swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sharing variables.


From: Eric Werk
Subject: Re: Sharing variables.
Date: Wed, 03 Mar 1999 14:53:22 +0100

Hi Fabio,

You have the variable you want to share in the class you want to give
write access, for eksample in Modelswarm, and then you implement a
method (in ModelSwarm) to read the variable. Here is an eksample:

@interface ModelSwarm: Swarm
{
   int  shared;
}
- (int) getShared;
@end;

@implementation ModelSwarm
- (int) getShared
{
   return shared
}
@end;

Then you let all your Agents have a reference to the ModelSwarm, that
you have to initialize when you create the Agent objects

@interface Agent: Swarm
{
   id modelSwarm;
}
- initModel: aModelSwarm;

and then you can read the shared variable with 
[modelSwarm getShared];

/Eric Werk

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]