swarm-support
[Top][All Lists]
Advanced

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

making Argument processing live in peace with lispAppArchiver


From: Paul E. Johnson
Subject: making Argument processing live in peace with lispAppArchiver
Date: Fri, 29 Jun 2001 15:41:23 -0500

Dear everybody:

This is a question about the sequence of object creation and parameter
setting.  Am I misunderstanding something?

I've got some classes that use the lispAppArchiver.  My code  follows
HeatbugBatchSwarm.m:

if ((asmModelParams =
       [lispAppArchiver getWithZone: [self getZone] key:
"asmModelParams"]) == nil)
    raiseEvent(InvalidOperation,
               "Can't find the modelSwarm parameters");

I have a few of these parameter objects, and I am trying to clear up
this complicated set of code by instantiating them in once centralized
place,  a class Parameters, where I also want to process command line
arguments (initSwarmArguments is used in main.m, referring to
[Parameters class] in the third argument.)

The problem is that the +createBegin/createEnd methods of the Parameter
class are called the very first thing in the simulation, even before the
lispAppArchiver exists, so I cannot find a way to create the parameter
objects and then have the parsed command line arguments override the
defaults loaded from the scm files.   I was trying to keep this direct,
with a parseKey setup like:

if (key == 'p')
    {
      asmModelParams->P= atoi(arg);
      return 0;
    }


As I read the source code for Arguments_c, the parsing of command line
arguments is triggered by its -createEnd method, and so I thought I
could beat it like so in Parameters.m (call the superclass's createEnd:
at the end to  do the parsing)

- createEnd
{

  if ((asmModelParams =
       [lispAppArchiver getWithZone: [self getZone] key:
"asmModelParams"]) == nil)
    raiseEvent(InvalidOperation,
               "Can't find the modelSwarm parameters");

      return [super createEnd];
}

That fails because "The message `getWithZone:key:' was sent to nil,
lispAppArchiver does not exist yet.

So I'm left with the prospect of creating a list of ivars in Parameters,
and parsing arguments into them, and then having a method that sticks
those values back into the asmModelParams object.  It seems more tedious
than necessary.

I have found my way to swarm's src/SwarmEnvironment.m, through to
src/defobj/defobj.m.   I'm not seeing a good/easy way for me to tweak
the swarm source to make the lispAppArchiver get created before
arguments. Is my reading correct?

Your friend

Paul Johnson


                  ==================================
   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]