OMNeT++ Simulation Library
6.0.3
|
#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, cObjectParImpl, 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 | isMutable () const |
virtual bool | isExpression () const |
virtual bool | isShared () const |
virtual bool | containsValue () const |
virtual bool | isSet () const |
virtual void | setIsVolatile (bool f) |
virtual void | setIsMutable (bool f) |
virtual void | setIsShared (bool f) |
virtual void | setIsSet (bool f) |
virtual const char * | getUnit () const |
virtual void | setUnit (const char *s) |
virtual const char * | getBaseDirectory () const |
virtual void | setBaseDirectory (const char *s) |
Setter functions. Note that overloaded assignment operators also exist. | |
virtual void | setBoolValue (bool b)=0 |
virtual void | setIntValue (intval_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 | setObjectValue (cObject *object)=0 |
virtual void | setXMLValue (cXMLElement *node)=0 |
virtual void | setExpression (cExpression *e)=0 |
Getter functions. | |
virtual bool | boolValue (cComponent *context) const =0 |
virtual intval_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 cObject * | objectValue (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)=default | |
virtual | ~cObject () |
virtual const char * | getClassName () const |
bool | isName (const char *s) const |
virtual const char * | getFullName () const |
virtual std::string | getFullPath () const |
virtual std::string | getClassAndFullName () const |
virtual std::string | getClassAndFullPath () const |
const cObject * | getThisPtr () const |
virtual std::string | str () const |
virtual std::ostream & | printOn (std::ostream &os) const |
virtual cObject * | getOwner () const |
virtual bool | isOwnedObject () const |
virtual bool | isSoftOwner () const |
virtual void | forEachChild (cVisitor *v) |
cObject * | findObject (const char *name, bool deep=true) |
virtual cClassDescriptor * | getDescriptor () const |
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 void | parse (const char *text, FileLine loc)=0 |
virtual int | compare (const cParImpl *other) const |
virtual void | forEachChild (cVisitor *v, cComponent *context) |
virtual void | forEachChild (cVisitor *v) |
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 cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
overridevirtual |
Redefined to throw a "packing not supported" exception.
Reimplemented from cNamedObject.
|
overridevirtual |
Redefined to throw a "packing not supported" exception.
Reimplemented from cNamedObject.
|
pure virtual |
Returns the parameter type.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns true if the stored value is of a numeric type.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
inlinevirtual |
Returns true if this parameter is marked in the NED file as "volatile".
|
inlinevirtual |
Returns true if this parameter is marked in the NED file as mutable.
|
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 isMutable flag.
|
inlinevirtual |
Sets the isShared flag.
|
inlinevirtual |
Sets the isSet flag.
|
inlinevirtual |
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.
|
inlinevirtual |
Initialize the parameter's unit (normally from the @unit property).
|
inlinevirtual |
Returns the base directory for interpreting relative path names in the expression.
|
inlinevirtual |
Sets the base directory for interpreting relative path names in the expression (e.g. in xmldoc()).
|
pure virtual |
Sets the value to the given bool value.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Sets the value to the given integer value.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Sets the value to the given double value.
Implemented in cObjectParImpl, 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 cObjectParImpl, 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 object.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Sets the value to the given cXMLElement.
Implemented in cObjectParImpl, 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 cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as a boolean. The cParImpl type must be BOOL.
Implemented in cObjectParImpl, 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 cObjectParImpl, 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 cObjectParImpl, 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 cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as string. The cParImpl type must be STRING.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as pointer to a cObject. The cParImpl type must be OBJECT.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns value as pointer to cXMLElement. The cParImpl type must be XML.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Returns pointer to the expression stored by the object, or nullptr.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
pure virtual |
Replaces for non-const values, replaces the stored expression with its evaluation.
Implemented in cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
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 cObjectParImpl, 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 cObjectParImpl, cBoolParImpl, cDoubleParImpl, cStringParImpl, cIntParImpl, and cXMLParImpl.
|
inlinevirtual |
Needed for cPar's forEachChild().
Reimplemented in cObjectParImpl, and cXMLParImpl.
|
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.)
virtual void forEachChild |
Enables traversing the object tree, performing some operation on each object. The operation is encapsulated in the particular subclass of cVisitor.
This method should be redefined in every subclass to call v->visit(obj) for every obj object contained.