#include <cmodule.h>
Inheritance diagram for cSimpleModule::
Public Methods | |
int | moduleState () const |
Constructors, destructor, assignment. | |
cSimpleModule (const cSimpleModule &mod) | |
cSimpleModule (const char *name, cModule *parentmod, unsigned stk) | |
virtual | ~cSimpleModule () |
cSimpleModule& | operator= (const cSimpleModule &mod) |
Redefined cObject functions. | |
virtual const char* | className () const |
virtual cObject* | dup () const |
virtual void | info (char *buf) |
virtual const char* | inspectorFactoryName () const |
virtual void | forEach (ForeachFunc f) |
Redefined cModule functions. | |
virtual void | setId (int n) |
virtual bool | isSimple () const |
virtual bool | callInitialize (int stage) |
virtual void | callFinish () |
virtual void | scheduleStart (simtime_t t) |
virtual void | deleteModule () |
Information about the module. | |
bool | usesActivity () const |
Simulation time. | |
simtime_t | simTime () const |
Debugging aids. | |
void | setPhase (const char *phase) |
const char* | phase () const |
bool | snapshot (cObject *obj=&simulation, const char *label=NULL) |
void | breakpoint (const char *label) |
void | pause (const char *phase=NULL) |
Message sending. | |
int | send (cMessage *msg, int gateid) |
int | send (cMessage *msg, const char *gatename, int sn=-1) |
int | send (cMessage *msg, cGate *outputgate) |
int | sendDelayed (cMessage *msg, double delay, int gateid) |
int | sendDelayed (cMessage *msg, double delay, const char *gatename, int sn=-1) |
int | sendDelayed (cMessage *msg, double delay, cGate *outputgate) |
int | sendDirect (cMessage *msg, double delay, cModule *mod, int inputgateid) |
int | sendDirect (cMessage *msg, double delay, cModule *mod, const char *inputgatename, int sn=-1) |
int | sendDirect (cMessage *msg, double delay, cGate *inputgate) |
Self-messages. | |
int | scheduleAt (simtime_t t, cMessage *msg) |
cMessage* | cancelEvent (cMessage *msg) |
Parallel simulation. | |
int | syncpoint (simtime_t t, int gateid) |
int | syncpoint (simtime_t t, const char *gatename, int sn=-1) |
int | cancelSyncpoint (simtime_t t, int gateid) |
int | cancelSyncpoint (simtime_t t, const char *gatename, int sn=-1) |
Receiving messages. | |
These functions can only be used with activity(), but not with handleMessage(). | |
bool | isThereMessage () const |
cMessage* | receive () |
cMessage* | receive (simtime_t timeout) |
cMessage* | receiveOn (const char *gatename, int sn=-1, simtime_t timeout=MAXTIME) |
cMessage* | receiveOn (int gateid, simtime_t timeout=MAXTIME) |
cMessage* | receiveNew () |
cMessage* | receiveNew (simtime_t timeout) |
cMessage* | receiveNewOn (const char *gatename, int sn=-1, simtime_t timeout=MAXTIME) |
cMessage* | receiveNewOn (int gateid, simtime_t timeout=MAXTIME) |
Waiting. | |
void | wait (simtime_t time) |
Stopping the module or the simulation. | |
void | end () |
void | endSimulation () |
void | error (const char *fmt,...) const |
Statistics collection | |
void | recordScalar (const char *name, double value) |
void | recordScalar (const char *name, const char *text) |
void | recordStats (const char *name, cStatistic *stats) |
Heap allocation. | |
void* | memAlloc (size_t m) |
void | memFree (void *&p) |
Protected Methods | |
Hooks for defining module behavior. | |
Exactly one of activity() and handleMessage() must be redefined by the user to add functionality to the simple module. See the manual for detailed guidance on how use to these two methods.
These methods are made protected because they shouldn't be called directly from outside. | |
virtual void | activity () |
virtual void | handleMessage (cMessage *msg) |
All basic functions associated with the simulation such as sending and receiving messages are implemented as cSimpleModule's member functions.
The activity() functions run as coroutines during simulation. Coroutines are brought to cSimpleModule from the cCoroutine base class.
|
Copy constructor. |
|
Constructor. |
|
Destructor. |
|
Should be redefined to contain the module activity function. This default implementation issues an error message. |
|
Specifies a breakpoint. During simulation, if execution gets to a breakpoint() call (and breakpoints are active etc.), the simulation will be stopped, if the user interface can handle breakpoints. |
|
Calls finish() in the context of this module. Reimplemented from cModule. |
|
Calls initialize(int stage) in the context of this module. It does a single stage of initialization, and returns Reimplemented from cModule. |
|
Removes the given message from the message queue. The message needs to have been sent using the scheduleAt() function. This function can be used to cancel a timer implemented with scheduleAt(). |
|
Used with parallel execution: cancel a synchronization point set by a syncpoint() call. |
|
Used with parallel execution: cancel a synchronization point set by a syncpoint() call. |
|
Returns pointer to a string containing the class name, "cSimpleModule". Reimplemented from cModule. |
|
Deletes a dynamically created module. Reimplemented from cModule. |
|
Creates and returns an exact copy of this object. See cObject for more details. Reimplemented from cObject. |
|
Ends the run of the simple module. The simulation is not stopped (unless this is the last running module.) |
|
Causes the whole simulation to stop. |
|
Issue an error message. |
|
Call the passed function for each contained object. See cObject for more details. Reimplemented from cModule. |
|
Should be redefined to contain the module's message handling function. This default implementation issues an error message. |
|
Produces a one-line description of object contents into the buffer passed as argument. See cObject for more details. Reimplemented from cObject. |
|
Returns the name of the inspector factory class associated with this class. See cObject for more details. Reimplemented from cModule. |
|
Returns true. Reimplemented from cModule. |
|
Tells if the next message in the event queue is for the same module and has the same arrival time. (Returns true only if two or more messages arrived to the module at the same time.) |
|
Dynamic memory allocation. This function should be used instead of the global malloc() from inside the module function (activity()), if deallocation by the simple module constructor is not provided. Dynamic allocations are discouraged in general unless you put the pointer into the class declaration of the simple module class and provide a proper destructor. Or, you can use container classes (cArray, cQueue)! |
|
Frees a memory block reserved with the malloc() described above and NULLs the pointer. |
|
FIXME: Return module state. |
|
Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details. |
|
Sets phase string and temporarily yield control to the user interface. If the user interface supports step-by-step execution, one can stop execution at each receive() call of the module function and examine the objects, variables, etc. If the state of simulation between receive() calls is also of interest, one can use pause() calls. The string argument (if given) sets the phase string, so pause("here") is the same as setPhase("here"); pause(). |
|
Returns pointer to the current phase string. |
|
Returns the first message from the put-aside queue or, if it is empty, calls receiveNew() to return a message from the event queue with the given timeout. Note that the arrival time of the message returned by receive() can be earlier than the current simulation time. |
|
Receives a message from the put-aside queue or the FES. |
|
Removes the next message from the event queue and returns a pointer to it. Ignores put-aside queue. If there is no message in the event queue, the function waits with t timeout until a message will be available. If the timeout expires and there is still no message in the queue, the function returns NULL. |
|
Remove the next message from the event queue and return a pointer to it. Ignores put-aside queue. |
|
Same as the previous function except that the gate must be specified with its index in the gate array. Using this function instead the previous one may speed up the simulation if the function is called frequently. |
|
The same as receiveNew(), except that it returns the next message that arrives on the gate specified with its name and index. All messages received meanwhile are inserted into the put-aside queue. If the timeout expires and there is still no such message in the queue, the function returns NULL. In order to process messages that may have been put in the put-aside queue, the user is expected to call receive() or receiveOn(), or to examine the put-aside queue directly sometime. |
|
Same as the previous function except that the gate must be specified with its index in the gate array. Using this function instead the previous one may speed up the simulation if the function is called frequently. |
|
Scans the put-aside queue for the first message that has arrived on the gate specified with its name and index. If there is no such message in the put-aside queue, calls receiveNew() to return a message from the event queue with the given timeout. Note that the arrival time of the message returned by receive() can be earlier than the current simulation time. |
|
Records a string into the scalar result file. |
|
Records a double into the scalar result file. |
|
Records a statistics object into the scalar result file. |
|
Schedules a self-message. Receive() will return the message at t simulation time. |
|
Creates a starting message for the module. Reimplemented from cModule. |
|
Sends a message through the gate given with its pointer. |
|
Sends a message through the gate given with its name and index (if multiple gate). |
|
Sends a message through the gate given with its ID. |
|
Sends a message through the gate given with its pointer as if it was sent delay seconds later. |
|
Delayed sending. Sends a message through the gate given with its name and index (if multiple gate) as if it was sent delay seconds later. |
|
Delayed sending. Sends a message through the gate given with its index as if it was sent delay seconds later. |
|
Sends a message directly to another module (to an input gate). |
|
Send a message directly to another module (to an input gate). |
|
Send a message directly to another module (to an input gate). |
|
FIXME: redefined cModule functions: Reimplemented from cModule. |
|
Sets the phase string. The string can be displayed in user interfaces which support tracing / debugging (currently only Tkenv) and the string can contain information that tells the user what the module is currently doing. The module creates its own copy of the string. |
|
Returns the current simulation time (that is, the arrival time of the last message returned by a receiveNew() call). |
|
To be called from module functions. Outputs textual information about all objects of the simulation (including the objects created in module functions by the user!) into the snapshot file. The output is detailed enough to be used for debugging the simulation: by regularly calling snapshot(), one can trace how the values of variables, objects changed over the simulation. The arguments: label is a string that will appear in the output file; obj is the object whose inside is of interest. By default, the whole simulation (all modules etc) will be written out. Tkenv also supports making snapshots manually, from menu. See also class cWatch and the WATCH() macro. |
|
Used with parallel execution: synchronize with receiver segment. Blocks receiver at t until a message arrives. |
|
Used with parallel execution: synchronize with receiver segment. Blocks receiver at t until a message arrives. |
|
Returns event handling scheme. |
|
Waits for the given interval. (Some other simulators call this functionality hold()). This function can only be used with activity(), but not with handleMessage(). The messages received meanwhile are inserted into the put-aside queue. |