Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Simulation.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the ToolBox.
00003  * Copyright Thomas Jacob.
00004  *
00005  * READ README.TXT BEFORE USE!!
00006  */
00007 
00008 
00009 #ifndef __TOOLBOX_SIMULATION_H
00010 #define __TOOLBOX_SIMULATION_H
00011 
00012 
00013 namespace toolbox
00014 {
00026    class Simulation
00027    {
00028       private:
00029 
00035          long Clock;
00036 
00040          ArrayList<SimulationEvent> * Events;
00041 
00045          bool HasEndedFlag;
00046 
00050          ArrayList<SimulationObject> * Objects;
00051 
00052          #ifdef _TOOLBOX_TEST
00053 
00056             static int InstanceCount;
00057          #endif
00058 
00059       public:
00060 
00064          Simulation();
00065 
00069          ~Simulation();
00070 
00076          void AddEvent(SimulationEvent * Event, long time);
00077 
00082          void AddObject(SimulationObject * Object);
00083 
00089          void DeleteEvent(int eventNr);
00090 
00096          void DeleteEvent(SimulationEvent * Event);
00097 
00103          void DeleteObject(int objectNr);
00104 
00110          void DeleteObject(SimulationObject * Object);
00111 
00117          inline void End();
00118 
00124          inline long GetClock();
00125 
00132          SimulationEvent * GetEvent(int eventNr);
00133 
00138          inline long GetEventCount();
00139 
00146          SimulationObject * GetObject(int objectNr);
00147 
00152          inline long GetObjectCount();
00153 
00158          inline bool HasEnded();
00159 
00164          void Reset();
00165 
00174          void Run();
00175 
00190          void Run(long endTime);
00191 
00192          #ifdef _TOOLBOX_TEST
00193 
00199             static void RunTestSuite(int * performedTests, int * failedTests);
00200          #endif
00201    };
00202 
00203 
00213    class SimulationEvent
00214    {
00215       friend Simulation;
00216 
00217       private:
00218 
00219          #ifdef _TOOLBOX_TEST
00220 
00223             static int InstanceCount;
00224          #endif
00225 
00229          class Simulation * Simulation;
00230 
00234          long Time;
00235 
00236       public:
00237 
00241          SimulationEvent();
00242 
00246          virtual ~SimulationEvent();
00247 
00252          inline class Simulation * GetSimulation();
00253 
00258          inline long GetTime();
00259 
00267          virtual void Handle();
00268 
00269          #ifdef _TOOLBOX_TEST
00270 
00276             static void RunTestSuite(int * performedTests, int * failedTests);
00277          #endif
00278    };
00279 
00280 
00287    class SimulationEndEvent : public SimulationEvent
00288    {
00289       private:
00290 
00291          #ifdef _TOOLBOX_TEST
00292 
00295             static int InstanceCount;
00296          #endif
00297 
00298       public:
00299 
00303          SimulationEndEvent();
00304 
00308          virtual ~SimulationEndEvent();
00309 
00314          virtual void Handle();
00315 
00316          #ifdef _TOOLBOX_TEST
00317 
00323             static void RunTestSuite(int * performedTests, int * failedTests);
00324          #endif
00325    };
00326 
00327 
00334    class SimulationObject
00335    {
00336       friend Simulation;
00337 
00338       private:
00339 
00340          #ifdef _TOOLBOX_TEST
00341 
00344             static int InstanceCount;
00345          #endif
00346 
00350          class Simulation * Simulation;
00351 
00352       public:
00353 
00357          SimulationObject();
00358 
00362          virtual ~SimulationObject();
00363 
00368          inline class Simulation * GetSimulation();
00369 
00370          #ifdef _TOOLBOX_TEST
00371 
00377             static void RunTestSuite(int * performedTests, int * failedTests);
00378          #endif
00379    };
00380 }
00381 
00382 
00383 #endif

Generated on Tue Oct 3 00:23:38 2006 for ToolBox by doxygen 1.3.6