cParImpl Class Reference
[Internal classes]

#include <cparimpl.h>

Inheritance diagram for cParImpl:

cNamedObject cObject cBoolParImpl cDoubleParImpl cLongParImpl cStringParImpl cXMLParImpl

List of all members.


Detailed Description

Internal class that stores parameter values.

cPar delegates almost all methods to cParImpl. Delegation was introduced to save memory by using shared storage for module parameters of the same values.

cParImpl is an abstract base class, which supports several data types via subclasses: cLongParImpl, cDoubleParImpl, cBoolParImpl, cStringParImpl, cXMLParImpl.

Miscellaneous utility functions.

virtual void convertToConst (cComponent *context)=0
virtual bool containsConstSubexpressions () const
virtual void evaluateConstSubexpressions (cComponent *context)
virtual std::string str () const =0
virtual void parse (const char *text)=0
static cParImplcreateWithType (Type type)

Public Member Functions

Constructors, destructor, assignment.
 cParImpl ()
 cParImpl (const cParImpl &other)
virtual ~cParImpl ()
cParImploperator= (const cParImpl &otherpar)
Redefined cObject member functions
virtual std::string info () const
virtual std::string detailedInfo () const
virtual cParImpldup () const
virtual void parsimPack (cCommBuffer *buffer)
virtual void parsimUnpack (cCommBuffer *buffer)
Owner component, type, flags.
virtual Type getType () const =0
virtual bool isNumeric () const =0
virtual bool isVolatile () const
virtual bool isExpression () const
virtual bool isShared () const
virtual bool containsValue () const
virtual bool isSet () const
virtual void setIsVolatile (bool f)
virtual void setIsShared (bool f)
virtual void setIsSet (bool f)
virtual const char * getUnit () const
virtual void setUnit (const char *s)
Setter functions. Note that overloaded assignment operators also exist.
virtual void setBoolValue (bool b)=0
virtual void setLongValue (long l)=0
virtual void setDoubleValue (double d)=0
virtual void setStringValue (const char *s)=0
virtual void setStringValue (const std::string &s)
virtual void setXMLValue (cXMLElement *node)=0
virtual void setExpression (cExpression *e)=0
Getter functions.
virtual bool boolValue (cComponent *context) const =0
virtual long longValue (cComponent *context) const =0
virtual double doubleValue (cComponent *context) const =0
virtual const char * stringValue (cComponent *context) const =0
virtual std::string stdstringValue (cComponent *context) const =0
virtual cXMLElementxmlValue (cComponent *context) const =0
virtual cExpressiongetExpression () const =0
Compare functions
virtual int compare (const cParImpl *other) const

Static Public Member Functions

Statistics.
static long getTotalParImplObjectCount ()
static long getLiveParImplObjectCount ()
static void resetParImplObjectCounters ()


Constructor & Destructor Documentation

cParImpl::cParImpl (  )  [explicit]

Constructor.

cParImpl::cParImpl ( const cParImpl other  )  [inline]

Copy constructor.

virtual cParImpl::~cParImpl (  )  [virtual]

Destructor.


Member Function Documentation

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

Assignment operator.

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

Returns a one-line description of the object.

See also:
detailedInfo()

Reimplemented from cObject.

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

Returns a long description of the object.

Reimplemented from cObject.

Reimplemented in cXMLParImpl.

virtual cParImpl* cParImpl::dup (  )  const [virtual]

Redefined change return type to cParImpl.

Reimplemented from cObject.

Reimplemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

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

Serializes the object into a buffer.

Reimplemented from cNamedObject.

Reimplemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

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

Deserializes the object from a buffer.

Reimplemented from cNamedObject.

Reimplemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual Type cParImpl::getType (  )  const [pure virtual]

Returns the parameter type.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual bool cParImpl::isNumeric (  )  const [pure virtual]

Returns true if the stored value is of a numeric type.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual bool cParImpl::isVolatile (  )  const [inline, virtual]

Returns true if this parameter is marked in the NED file as "volatile".

virtual bool cParImpl::isExpression (  )  const [inline, virtual]

Returns false if the stored value is a constant, and true if it is an expression.

(It is not examined whether the expression yields a constant value.)

virtual bool cParImpl::isShared (  )  const [inline, virtual]

Used by cPar only: Returns true if this object is shared among multiple cPars.

virtual bool cParImpl::containsValue (  )  const [inline, virtual]

Returns true if the parameter contains a value.

Note that isSet() may still return true or false.

virtual bool cParImpl::isSet (  )  const [inline, virtual]

Used by cPar only: Returns true if the parameter value is set, false otherwise (i.e.

if the object contains no value or the current value is just a default).

virtual void cParImpl::setIsVolatile ( bool  f  )  [inline, virtual]

Sets the isVolatile flag.

NOTE: It may be necessary to invoke convertToConst(cComponent *context) as well.

virtual void cParImpl::setIsShared ( bool  f  )  [inline, virtual]

Sets the isShared flag.

virtual void cParImpl::setIsSet ( bool  f  )  [inline, virtual]

Sets the isSet flag.

virtual const char* cParImpl::getUnit (  )  const [virtual]

Returns the parameter's unit ("s", "mW", "Hz", "bps", etc), as declared in the @unit property of the parameter in NED.

Unit is only meaningful with numeric parameters.

virtual void cParImpl::setUnit ( const char *  s  )  [virtual]

Initialize the parameter's unit (normally from the @unit property).

virtual void cParImpl::setBoolValue ( bool  b  )  [pure virtual]

Sets the value to the given bool value.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual void cParImpl::setLongValue ( long  l  )  [pure virtual]

Sets the value to the given long value.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual void cParImpl::setDoubleValue ( double  d  )  [pure virtual]

Sets the value to the given double value.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual void cParImpl::setStringValue ( const char *  s  )  [pure virtual]

Sets the value to the given string value.

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

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual void cParImpl::setStringValue ( const std::string &  s  )  [inline, virtual]

Sets the value to the given string value.

virtual void cParImpl::setXMLValue ( cXMLElement node  )  [pure virtual]

Sets the value to the given cXMLElement.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual void cParImpl::setExpression ( cExpression e  )  [pure virtual]

Sets the value to the given expression.

This object will assume the responsibility to delete the expression object.

Note: if the parameter is marked as non-volatile (isVolatile()==false), one should not set an expression as value. This is not enforced by cParImpl though.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual bool cParImpl::boolValue ( cComponent context  )  const [pure virtual]

Returns value as a boolean.

The cParImpl type must be BOOL.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual long cParImpl::longValue ( cComponent context  )  const [pure virtual]

Returns value as long.

The cParImpl type must be LONG or DOUBLE.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual double cParImpl::doubleValue ( cComponent context  )  const [pure virtual]

Returns value as long.

The cParImpl type must be LONG or DOUBLE.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual const char* cParImpl::stringValue ( cComponent context  )  const [pure virtual]

Returns value as const char *.

Only for STRING type. This method may only be invoked when the parameter's value is a string constant and not the result of expression evaluation, otherwise an error is thrown. This practically means this method cannot be used on parameters declared as "volatile string" in NED; they can only be accessed using stdstringValue().

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual std::string cParImpl::stdstringValue ( cComponent context  )  const [pure virtual]

Returns value as string.

Only for string (S) type.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual cXMLElement* cParImpl::xmlValue ( cComponent context  )  const [pure virtual]

Returns value as pointer to cXMLElement.

The cParImpl type must be XML.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual cExpression* cParImpl::getExpression (  )  const [pure virtual]

Returns pointer to the expression stored by the object, or NULL.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual void cParImpl::convertToConst ( cComponent context  )  [pure virtual]

Replaces for non-const values, replaces the stored expression with its evaluation.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual bool cParImpl::containsConstSubexpressions (  )  const [virtual]

Returns true if this expression contains const subexpressions.

virtual void cParImpl::evaluateConstSubexpressions ( cComponent context  )  [virtual]

Evaluates const subexpressions, and replaces them with their values.

See cDynamicExpression::Elem::CONSTSUBEXPR.

virtual std::string cParImpl::str (  )  const [pure virtual]

Returns the value in text form.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

virtual void cParImpl::parse ( const char *  text  )  [pure virtual]

Convert the value from string, and store the result.

If the text cannot be parsed, an exception is thrown, which can be caught as std::runtime_error& if necessary.

Implemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

static cParImpl* cParImpl::createWithType ( Type  type  )  [static]

Factory method: creates a parameter object representing the given type.

virtual int cParImpl::compare ( const cParImpl other  )  const [virtual]

Compares two cParImpls, including name, type, flags, stored value or expression.

Makes it possible to use cParImpl as a key in std::map or std::set.

Reimplemented in cBoolParImpl, cDoubleParImpl, cLongParImpl, cStringParImpl, and cXMLParImpl.

static long cParImpl::getTotalParImplObjectCount (  )  [inline, static]

Returns the total number of objects created since the start of the program (or since the last reset).

The counter is incremented by cOwnedObject constructor. Counter is signed to make it easier to detect if it overflows during very long simulation runs. May be useful for profiling or debugging memory leaks.

static long cParImpl::getLiveParImplObjectCount (  )  [inline, static]

Returns the number of objects that currently exist in the program.

The counter is incremented by cOwnedObject constructor and decremented by the destructor. May be useful for profiling or debugging memory leaks.

static void cParImpl::resetParImplObjectCounters (  )  [inline, static]

Reset counters used by getTotalObjectCount() and getLiveObjectCount().

(Note that getLiveObjectCount() may go negative after a reset call.)


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

Generated on Wed Apr 3 14:40:28 2013 for OMNeT++ Simulation Library by  doxygen 1.5.5