Objective C does not strictly offer ``class variables'', or, at least, has no explicit support for them. However the effect of such variables can be realised by using static variables with file scope in the class implementation file. Note, however, that these variables will not be accessible to subclasses.
Class variables are useful in SCL to implement reaction and mobility parameters. These must be common to all objects of a specified class. They could be implemented with conventional global variables; but since they are class specific, it is more appropriate to implement them as class variables.
A problem with this approach is that the Swarm probe machinery does not support probing of class objects. Thus, probes cannot be used directly to give user access to these parameters. I understand that this is a fairly fundamental limitation, and is unlikely to be removed in the future.
However, this is easily worked around by introducing a special object, parameterManager which ``shadows'' the class variables as instance variables. This can then be probed as usual to provide access to the parameters. Some care is required in using this approach. One can normally use a probe to directly modify instance variables; one can do that in this case also, but it will not automatically have the desired or expected effect, because such modifications do not, in themselves, affect the class variables. To correct this, the parameterManager provides the apply method which essentially copies all the instance variables into the corresponding class variables. To make the behaviour as robust as possible, an invocation of apply in included in every timestep--so that any changes in the instance variables will automatically take full effect at the start of the next timestep. Similarly, apply is invoked immediately prior to saving a model to disk.
Copyright © 1997 All Rights Reserved.
Timestamp: Tue Dec 31 19:40:38 GMT 1996