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)
virtual ~cSimulation ()
Redefined cObject member functions.
virtual cObjectdup () 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 addModule (cModule *mod)
void deleteModule (int id)
int lastModuleId () 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 setupNetwork (cNetworkType *net, int run_num)
void startRun ()
void callFinish ()
void endRun ()
void deleteNetwork ()
void setNetIfCheckFreq (int f)
Information about the current simulation run.
cNetworkTypenetworkType () const
int runNumber () const
simtime_t simTime () const
long eventNumber () const
Scheduling and context switching during simulation.
cSimpleModuleselectNextModule ()
void doOneEvent (cSimpleModule *m)
void transferTo (cSimpleModule *p)
void 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)

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 )
 

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

cSimulation::cSimulation ( const char * name ) [explicit]
 

Constructor.

cSimulation::~cSimulation ( ) [virtual]
 

Destructor.


Member Function Documentation

int cSimulation::addModule ( 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.

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::deleteModule ( int id )
 

Deletes a module identified by its ID.

void cSimulation::deleteNetwork ( )
 

Cleans up the network currently set up. With distributed simulation, also notifies other segments that they should clean up their networks.

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. Also increments the event number (returned by eventNumber()).

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

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

Reimplemented from cObject.

void cSimulation::endRun ( )
 

Should be called at the end of a simulation run. With distributed simulation, this signals other segments that they should stop execution.

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.

int cSimulation::lastModuleId ( ) 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.

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

Assignment is not supported by this class: this method throws a cException when called.

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

DEPRECATED because it might return null reference; use module(int) instead.

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

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. If the FES is empty, returns NULL.

void cSimulation::setContextModule ( cModule * p )
 

Sets the module in context. Used internally.

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::setSystemModule ( cModule * p ) [inline]
 

Sets the system module.

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

Builds a new network and initializes it. With distributed simulation, also sets up network on other segments.

simtime_t cSimulation::simTime ( ) const [inline]
 

Returns current simulation time.

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::startRun ( )
 

Should be called after setupNetwork(), just before the first doOneEvent() call. The initialize() methods of modules are called here. With distributed simulation, also tells other segments that to begin executing the simulation.

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

Returns pointer to the system module.

void cSimulation::transferTo ( cSimpleModule * p )
 

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

void cSimulation::transferToMain ( )
 

Switches to main coroutine.

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 Mon Jun 16 23:37:33 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001