OMNeT++ Simulation Library
5.6.1
|
#include <cparimpl.h>
Internal class that stores values for cPar objects.
cPar delegates almost all methods to cParImpl. Delegation is used to conserve memory by using shared storage for module parameters that have the same values.
cParImpl is an abstract base class, which supports several data types via subclasses: cIntParImpl, cDoubleParImpl, cBoolParImpl, cStringParImpl, cXMLParImpl.
Public Member Functions | |
Constructors, destructor, assignment. | |
cParImpl () | |
cParImpl (const cParImpl &other) | |
virtual | ~cParImpl () |
cParImpl & | operator= (const cParImpl &otherpar) |
Redefined cObject member functions | |
virtual cParImpl * | dup () const override |
virtual void | parsimPack (cCommBuffer *buffer) const override |
virtual void | parsimUnpack (cCommBuffer *buffer) override |
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 | setIntValue (intpar_t 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 intpar_t | intValue (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 cXMLElement * | xmlValue (cComponent *context) const =0 |
virtual cExpression * | getExpression () const =0 |
Public Member Functions inherited from cNamedObject | |
cNamedObject () | |
cNamedObject (const char *name, bool namepooling=true) | |
cNamedObject (const cNamedObject &obj) | |
virtual | ~cNamedObject () |
cNamedObject & | operator= (const cNamedObject &o) |
virtual void | setName (const char *s) |
virtual const char * | getName () const override |
virtual void | setNamePooling (bool b) |
virtual bool | getNamePooling () |
Public Member Functions inherited from cObject | |
cObject () | |
cObject (const cObject &other) | |
virtual | ~cObject () |
virtual const char * | getClassName () const |
bool | isName (const char *s) const |
virtual const char * | getFullName () const |
virtual std::string | getFullPath () const |
const cObject * | getThisPtr () const |
virtual std::string | str () const |
virtual _OPPDEPRECATED std::string | info () const |
virtual _OPPDEPRECATED std::string | detailedInfo () const |
virtual cObject * | getOwner () const |
virtual bool | isOwnedObject () const |
virtual void | forEachChild (cVisitor *v) |
cObject * | findObject (const char *name, bool deep=true) |
void | copyNotSupported () const |
Static Public Member Functions | |
Statistics. | |
static long | getTotalParImplObjectCount () |
static long | getLiveParImplObjectCount () |
static void | resetParImplObjectCounters () |
Miscellaneous utility functions. | |
virtual void | convertToConst (cComponent *context)=0 |
virtual bool | containsConstSubexpressions () const |
virtual void | evaluateConstSubexpressions (cComponent *context) |
virtual void | parse (const char *text)=0 |
virtual int | compare (const cParImpl *other) const |
virtual void | forEachChild (cVisitor *v, cComponent *context) |
static cParImpl * | createWithType (Type type) |
Additional Inherited Members | |
Protected Member Functions inherited from cObject | |
virtual void | take (cOwnedObject *obj) |
virtual void | drop (cOwnedObject *obj) |
void | dropAndDelete (cOwnedObject *obj) |
|
explicit |
Constructor.
|
virtual |
Destructor.
|
overridevirtual |
Redefined change return type to cParImpl.
Reimplemented from cObject.
Reimplemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
overridevirtual |
Serializes the object into a buffer.
Reimplemented from cNamedObject.
Reimplemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
overridevirtual |
Deserializes the object from a buffer.
Reimplemented from cNamedObject.
Reimplemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns the parameter type.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns true if the stored value is of a numeric type.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
inlinevirtual |
Returns true if this parameter is marked in the NED file as "volatile".
|
inlinevirtual |
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.)
|
inlinevirtual |
Used by cPar only: Returns true if this object is shared among multiple cPars.
|
inlinevirtual |
Returns true if the parameter contains a value. Note that isSet() may still return true or false.
|
inlinevirtual |
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).
|
inlinevirtual |
Sets the isVolatile flag. NOTE: It may be necessary to invoke convertToConst(cComponent *context) as well.
|
inlinevirtual |
Sets the isShared flag.
|
inlinevirtual |
Sets the isSet flag.
|
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 |
Initialize the parameter's unit (normally from the @unit property).
|
pure virtual |
Sets the value to the given bool value.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Sets the value to the given integer value.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Sets the value to the given double value.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Sets the value to the given string value. The cParImpl will make its own copy of the string. nullptr is also accepted and treated as an empty string.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
inlinevirtual |
Sets the value to the given string value.
References cParImpl::setStringValue().
Referenced by cParImpl::setStringValue().
|
pure virtual |
Sets the value to the given cXMLElement.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
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, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as a boolean. The cParImpl type must be BOOL.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as an integer. The cParImpl type must be INT. Note: Implicit conversion from DOUBLE is intentionally missing.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as a double. The cParImpl type must be DOUBLE. Note: Implicit conversion from INT is intentionally missing.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as const char *. The cParImpl type must be STRING. 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, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as string. The cParImpl type must be STRING.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as pointer to cXMLElement. The cParImpl type must be XML.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns pointer to the expression stored by the object, or nullptr.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Replaces for non-const values, replaces the stored expression with its evaluation.
Implemented in cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
virtual |
Returns true if this expression contains const subexpressions.
|
virtual |
Evaluates const subexpressions, and replaces them with their values. See cDynamicExpression::Elem::CONSTSUBEXPR.
|
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, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
static |
Factory method: creates a parameter object representing the given type.
|
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, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
inlinevirtual |
|
inlinestatic |
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.
|
inlinestatic |
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.
|
inlinestatic |
Reset counters used by getTotalObjectCount() and getLiveObjectCount(). (Note that getLiveObjectCount() may go negative after a reset call.)