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

Simulation Class Reference

#include <Simulation.h>

List of all members.


Detailed Description

The Simulation class represents an event based simulation.

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.

Author:
Thomas Jacob

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.

SimulationEventGetEvent (int eventNr)
 Returns an event of the event array at a given position.

long GetEventCount ()
 Returns the number of events in the event array.

SimulationObjectGetObject (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.


Constructor & Destructor Documentation

Simulation  ) 
 

Creates a new simulation.

~Simulation  ) 
 

Destroys the simulation.


Member Function Documentation

void AddEvent SimulationEvent Event,
long  time
 

Adds an event to the simulation.

Parameters:
Event The event to be added.
time The time to schedule the event to.

void AddObject SimulationObject Object  ) 
 

Adds an object to the simulation.

Parameters:
Object The object to be added.

void DeleteEvent SimulationEvent Event  ) 
 

Deletes an event of the simulation.

The event is looked up, removed and freed.

Parameters:
Event The event to be deleted.

void DeleteEvent int  eventNr  ) 
 

Deletes an event of the simulation.

The event is looked up, removed and freed.

Parameters:
eventNr The position of the event in the event array.

void DeleteObject SimulationObject Object  ) 
 

Deletes an object of the simulation.

The object is looked up, removed and freed.

Parameters:
Object The object to be deleted.

void DeleteObject int  objectNr  ) 
 

Deletes an object of the simulation.

The object is looked up, removed and freed.

Parameters:
objectNr The position of the object in the object array.

void End  )  [inline]
 

Ends the simulation.

Use this method in an event method to notify the simulation to stop after the current event has been handled.

long GetClock  )  [inline]
 

Returns the simulation clock.

This is the time of the current event.

Returns:
The simulation clock.

SimulationEvent* GetEvent int  eventNr  ) 
 

Returns an event of the event array at a given position.

Parameters:
eventNr The position of the event.
Returns:
The event at that position.

long GetEventCount  )  [inline]
 

Returns the number of events in the event array.

Returns:
The number of events in the event array.

SimulationObject* GetObject int  objectNr  ) 
 

Returns an object of the object array at a given position.

Parameters:
objectNr The position of the object.
Returns:
The object at that position.

long GetObjectCount  )  [inline]
 

Returns the number of objects in the object array.

Returns:
The number of objects in the object array.

bool HasEnded  )  [inline]
 

Returns, if the simulation has ended.

Returns:
If the simulation has ended.

void Reset  ) 
 

Resets the simulation.

All events and objects are removed from their respective arrays.

void Run long  endTime  ) 
 

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.

Parameters:
endTime The time to end the simulation, if it is not stopped before.

void Run  ) 
 

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.


Member Data Documentation

long Clock [private]
 

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.

ArrayList<SimulationEvent>* Events [private]
 

The array of the simulation events in the future.

Definition at line 40 of file Simulation.h.

bool HasEndedFlag [private]
 

If the simulation has ended.

Definition at line 45 of file Simulation.h.

ArrayList<SimulationObject>* Objects [private]
 

The array of the simulation objects.

Definition at line 50 of file Simulation.h.


The documentation for this class was generated from the following file:
Generated on Tue Oct 3 00:23:40 2006 for ToolBox by doxygen 1.3.6