cMsgPar Class Reference
[Simulation core classes]

cMsgPar objects store a (string, bool, double, etc) value, and can be attached to cMessage objects. More...

#include <cmsgpar.h>

Inheritance diagram for cMsgPar:
cOwnedObject cNamedObject cObject

List of all members.

Public Member Functions

Constructors, destructor, assignment.

 cMsgPar (const cMsgPar &other)
 cMsgPar (const char *name=NULL)
 cMsgPar (const char *name, cMsgPar &other)
virtual ~cMsgPar ()
cMsgParoperator= (const cMsgPar &otherpar)
Redefined cObject member functions

virtual cMsgPardup () const
virtual std::string info () const
virtual std::string detailedInfo () const
virtual void forEachChild (cVisitor *v)
virtual void parsimPack (cCommBuffer *buffer)
virtual void parsimUnpack (cCommBuffer *buffer)
Setter functions. Note that overloaded assignment operators also exist.

cMsgParsetBoolValue (bool b)
cMsgParsetLongValue (long l)
cMsgParsetStringValue (const char *s)
cMsgParsetDoubleValue (double d)
cMsgParsetDoubleValue (cStatistic *res)
cMsgParsetDoubleValue (MathFuncNoArg f)
cMsgParsetDoubleValue (MathFunc1Arg f, double p1)
cMsgParsetDoubleValue (MathFunc2Args f, double p1, double p2)
cMsgParsetDoubleValue (MathFunc3Args f, double p1, double p2, double p3)
cMsgParsetDoubleValue (MathFunc4Args f, double p1, double p2, double p3, double p4)
cMsgParsetPointerValue (void *ptr)
cMsgParsetObjectValue (cOwnedObject *obj)
cMsgParsetXMLValue (cXMLElement *node)
void configPointer (VoidDelFunc delfunc, VoidDupFunc dupfunc, size_t itemsize=0)
void setTakeOwnership (bool tk)
bool getTakeOwnership () const
Getter functions. Note that overloaded conversion operators also exist.

bool boolValue ()
long longValue ()
const char * stringValue ()
double doubleValue ()
void * pointerValue ()
cOwnedObjectgetObjectValue ()
cXMLElementxmlValue ()
Type, change flag.

char getType () const
bool isNumeric () const
bool isConstant () const
bool hasChanged ()
Utility functions.

void convertToConst ()
bool equalsTo (cMsgPar *par)
Convert to/from text representation.

virtual std::string str () const
_OPPDEPRECATED std::string getAsText () const
virtual bool parse (const char *text, char type='?')
_OPPDEPRECATED bool setFromText (const char *text, char type='?')
Overloaded assignment and conversion operators.

cMsgParoperator= (bool b)
cMsgParoperator= (const char *s)
cMsgParoperator= (char c)
cMsgParoperator= (unsigned char c)
cMsgParoperator= (int i)
cMsgParoperator= (unsigned int i)
cMsgParoperator= (short i)
cMsgParoperator= (unsigned short i)
cMsgParoperator= (long l)
cMsgParoperator= (unsigned long l)
cMsgParoperator= (double d)
cMsgParoperator= (long double d)
cMsgParoperator= (void *ptr)
cMsgParoperator= (cOwnedObject *obj)
cMsgParoperator= (cXMLElement *node)
 operator bool ()
 operator const char * ()
 operator char ()
 operator unsigned char ()
 operator int ()
 operator unsigned int ()
 operator short ()
 operator unsigned short ()
 operator long ()
 operator unsigned long ()
 operator double ()
 operator long double ()
 operator void * ()
 operator cOwnedObject * ()
 operator cXMLElement * ()

Protected Member Functions

Event hooks

virtual void beforeChange ()
virtual void afterChange ()

Detailed Description

cMsgPar objects store a (string, bool, double, etc) value, and can be attached to cMessage objects.

Note: Before version 3.0, the cPar class was used for both message parameters and module parameters. As of 4.0, cPar only serves as module/channel parameter, and other uses of cPar in existing 3.x code should be either eliminated (see next note), or changed to cMsgPar.

Note2: This is an obsolete class, retained to support legacy code. The preferred way of adding data to cMessages since the 2.3 version is via subclassing, using .msg files and the opp_msgc tool.

cMsgPar supports several data types. Data types are identified by type characters. The current data type is returned by getType().


Member Function Documentation

virtual void cMsgPar::afterChange (  )  [protected, virtual]

Called each time after the value of this object changed.

It can be used for tracking parameter changes. This default implementation does nothing.

virtual void cMsgPar::beforeChange (  )  [protected, virtual]

Called each time before the value of this object changes.

It can be used for tracking parameter changes. This default implementation does nothing.

bool cMsgPar::boolValue (  ) 

Returns value as a boolean.

The cMsgPar type must be bool (B) or a numeric type.

void cMsgPar::configPointer ( VoidDelFunc  delfunc,
VoidDupFunc  dupfunc,
size_t  itemsize = 0 
)

Configures memory management for the void* pointer ('P') type.

Similar to cLinkedList::configPointer().

delfuncdupfunc.itemsizebehavior
NULLNULL0Pointer is treated as mere pointer - no memory management. Duplication copies the pointer, and deletion does nothing.
NULLNULL!=0Plain memory management. Duplication is done with new char[size]+memcpy(), and deletion is done via delete.
NULL or user's delete func.user's dupfunc.indifferentSophisticated memory management. Duplication is done by calling the user-supplied duplication function, which should do the allocation and the appropriate copying. Deletion is done by calling the user-supplied delete function, or the delete operator if it is not supplied.
void cMsgPar::convertToConst (  ) 

Replaces the object value with its evaluation (a double).

Equivalent to setValue('D', this->doubleValue()).

virtual std::string cMsgPar::detailedInfo (  )  const [virtual]

Produces a multi-line description of the object's contents.

See cObject for more details.

Reimplemented from cObject.

double cMsgPar::doubleValue (  ) 

Returns value as double.

The cMsgPar type must be types long (L), double (D), function (F), Boolean (B), distribution (T).

virtual cMsgPar* cMsgPar::dup (  )  const [inline, virtual]

Creates and returns an exact copy of this object.

See cObject for more details.

Reimplemented from cObject.

bool cMsgPar::equalsTo ( cMsgPar par  ) 

Compares the stored values.

The two objects must have the same type character and the same value to be equal.

virtual void cMsgPar::forEachChild ( cVisitor v  )  [virtual]

Calls v->visit(this) for the contained object, if there is any.

See cObject for more details.

Reimplemented from cObject.

_OPPDEPRECATED std::string cMsgPar::getAsText (  )  const [inline]

DEPRECATED.

Same as str().

cOwnedObject* cMsgPar::getObjectValue (  ) 

Returns value as pointer to cOwnedObject.

The cMsgPar type must be pointer (O).

bool cMsgPar::hasChanged (  ) 

Returns true if the value has changed since the last hasChanged() call.

Side effect: clears the 'changed' flag, so a next call will return false.

virtual std::string cMsgPar::info (  )  const [virtual]

Produces a one-line description of the object's contents.

See cObject for more details.

Reimplemented from cObject.

bool cMsgPar::isConstant (  )  const

Returns true if the value is constant.

It returns true if the type is 'L', 'D', 'B', or 'S', that is, the object stores a long, double, boolean or string constant.

long cMsgPar::longValue (  ) 

Returns value as long.

The cMsgPar type must be types long (L), double (D), Boolean (B), function (F), distribution (T).

cMsgPar& cMsgPar::operator= ( const cMsgPar otherpar  ) 

Assignment operator.

The name member is not copied; see cOwnedObject's operator=() for more details.

The behavior with redirected cMsgPar objects is the following. This function copies the contents of the other object (whether it is redirected or not) into this object, or, if this object is redirected, into the object this object refers to. This means that if you want to overwrite this very object (and not the one it points to), you have to use cancelRedirection() first.

virtual bool cMsgPar::parse ( const char *  text,
char  type = '?' 
) [virtual]

This function tries to interpret the argument text as a type typed value (L=long, S=string, etc).

type=='?' (the default) means that the type is to be auto-selected. On success, cMsgPar is updated with the new value and true is returned, otherwise the function returns false. No error message is generated.

virtual void cMsgPar::parsimPack ( cCommBuffer buffer  )  [virtual]

Serializes the object into an MPI send buffer.

Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cOwnedObject.

virtual void cMsgPar::parsimUnpack ( cCommBuffer buffer  )  [virtual]

Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution.

See cObject for more details.

Reimplemented from cOwnedObject.

void* cMsgPar::pointerValue (  ) 

Returns value as a void * pointer.

The cMsgPar type must be pointer (P).

cMsgPar& cMsgPar::setDoubleValue ( MathFunc4Args  f,
double  p1,
double  p2,
double  p3,
double  p4 
)

Sets the value to the given math function with four arguments.

Every time the cMsgPar's value is asked the function will be called with p1, p2, p3 and p4 as an arguments.

cMsgPar& cMsgPar::setDoubleValue ( MathFunc3Args  f,
double  p1,
double  p2,
double  p3 
)

Sets the value to the given math function with three arguments.

Every time the cMsgPar's value is asked the function will be called with p1, p2 and p3 as an arguments.

cMsgPar& cMsgPar::setDoubleValue ( MathFunc2Args  f,
double  p1,
double  p2 
)

Sets the value to the given math function with two arguments.

Every time the cMsgPar's value is asked the function will be called with p1 and p2 as an arguments.

cMsgPar& cMsgPar::setDoubleValue ( MathFunc1Arg  f,
double  p1 
)

Sets the value to the given math function with one argument.

Every time the cMsgPar's value is asked the function will be called with p1 as an argument.

cMsgPar& cMsgPar::setDoubleValue ( MathFuncNoArg  f  ) 

Sets the value to the given math function with no arguments.

Every time the cMsgPar's value is asked the function will be called.

cMsgPar& cMsgPar::setDoubleValue ( cStatistic res  ) 

Sets the value to the given distribution.

Every time the cMsgPar's value is asked a random number produced by res.random() will be returned.

_OPPDEPRECATED bool cMsgPar::setFromText ( const char *  text,
char  type = '?' 
) [inline]

DEPRECATED.

Same as parse().

cMsgPar& cMsgPar::setObjectValue ( cOwnedObject obj  ) 

Sets the value to the given object.

Whether cMsgPar will take the ownership of the object depends on the getTakeOwnership() flag.

cMsgPar& cMsgPar::setPointerValue ( void *  ptr  ) 

Sets the value to the given pointer.

The ownership of the block pointer to can be controlled using configPointer().

See also:
configPointer
cMsgPar& cMsgPar::setStringValue ( const char *  s  ) 

Sets the value to the given string value.

The cMsgPar will make its own copy of the string. NULL is also accepted and treated as an empty string.

const char* cMsgPar::stringValue (  ) 

Returns value as const char *.

Only for string (S) type.

cXMLElement* cMsgPar::xmlValue (  ) 

Returns value as pointer to cXMLElement.

The cMsgPar type must be XML (M).


The documentation for this class was generated from the following file:
Generated on Tue Dec 2 11:16:29 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3