#include <Simulation.h>
In consists of a simulation clock, a array of all objects of the simulation, and a arrray of all events in the future. The clock is advanced from event to event, and for each event, an event method is called, which adds new events, removes existing ones, modifies objects, creates or destroys them, or ends the simulation.
Definition at line 26 of file Simulation.h.
Public Member Functions | |
void | AddEvent (SimulationEvent *Event, long time) |
Adds an event to the simulation. | |
void | AddObject (SimulationObject *Object) |
Adds an object to the simulation. | |
void | DeleteEvent (SimulationEvent *Event) |
Deletes an event of the simulation. | |
void | DeleteEvent (int eventNr) |
Deletes an event of the simulation. | |
void | DeleteObject (SimulationObject *Object) |
Deletes an object of the simulation. | |
void | DeleteObject (int objectNr) |
Deletes an object of the simulation. | |
void | End () |
Ends the simulation. | |
long | GetClock () |
Returns the simulation clock. | |
SimulationEvent * | GetEvent (int eventNr) |
Returns an event of the event array at a given position. | |
long | GetEventCount () |
Returns the number of events in the event array. | |
SimulationObject * | GetObject (int objectNr) |
Returns an object of the object array at a given position. | |
long | GetObjectCount () |
Returns the number of objects in the object array. | |
bool | HasEnded () |
Returns, if the simulation has ended. | |
void | Reset () |
Resets the simulation. | |
void | Run (long endTime) |
Starts the simulation. | |
void | Run () |
Starts the simulation. | |
Simulation () | |
Creates a new simulation. | |
~Simulation () | |
Destroys the simulation. | |
Private Attributes | |
long | Clock |
The simulation clock. | |
ArrayList< SimulationEvent > * | Events |
The array of the simulation events in the future. | |
bool | HasEndedFlag |
If the simulation has ended. | |
ArrayList< SimulationObject > * | Objects |
The array of the simulation objects. |
|
Creates a new simulation.
|
|
Destroys the simulation.
|
|
Adds an event to the simulation.
|
|
Adds an object to the simulation.
|
|
Deletes an event of the simulation. The event is looked up, removed and freed.
|
|
Deletes an event of the simulation. The event is looked up, removed and freed.
|
|
Deletes an object of the simulation. The object is looked up, removed and freed.
|
|
Deletes an object of the simulation. The object is looked up, removed and freed.
|
|
Ends the simulation. Use this method in an event method to notify the simulation to stop after the current event has been handled. |
|
Returns the simulation clock. This is the time of the current event.
|
|
Returns an event of the event array at a given position.
|
|
Returns the number of events in the event array.
|
|
Returns an object of the object array at a given position.
|
|
Returns the number of objects in the object array.
|
|
Returns, if the simulation has ended.
|
|
Resets the simulation. All events and objects are removed from their respective arrays. |
|
Starts the simulation. The method takes an event of the event array after another and executes its event method (Handle). Events are automatically deleted after they have been executed. The method returns, when the End method has been called to indicate the end of the simulation, or if a given time has passed. The method does this by adding a SimulationEndEvent to the event array before the simulation is started, and then uses the Run() overload.
|
|
Starts the simulation. The method takes an event of the event array after another and executes its event method (Handle). Events are automatically deleted after they have been executed. The method returns, when the End method has been called to indicate the end of the simulation. |
|
The simulation clock. This is the time of the current event being handled and is advanced in irregular steps according to the occurring events of the simulation. Definition at line 35 of file Simulation.h. |
|
The array of the simulation events in the future.
Definition at line 40 of file Simulation.h. |
|
If the simulation has ended.
Definition at line 45 of file Simulation.h. |
|
The array of the simulation objects.
Definition at line 50 of file Simulation.h. |