OMNeT++ Simulation Library  6.0.3
cProperty Class Reference

#include <cproperty.h>

Description

Stores a (NED) property with its (possibly compound) value.

The value consists of key-valuelist pairs; the key might be empty (default key).

Inheritance diagram for cProperty:
cNamedObject cObject

Public Member Functions

Constructors, destructor, assignment.
 cProperty (const char *name=nullptr, const char *index=nullptr)
 
 cProperty (const cProperty &other)
 
virtual ~cProperty ()
 
cPropertyoperator= (const cProperty &other)
 
Redefined cObject functions
virtual void setName (const char *name) override
 
virtual const char * getFullName () const override
 
virtual cPropertydup () const override
 
virtual std::string str () const override
 
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
Property getter/setter methods
virtual void setIndex (const char *index)
 
virtual const char * getIndex () const
 
virtual void setIsImplicit (bool b)
 
virtual bool isImplicit () const
 
virtual std::vector< const char * > getKeys () const
 
virtual bool containsKey (const char *key) const
 
virtual void addKey (const char *key)
 
virtual int getNumKeys () const
 
virtual int getNumValues (const char *key) const
 
virtual void setNumValues (const char *key, int size)
 
virtual const char * getValue (const char *key="", int index=0) const
 
virtual const char * getValueOriginFile (const char *key="", int index=0) const
 
virtual const char * getValueOriginType (const char *key="", int index=0) const
 
virtual void setValue (const char *key, int index, const char *value, const char *originFile=nullptr, const char *originType=nullptr)
 
virtual void erase (const char *key)
 
virtual void updateWith (const cProperty *other)
 
- Public Member Functions inherited from cNamedObject
 cNamedObject ()
 
 cNamedObject (const char *name, bool namepooling=true)
 
 cNamedObject (const cNamedObject &obj)
 
virtual ~cNamedObject ()
 
cNamedObjectoperator= (const cNamedObject &o)
 
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 std::string getFullPath () const
 
virtual std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual cObjectgetOwner () const
 
virtual bool isOwnedObject () const
 
virtual bool isSoftOwner () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Additional Inherited Members

- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cProperty() [1/2]

cProperty ( const char *  name = nullptr,
const char *  index = nullptr 
)
explicit

Constructor. The property name should be specified without the "@" mark.

◆ cProperty() [2/2]

cProperty ( const cProperty other)
inline

Copy constructor.

◆ ~cProperty()

virtual ~cProperty ( )
virtual

Destructor.

Member Function Documentation

◆ operator=()

cProperty& operator= ( const cProperty other)

Assignment operator.

◆ setName()

virtual void setName ( const char *  name)
overridevirtual

Redefined.

See also
setIndex()

Reimplemented from cNamedObject.

◆ getFullName()

virtual const char* getFullName ( ) const
overridevirtual

Redefined to return the property name plus optional index.

Reimplemented from cObject.

◆ dup()

virtual cProperty* dup ( ) const
inlineoverridevirtual

Creates and returns an exact copy of this object.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Returns the property's representation approximately in NED syntax. Example: "\@statistic[delay](source=delay;record=mean,max)"

Reimplemented from cObject.

◆ parsimPack()

virtual void parsimPack ( cCommBuffer buffer) const
overridevirtual

Serializes the object into a buffer.

Reimplemented from cNamedObject.

◆ parsimUnpack()

virtual void parsimUnpack ( cCommBuffer buffer)
overridevirtual

Deserializes the object from a buffer.

Reimplemented from cNamedObject.

◆ setIndex()

virtual void setIndex ( const char *  index)
virtual

Sets the index of this property; see NED syntax @propname[index](keys-and-values).

◆ getIndex()

virtual const char* getIndex ( ) const
virtual

Returns the index of this property; see NED syntax @propname[index](keys-and-values). Returns nullptr if the property has no index (@propname(keys-and-values)).

◆ setIsImplicit()

virtual void setIsImplicit ( bool  b)
virtual

Returns the "implicit" flag of this property.

◆ isImplicit()

virtual bool isImplicit ( ) const
virtual

Returns whether this property is implicit. Implicit properties are those not spelled out in the NED file, but rather, added automatically during the parsing process or later.

◆ getKeys()

virtual std::vector<const char *> getKeys ( ) const
virtual

Returns the list of keys if this property. The default key is listed as "".

◆ containsKey()

virtual bool containsKey ( const char *  key) const
virtual

Returns true if the property contains the given key. Specify "" or DEFAULTKEY for the default key.

◆ addKey()

virtual void addKey ( const char *  key)
virtual

Adds the given key to the property. Has no effect if the key already exists.

◆ getNumKeys()

virtual int getNumKeys ( ) const
inlinevirtual

Returns the number of keys in the property.

◆ getNumValues()

virtual int getNumValues ( const char *  key) const
virtual

Returns the number of values for the given key in the property. Specify "" or DEFAULTKEY for the default key.

Returns 0 if the given key does not exist.

◆ setNumValues()

virtual void setNumValues ( const char *  key,
int  size 
)
virtual

Expands or trims the list of values for the given key in the property, by discarding elements or adding "" elements. Specify "" or DEFAULTKEY for the default key. Note that simply setting an element above getNumValues(key) will also expand the list.

Throws an error if the given key does not exist.

◆ getValue()

virtual const char* getValue ( const char *  key = "",
int  index = 0 
) const
virtual

Returns the indexth value for the given key in the property. Specify "" or DEFAULTKEY for the default key. If the key does not exist or the index is out of bounds, nullptr is returned.

◆ getValueOriginFile()

virtual const char* getValueOriginFile ( const char *  key = "",
int  index = 0 
) const
virtual

Returns the name (path) of the file where the indexth value of the given key in the property came from. Specify "" or DEFAULTKEY for the default key. If the key does not exist, the index is out of bounds, or the directory is not known, nullptr is returned.

◆ getValueOriginType()

virtual const char* getValueOriginType ( const char *  key = "",
int  index = 0 
) const
virtual

Returns the fully qualified name of the type where the indexth value of the given key in the property came from. Specify "" or DEFAULTKEY for the default key. If the key does not exist, the index is out of bounds, or the directory is not known, nullptr is returned.

◆ setValue()

virtual void setValue ( const char *  key,
int  index,
const char *  value,
const char *  originFile = nullptr,
const char *  originType = nullptr 
)
virtual

Replaces a value (and its origin type, see getValueOriginType()) for the given key in the property. Specify "" or DEFAULTKEY for the default key. cProperty will create its own copy of the string passed. The index parameter may be greater than getNumValues(key); that will cause the values list to expand, the new elements filled with "".

Throws an error if the given key does not exist, or the index is negative.

◆ erase()

virtual void erase ( const char *  key)
virtual

Erases the given key and all its values.

◆ updateWith()

virtual void updateWith ( const cProperty other)
virtual

Update with the contents of another property. Corresponding elements from the other property will overwrite existing values. If the other property contains values which contain just a single hyphen "-", they are considered antivalues and will erase corresponding values from this property.


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