Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

cMessage Class Reference

#include <cmessage.h>

Inheritance diagram for cMessage::

cObject cPacket List of all members.

Miscellaneous.

virtual const char* displayString () const
int cmpbydelivtime (cObject *one, cObject *other)
int cmpbypriority (cObject *one, cObject *other)
unsigned long totalMessageCount ()
unsigned long liveMessageCount ()
void resetMessageCounters ()

Public Methods

Constructors, destructor, assignment
 cMessage (const cMessage &msg)
 cMessage (const char *name=NULL, int k=0, long len=1, int pri=0, bool err=false)
virtual ~cMessage ()
cMessage& operator= (const cMessage &msg)
Redefined cObject functions.
virtual const char* className () const
virtual cObjectdup () const
virtual void info (char *buf)
virtual const char* inspectorFactoryName () const
virtual void forEach (ForeachFunc do_fn)
virtual void writeContents (ostream &os)
virtual int netPack ()
virtual int netUnpack ()
Message attributes.
void setKind (int k)
void setPriority (int p)
void setLength (long l)
void addLength (long l)
void setBitError (bool err)
void setTimestamp ()
void setTimestamp (simtime_t t)
void setContextPointer (void *p)
int kind () const
int priority () const
long length () const
bool hasBitError () const
simtime_t timestamp () const
unsigned long insertOrder () const
void* contextPointer () const
Parameter list.
cArrayparList ()
cParaddPar (const char *s)
cParaddPar (cPar *p)
cParaddPar (cPar &p)
cParpar (int n)
cParpar (const char *s)
int findPar (const char *s) const
bool hasPar (const char *s) const
Message encapsulation.
void encapsulate (cMessage *msg)
cMessage* decapsulate ()
cMessage* encapsulatedMsg () const
Sending/arrival information.
bool isSelfMessage () const
bool isScheduled () const
cGatesenderGate () const
cGatearrivalGate () const
int senderModuleId () const
int senderGateId () const
int arrivalModuleId () const
int arrivalGateId () const
simtime_t creationTime () const
simtime_t sendingTime () const
simtime_t arrivalTime () const
bool arrivedOn (int g) const
bool arrivedOn (const char *s, int g=0)

Detailed Description

The message class in OMNeT++. cMessage objects may represent events, messages, packets (frames, cells, etc) or other entities in a simulation. cMessage can be assigned a name (a property inherited from cObject) and it has other attributes, including message kind, length, priority, error flag and time stamp.

After being sent through a channel, cMessage also remembers the sending and delivery times and its source module. cMessage holds a cArray which means that a cMessage can be attached any number of objects. These objects will typically be of cPar type, but other types are also possible.


Constructor & Destructor Documentation

cMessage::cMessage ( const cMessage & msg )
 

Copy constructor.

cMessage::cMessage ( const char * name = NULL,
int k = 0,
long len = 1,
int pri = 0,
bool err = false ) [explicit]
 

Constructor.

cMessage::~cMessage ( ) [virtual]
 

Destructor.


Member Function Documentation

void cMessage::addLength ( long l )
 

Change message length by the given value. The value may be negative, but a negative resulting message length is an error. Useful for modeling encapsulation/decapsulation. (See also encapsulate() and decapsulate().)

cPar & cMessage::addPar ( cPar & p ) [inline]
 

Add a parameter to the message's parameter list. DEPRECATED.

cPar & cMessage::addPar ( cPar * p ) [inline]
 

Add a parameter to the message's parameter list. Convenience function.

cPar & cMessage::addPar ( const char * s ) [inline]
 

Add a parameter to the message's parameter list. Convenience function.

cGate * cMessage::arrivalGate ( ) const
 

Returns pointers to the gate from which the message was sent and on which gate it arrived. A NULL pointer is returned for new (unsent) messages and messages sent via scheduleAt().

int cMessage::arrivalGateId ( ) const [inline]
 

Returns index of gate the message arrived on in the sender module or -1 if the message hasn't sent/scheduled yet.

int cMessage::arrivalModuleId ( ) const [inline]
 

Returns receiver module's index in the module vector or -1 if the message hasn't been sent/scheduled yet.

simtime_t cMessage::arrivalTime ( ) const [inline]
 

Returns time when the message has arrived or 0 if the message hasn't been sent/scheduled yet.

bool cMessage::arrivedOn ( const char * s,
int g = 0 )
 

Return true if the message has arrived through the gate given with its name and index (if multiple gate).

bool cMessage::arrivedOn ( int g ) const [inline]
 

Return true if the message has arrived through gate g.

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

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

Reimplemented from cObject.

Reimplemented in cPacket.

int cMessage::cmpbydelivtime ( cObject * one,
cObject * other ) [static]
 

Static function that compares two messages by their delivery times, then by their priorities. Usable as cQeueue CompareFunc.

int cMessage::cmpbypriority ( cObject * one,
cObject * other ) [static]
 

Static function that compares two messages by their priority. It can be used to sort messages in a priority queue. Usable as cQeueue CompareFunc.

void * cMessage::contextPointer ( ) const [inline]
 

Returns the context pointer.

simtime_t cMessage::creationTime ( ) const [inline]
 

Returns time when the message was created.

cMessage * cMessage::decapsulate ( )
 

Decapsulates a message from the message object. The length of the message will be decreased accordingly, except if it was zero. If the length would become negative, an error occurs.

const char * cMessage::displayString ( ) const [virtual]
 

Override to define a display string for the message. Display string affects message appearance in Tkenv. This default implementation returns "".

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

Creates and returns an exact copy of this object. See cObject for more details.

Reimplemented from cObject.

Reimplemented in cPacket.

void cMessage::encapsulate ( cMessage * msg )
 

Encapsulates msg in the message. msg->length() will be added to the length of the message.

cMessage * cMessage::encapsulatedMsg ( ) const [inline]
 

Returns a pointer to the encapsulated message, or NULL.

int cMessage::findPar ( const char * s ) const
 

Returns the index of the parameter with the given name in the message's parameter list, or -1 if it could not be found. Convenience function.

void cMessage::forEach ( ForeachFunc do_fn ) [virtual]
 

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

Reimplemented from cObject.

bool cMessage::hasBitError ( ) const [inline]
 

Returns true if bit error flag is set, false otherwise.

bool cMessage::hasPar ( const char * s ) const [inline]
 

Check if a parameter exists.

void cMessage::info ( char * buf ) [virtual]
 

Produces a one-line description of object contents into the buffer passed as argument. See cObject for more details.

Reimplemented from cObject.

Reimplemented in cPacket.

unsigned long cMessage::insertOrder ( ) const [inline]
 

FIXME: INTERNAL: Used by cMessageHeap.

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

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

Reimplemented from cObject.

Reimplemented in cPacket.

bool cMessage::isScheduled ( ) const [inline]
 

Return true if message is among future events.

bool cMessage::isSelfMessage ( ) const [inline]
 

Return true if message was posted by scheduleAt().

int cMessage::kind ( ) const [inline]
 

Returns message kind.

long cMessage::length ( ) const [inline]
 

Returns message length.

unsigned long cMessage::liveMessageCount ( ) [inline, static]
 

Returns the total number of messages that currently exist in the simulation. May be useful for detecting memory leaks caused by forgetting to delete messages.

int cMessage::netPack ( ) [virtual]
 

Serializes the object into a PVM or MPI send buffer Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cObject.

Reimplemented in cPacket.

int cMessage::netUnpack ( ) [virtual]
 

Deserializes the object from a PVM or MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cObject.

Reimplemented in cPacket.

cMessage & cMessage::operator= ( const cMessage & msg )
 

Assignment operator. Duplication and the assignment operator work all right with cMessage. The name member doesn't get copied; see cObject's operator=() for more details.

cPar & cMessage::par ( const char * s )
 

Returns the object with the given name in the message's parameter list, converting it to a cPar. Convenience function.

cPar & cMessage::par ( int n )
 

Returns the nth object in the message's parameter list, converting it to a cPar. Convenience function.

cArray & cMessage::parList ( ) [inline]
 

Returns the cArray member of the message which holds the parameters and other attached objects. Parameters can be inserted, retrieved, looked up or deleted through cArray's member functions.

int cMessage::priority ( ) const [inline]
 

Returns message priority.

void cMessage::resetMessageCounters ( ) [inline, static]
 

Reset counters used by totalMessageCount() and liveMessageCount().

cGate * cMessage::senderGate ( ) const
 

Returns pointers to the gate from which the message was sent and on which gate it arrived. A NULL pointer is returned for new (unsent) messages and messages sent via scheduleAt().

int cMessage::senderGateId ( ) const [inline]
 

Returns index of gate sent through in the sender module or -1 if the message hasn't been sent/scheduled yet.

int cMessage::senderModuleId ( ) const [inline]
 

Returns sender module's index in the module vector or -1 if the message hasn't been sent/scheduled yet.

simtime_t cMessage::sendingTime ( ) const [inline]
 

Returns time when the message was sent/scheduled or 0 if the message hasn't been sent yet.

void cMessage::setBitError ( bool err ) [inline]
 

Set bit error flag.

void cMessage::setContextPointer ( void * p ) [inline]
 

Set context pointer.

void cMessage::setKind ( int k ) [inline]
 

Sets message kind. The message kind member is not used by OMNeT++, it can be used freely by the user.

void cMessage::setLength ( long l )
 

Sets message length. When the message is sent through a channel, message length affects transmission delay and the probability of setting the bit error flag.

void cMessage::setPriority ( int p ) [inline]
 

Sets message priority. The priority member is used when the simulator inserts messages in the message queue (FES) to order messages with identical arrival time values.

void cMessage::setTimestamp ( simtime_t t ) [inline]
 

Directly sets the message's time stamp.

void cMessage::setTimestamp ( ) [inline]
 

Sets the message's time stamp to the current simulation time.

simtime_t cMessage::timestamp ( ) const [inline]
 

Returns the message's time stamp.

unsigned long cMessage::totalMessageCount ( ) [inline, static]
 

Returns the total number of messages created so far during the current simulation run. May be useful for debugging, profiling, etc.

void cMessage::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:50 2002 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001