User interface: cEnvir and ev

Classes

class  cEnvir
 cEnvir represents the "environment" of the simulation. More...
class  cRunnableEnvir
 The interface for cEnvir objects that can be instantiated as a user interface like Cmdenv and Tkenv. More...
class  cNullEnvir
 A cEnvir implementation with all pure virtual methods defined with an empty body, with a trivial implementation, or to throw an exception with the "unsupported method" text. More...

Defines

#define ev   (*cSimulation::getActiveEnvir())
#define EV   ev.isDisabled()?ev:ev

Define Documentation

#define EV   ev.isDisabled()?ev:ev

EV<< can be used instead of ev<< to make logging more efficient.

An example:

 EV << "Packet " << msg->getName() << " received\n";
 

EV utilizes cEnvir::isDisabled() to check whether the logged text is going to be printed/stored anywhere, or just gets discarded; in the latter case the << operators do not get evaluated at all, making the log statement effectively a zero cost operation.

#define ev   (*cSimulation::getActiveEnvir())

Represents the "environment" or user interface of the simulation.

Most common usage from model code (simple modules) is to write log messages, e.g.:

 ev << "Received packet " << msg->getName() << ", length " << msg->getBitLength()/8 << " bytes\n";
 ev << "Sending up to higher layer\n";
 

Other useful methods are cEnvir::isGUI() and cEnvir::isDisabled().

The rest of cEnvir methods are used internally for communication between the simulation kernel and the environment.

Referenced by cComponent::getRNG().

Generated on Fri Mar 7 17:19:39 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3