Main Page Modules Class Hierarchy Compound List File List Compound Members

# cEnvir Class Reference

`#include <cenvir.h>`

List of all members.

## Public Methods

Constructor, destructor.
Note that only one instance of cEnvir exists, the ev object.
| cEnvir ()
| ~cEnvir ()
Methods called from main().
void | setup (int ac, char *av[])
int | run ()
void | shutdown ()
Methods to be called by the simulation kernel to notify the environment about events.
void | objectDeleted (cObject *object)
void | messageSent (cMessage *msg)
void | messageDelivered (cMessage *msg)
void | breakpointHit (const char *lbl, cSimpleModule *mod)
Methods called by the simulation kernel to access configuration settings.
const char* | getParameter (int run_no, const char *parname)
const char* | getPhysicalMachineFor (const char *logical_mach)
const char* | getDisplayString (int run_no, const char *name)
Input/output methods called from simple modules or the simulation kernel.
void | printfmsg (const char *fmt,...)
void | printf (const char *fmt="\n",...)
void | puts (const char *s)
void | flush ()
bool | gets (const char *prompt, char *buf, int len=255)
bool | askf (char *buf, int len, const char *promptfmt,...)
bool | askYesNo (const char *msgfmt,...)
cEnvir& | setPrompt (const char *s)
const char* | prompt () const
void | foreignPuts (const char *hostname, const char *mod, const char *str)
Methods for recording data from output vectors.
These are functions cOutVector internally relies on. The behavior of these functions can be changed by plugging in a different cOutputVectorManager object into the user interface library. (Or alternatively, by reimplementing the whole cEnvir of course).
void* | registerOutputVector (const char *modulename, const char *vectorname, int tuple)
void | deregisterOutputVector (void *vechandle)
bool | recordInOutputVector (void *vechandle, simtime_t t, double value)
bool | recordInOutputVector (void *vechandle, simtime_t t, double value1, double value2)
Scalar statistics.
These are the functions the cSimpleModule::recordScalar() functions internally rely on. The behavior of these functions can be changed by plugging in a different cOutputScalarManager object into the user interface library. (Or alternatively, by reimplementing the whole cEnvir of course).
void | recordScalar (cModule *module, const char *name, double value)
void | recordScalar (cModule *module, const char *name, const char *text)
void | recordScalar (cModule *module, const char *name, cStatistic *stats)
Management of streams where snapshots can be written.
The behavior of these functions can be changed by plugging in a different cSnapshotManager object into the user interface library. (Or alternatively, by reimplementing the whole cEnvir of course).
ostream* | getStreamForSnapshot ()
void | releaseStreamForSnapshot (ostream *os)
Miscellaneous functions.
unsigned | extraStackForEnvir ()
int | runningMode () const
int | argCount ()
char** | argVector ()

## Detailed Description

Interface to the environment (user interface) of the simulation. cEnvir is a common facade for the Cmdenv and Tkenv user interfaces (and any other future user interface).

cEnvir has only one instance, the ev global variable.

cEnvir member functions can be rougly divided into two groups:

- I/O for module activities; actual implementation is different for each user interface (e.g. stdin/stdout for Cmdenv, windowing in Tkenv)
- functions for exchanging information between the simulation and the environment.

The implementation of cEnvir is not part of the simulation kernel, it's in a separate library (the Envir library; see src/envir). This means that customizers are free to replace the environment of the simulation as they like, by simply linking the executable with a different library.

The default (Envir library) implementation of cEnvir delegates its task to an internal "simulation application" object. Cmdenv and Tkenv inherit from the default simulation application class.

The default (src/envir) implementation of cEnvir can be customized without changing the via classes declared in the envirext.h header (e.g. cOutputVectorManager, cOutputScalarManager).

See also:
  cOutputVectorManager class , cOutputScalarManager class

## Constructor & Destructor Documentation

cEnvir::cEnvir ( | )

| Constructor.

cEnvir::~cEnvir ( | )

| Destructor.

## Member Function Documentation

int cEnvir::argCount ( | )

| Access to original command-line arguments.

char ** cEnvir::argVector ( | )

| Access to original command-line arguments.

bool cEnvir::askYesNo ( | const char * msgfmt,
| ... )

| Puts a yes/no question to the user. The question itself is expected in the printf() format (format string + arguments). The true return value means yes, false means no.

bool cEnvir::askf ( | char * buf,
| int len,
| const char * promptfmt,
| ... )

| Pops up a dialog, displays the message given in 'promptfmt' and following arguments in printf() format and reads a line (maximum len characters) from the user into the buffer 'buf'. Returns true if the user pressed the Cancel button.

void cEnvir::breakpointHit ( | const char * lbl,
| cSimpleModule * mod )

| Notifies the environment that a simple module executed a breakpoint() call.

void cEnvir::deregisterOutputVector ( | void * vechandle )

| cOutVector objects must deregister themselves when they are no longer needed.

unsigned cEnvir::extraStackForEnvir ( | )

| Called from cSimpleModule; it returns how much extra stack space the user interface recommends for the simple modules.

void cEnvir::flush ( | )

| Flushes the output buffer of ev.printf() and ev<< operations. Only some user interfaces need it: it can be useful with Cmdenv which writes to the standard output, but no need for it with Tkenv which displays all output immediately anyway.

void cEnvir::foreignPuts ( | const char * hostname,
| const char * mod,
| const char * str )

| Used with parallel execution. It is called internally by the simulation kernel when something was written to ev by another segment.

const char * cEnvir::getDisplayString ( | int run_no,
| const char * name )

| Returns display string for an object given with its full name.

const char * cEnvir::getParameter ( | int run_no,
| const char * parname )

| Called by the simulation kernel (cModulePar) to obtain value for an input module parameter.

const char * cEnvir::getPhysicalMachineFor ( | const char * logical_mach )

| User by distributed execution. Returns physical name for a logical machine name.

ostream * cEnvir::getStreamForSnapshot ( | )

| Returns a stream where a snapshot can be written. Called from cSimulation::snapshot().

bool cEnvir::gets ( | const char * prompt,
| char * buf,
| int len = 255 )

| Similar to cEnvir::askf(), but just writes out the prompt message string with no formatting.

void cEnvir::messageDelivered ( | cMessage * msg )

| Notifies the environment that a message was delivered to its destination module, that is, a message arrival event occurred. Details can be extracted from the message object itself. The user interface implementation may use the notification to animate the message on a network diagram, to write a log entry, etc.

void cEnvir::messageSent ( | cMessage * msg )

| Notifies the environment that a message was sent. Details can be extracted from the message object itself. The user interface implementation may use the notification to animate the message on a network diagram, to write a log entry, etc.

void cEnvir::objectDeleted ( | cObject * object )

| Notifies the environment that the object no longer exists. The user interface should close all inspector windows for the object and remove it from object lists currently displayed. cObject's destructor automatically calls this function.

void cEnvir::printf ( | const char * fmt = "\n",
| ... )

| Simple modules can output text into their own window through this function. The text is expected in printf() format (format string + arguments).

void cEnvir::printfmsg ( | const char * fmt,
| ... )

| Displays a message in dialog box. This function should not be used too much by simple modules, if ever.

const char * cEnvir::prompt ( | ) const`[inline]`

| Returns the prompt string.

void cEnvir::puts ( | const char * s )

| Similar to ev.printf(), but just writes out its argument string with no formatting.

bool cEnvir::recordInOutputVector ( | void * vechandle,
| simtime_t t,
| double value1,
| double value2 )

| This method is intended to be called by cOutVector objects to write a value pair into the output vector. The return value is true if the data was actually recorded, and false if it was not recorded (because of filtering, etc.)

bool cEnvir::recordInOutputVector ( | void * vechandle,
| simtime_t t,
| double value )

| This method is intended to be called by cOutVector objects to write a value into the output vector. The return value is true if the data was actually recorded, and false if it was not recorded (because of filtering, etc.)

void cEnvir::recordScalar ( | cModule * module,
| const char * name,
| cStatistic * stats )

| Records a statistics object, in a default configuration into the scalar result file.

void cEnvir::recordScalar ( | cModule * module,
| const char * name,
| const char * text )

| Records a string result, in a default configuration into the scalar result file.

void cEnvir::recordScalar ( | cModule * module,
| const char * name,
| double value )

| Records a double scalar result, in a default configuration into the scalar result file.

void * cEnvir::registerOutputVector ( | const char * modulename,
| const char * vectorname,
| int tuple )

| This method is intended to be called by cOutVector objects to register themselves. The return value is a handle of type void*; this handle has to be passed to record() to identify the vector each time a value is written.

void cEnvir::releaseStreamForSnapshot ( | ostream * os )

| Releases a stream after a snapshot was written.

int cEnvir::run ( | )

| Called from main(). This function should encapsulate the whole functionality of running the application. The return value may be used as exit code for the simulation program.

int cEnvir::runningMode ( | ) const`[inline]`

| Returns whether the simulation is distributed, and if yes, if this process is master or slave.

cEnvir & cEnvir::setPrompt ( | const char * s )

| Sets the prompt for >> operators.

void cEnvir::setup ( | int ac,
| char * av[] )

| This function is called by main() at the beginning of the program. It receives the command-line arguments as parameters.

void cEnvir::shutdown ( | )

| Called from main() before exiting.

The documentation for this class was generated from the following file:

- cenvir.h