Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

cSimulation Class Reference

#include <csimul.h>

Inheritance diagram for cSimulation::

cObject List of all members.

Public Methods

Constructor, destructor.
 cSimulation (const cSimulation &r)
 cSimulation (const char *name, cHead *h=NULL)
virtual ~cSimulation ()
Redefined cObject member functions.
virtual const char* className () const
virtual cObjectdup () const
virtual const char* inspectorFactoryName () const
virtual void forEach (ForeachFunc f)
virtual void writeContents (ostream &os)
virtual const char* fullPath () const
virtual const char* fullPath (char *buffer, int bufsize) const
cSimulation& operator= (const cSimulation &)
Accessing modules.
int add (cModule *mod)
void del (int id)
int lastModuleIndex () const
cModulemoduleByPath (const char *modulepath) const
cModulemodule (int id) const
cModuleoperator[] (int id) const
void setSystemModule (cModule *p)
cModulesystemModule () const
Setting up and finishing a simulation run.
void setNetInterface (cNetMod *netif)
cNetModnetInterface () const
void resetClock ()
void startClock ()
void stopClock ()
bool setupNetwork (cNetworkType *net, int run_num)
void startRun ()
void callFinish ()
void endRun ()
void deleteNetwork ()
void setTimeLimit (long t)
void setSimTimeLimit (simtime_t t)
void setNetIfCheckFreq (int f)
Information about the current simulation run.
cNetworkTypenetworkType () const
int runNumber () const
long timeLimit () const
simtime_t simTimeLimit () const
simtime_t simTime () const
long eventNumber () const
Scheduling and context switching during simulation.
cSimpleModuleselectNextModule ()
void doOneEvent (cSimpleModule *m)
void incEventNumber ()
void checkTimes ()
int transferTo (cSimpleModule *p)
int transferToMain ()
void setContextModule (cModule *p)
void setGlobalContext ()
void setLocalList (cHead *p)
cSimpleModulerunningModule () const
cModulecontextModule () const
cSimpleModulecontextSimpleModule () const
cHeadlocalList ()
Snapshots.
bool snapshot (cObject *obj, const char *label)
Errors and warnings.
bool warnings () const
void setWarnings (bool w)
void terminate (int errcode, const char *message)
void error (int errcode, const char *message)
void warning (int errcode, const char *message)
bool ok () const
int errorCode () const
void setErrorCode (int e)
bool normalTermination () const
void resetError ()

Detailed Description

Simulation manager class. cSimulation is the central class in OMNeT++, and it has only one instance, the global variable simulation. It holds the modules, it manages setting up a simulation, running and finishing it, etc.

cSimulation should normally be of little interest to the simulation programmer. Most of its methods are called by the user interface libraries (Envir, Cmdenv, Tkenv) to set up and run simulations.


Constructor & Destructor Documentation

cSimulation::cSimulation ( const cSimulation & r ) [inline]
 

Copy constructor is not supported: This function gives an error via operator= when called.

cSimulation::cSimulation ( const char * name,
cHead * h = NULL ) [explicit]
 

Constructor.

cSimulation::~cSimulation ( ) [virtual]
 

Destructor.


Member Function Documentation

int cSimulation::add ( cModule * mod )
 

Adds a new module and return its ID.

void cSimulation::callFinish ( )
 

Recursively calls finish() on the modules of the network. This method simply invokes callfinish() on the system module.

void cSimulation::checkTimes ( )
 

Checks if the current simulation has reached the simulation or real time limits, and if so, stops the simulation with the appropriate message.

const char * cSimulation::className ( ) const [inline, virtual]
 

Returns pointer to a string containing the class name, "cSimulation".

Reimplemented from cObject.

cModule * cSimulation::contextModule ( ) const [inline]
 

Returns the module currently in context.

cSimpleModule * cSimulation::contextSimpleModule ( ) const
 

Returns the module currently in context as a simple module. If the module in context is not a simple module, returns NULL. This is a convenience function which simply calls contextModule().

void cSimulation::del ( int id )
 

Deletes a module identified by its ID.

void cSimulation::deleteNetwork ( )
 

Cleans up the simulation network currently set up. Deletes modules, message queue etc.

void cSimulation::doOneEvent ( cSimpleModule * m )
 

Executes one event. The argument should be the module returned by selectNextModule(); that is, the module to which the next event (lowest timestamp event in the FES) belongs.

cObject * cSimulation::dup ( ) const [inline, virtual]
 

Dupping is not implemented for this class. This function gives an error via operator= when called.

Reimplemented from cObject.

void cSimulation::endRun ( )
 

Should be called at the end of a simulation run. Closes open files, etc.

void cSimulation::error ( int errcode,
const char * message )
 

Issue error message.

int cSimulation::errorCode ( ) const [inline]
 

Returns current error code.

long cSimulation::eventNumber ( ) const [inline]
 

Returns sequence number of current event.

void cSimulation::forEach ( ForeachFunc f ) [virtual]
 

Call the passed function for each contained object. See cObject for more details.

Reimplemented from cObject.

const char * cSimulation::fullPath ( char * buffer,
int bufsize ) const [virtual]
 

Returns the name of the simulation object, "simulation".

Reimplemented from cObject.

const char * cSimulation::fullPath ( ) const [virtual]
 

Redefined. (Reason: a C++ rule that overloaded virtual methods must be redefined together.)

Reimplemented from cObject.

void cSimulation::incEventNumber ( ) [inline]
 

Increments the event number.

const char * cSimulation::inspectorFactoryName ( ) const [inline, virtual]
 

Returns the name of the inspector factory class associated with this class. See cObject for more details.

Reimplemented from cObject.

int cSimulation::lastModuleIndex ( ) const [inline]
 

Returns highest used module ID.

cHead * cSimulation::localList ( ) [inline]
 

Returns the currently active 'locals' object. This object is usually the locals data member of the module in context, or the global locals object if we are in global context. This facility is used internally to manage ownership of user objects created within simple modules.

cModule * cSimulation::module ( int id ) const [inline]
 

Looks up a module by ID.

cModule * cSimulation::moduleByPath ( const char * modulepath ) const
 

Finds a module by its path.

cNetMod * cSimulation::netInterface ( ) const [inline]
 

Returns network interface module.

cNetworkType * cSimulation::networkType ( ) const [inline]
 

Returns the cNetworkType object that was used to set up the current simulation model.

bool cSimulation::normalTermination ( ) const
 

Examines error code and returns true if simulation terminated normally.

bool cSimulation::ok ( ) const [inline]
 

Returns true if no errors happened (i.e. error code is zero, eOK).

cSimulation & cSimulation::operator= ( const cSimulation & ) [inline]
 

Assignment is not supported for this class. This function raises an error when called.

cModule & cSimulation::operator[] ( int id ) const [inline]
 

Same as module(int), only this returns reference instead of pointer.

void cSimulation::resetClock ( )
 

Resets the clock measuring the elapsed (real) time spent in this simulation run.

void cSimulation::resetError ( ) [inline]
 

Reset error code.

int cSimulation::runNumber ( ) const [inline]
 

Returns the current run number. A run is the execution of a model with a given set of parameter settings. Runs can be defined in omnetpp.ini.

cSimpleModule * cSimulation::runningModule ( ) const [inline]
 

Returns the currently executing simple module.

cSimpleModule * cSimulation::selectNextModule ( )
 

The scheduler function. Returns the module to which the next event (lowest timestamp event in the FES) belongs.

void cSimulation::setContextModule ( cModule * p )
 

Sets the module in context. Used internally.

void cSimulation::setErrorCode ( int e ) [inline]
 

Sets error code without giving error message.

void cSimulation::setGlobalContext ( ) [inline]
 

Sets global context. Used internally.

void cSimulation::setLocalList ( cHead * p ) [inline]
 

Sets the 'locals' object for the current context.

void cSimulation::setNetIfCheckFreq ( int f ) [inline]
 

Used with distributed simulation, sets the frequency of checking messages arriving from other segments. This setting is mostly useful for performance tuning. The meaning of the value is: "check the network interface after every f local events."

void cSimulation::setNetInterface ( cNetMod * netif )
 

Sets network interface module.

void cSimulation::setSimTimeLimit ( simtime_t t ) [inline]
 

Sets a simulation time limit for the current simulation run.

void cSimulation::setSystemModule ( cModule * p ) [inline]
 

Sets the system module.

void cSimulation::setTimeLimit ( long t ) [inline]
 

Sets an execution time limit for the current simulation run. The value is understood in seconds.

void cSimulation::setWarnings ( bool w ) [inline]
 

Globally disable/enable warnings.

bool cSimulation::setupNetwork ( cNetworkType * net,
int run_num )
 

Builds a new network.

simtime_t cSimulation::simTime ( ) const [inline]
 

Returns current simulation time.

simtime_t cSimulation::simTimeLimit ( ) const [inline]
 

Returns simulation time limit for the current simulation run.

bool cSimulation::snapshot ( cObject * obj,
const char * label )
 

Writes a snapshot of the given object and its children to the textual snapshot file. This method is called internally from cSimpleModule's snapshot().

void cSimulation::startClock ( )
 

Start measuring elapsed (real) time spent in this simulation run.

void cSimulation::startRun ( )
 

Initializes network.

void cSimulation::stopClock ( )
 

Stop measuring elapsed (real) time spent in this simulation run.

cModule * cSimulation::systemModule ( ) const [inline]
 

Returns pointer to the system module.

void cSimulation::terminate ( int errcode,
const char * message )
 

Prints a termination message and sets the error number.

long cSimulation::timeLimit ( ) const [inline]
 

Returns CPU time limit for the current simulation run.

int cSimulation::transferTo ( cSimpleModule * p )
 

Switches to simple module's coroutine. This method is invoked from doOneEvent() for activity()-based modules.

int cSimulation::transferToMain ( )
 

Switches to main coroutine.

void cSimulation::warning ( int errcode,
const char * message )
 

Issues simulation warning. message + question:continue/abort?

bool cSimulation::warnings ( ) const [inline]
 

Return true if warnings are globally enabled.

void cSimulation::writeContents ( ostream & os ) [virtual]
 

Writes textual information about this object to the stream. See cObject for more details.

Reimplemented from cObject.


The documentation for this class was generated from the following file:
Generated at Sat May 4 15:45:51 2002 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001