[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: createActionTo
From: |
Marcus G. Daniels |
Subject: |
Re: createActionTo |
Date: |
29 Dec 1999 18:33:39 -0800 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "NEN" == Norberto Eiji Nawa <address@hidden> writes:
NEN> I wonder if there are more elegant ways to do the same thing...
Here's something new with the current snapshot from:
ftp://ftp.santafe.edu/pub/swarm/testing
A similar example for Java was posted the other day. Objective C users
would need to build and install the snapshot in order to get the new
headers and libraries in place (a DLL upgrade in not sufficient).
#import <simtools.h> // initSwarm
#import <objectbase/Swarm.h> // Swarm
#import <activity.h> // Schedule
@interface Controller: Swarm
{
id <Schedule> schedule;
id <Schedule> stopSchedule;
}
@end
@implementation Controller
- (void)stepX: (double)x Y: (double)y
{
printf ("stepX: %lf Y: %lf @ %lu\n", x, y, getCurrentTime ());
}
- stop
{
[getTopLevelActivity () terminate];
return self;
}
- buildActions
{
[super buildActions];
schedule = [Schedule create: self setRepeatInterval: 1];
[schedule at: 0
createFAction: [FCall create: self
target: self
selector: M(stepX:Y:)
arguments: [[[[[FArguments createBegin: self]
setSelector: M(stepX:Y:)]
addDouble: 10.0]
addDouble: 20.0]
createEnd]]];
stopSchedule = [Schedule create: self setAutoDrop: YES];
[stopSchedule at: 10 createActionTo: self message: M(stop)];
return self;
}
- activateIn: swarmContext
{
[super activateIn: swarmContext];
[schedule activateIn: self];
[stopSchedule activateIn: self];
return [self getActivity];
}
@end
int
main (int argc, const char **argv)
{
initSwarmBatch (argc, argv);
{
id controller = [Controller create: globalZone];
[controller buildObjects];
[controller buildActions];
[[controller activateIn: nil] run];
}
}
/*
Local Variables:
compile-command: "gcc -DDLL -o testFAction -g -Wno-import -I$SWARMHOME/include
-L$SWARMHOME/lib testFAction.m -lswarmdll -lobjcdll"
End:
*/
==================================
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.