OMNeT++ Simulation Library  6.0.3
cValueMap Class Reference

#include <cvaluemap.h>

Description

Key-value container class based on std::map<std::string,cValue>.

The added value is ownership handling of object values (cObject* pointers) contained in cValue objects. Guidelines: owned objects are those that subclass from cOwnedObject and getOwner() returns this object, and all cObjects that are non-cOwnedObject.

Inheritance diagram for cValueMap:
cValueContainer cOwnedObject cNamedObject cObject

Public Member Functions

Constructors, destructor, assignment.
 cValueMap (const cValueMap &other)
 
 cValueMap (const char *name=nullptr)
 
virtual ~cValueMap ()
 
cValueMapoperator= (const cValueMap &other)
 
Redefined cObject member functions
virtual cValueMapdup () const override
 
virtual std::string str () const override
 
virtual void forEachChild (cVisitor *v) override
 
Container functions.
virtual int size () const
 
virtual void clear ()
 
virtual void set (const char *key, const cValue &value)
 
virtual bool containsKey (const char *key) const
 
virtual const cValueget (const char *key) const
 
const cValueoperator[] (const char *key) const
 
virtual void erase (const char *key)
 
const std::map< std::string, cValue > & getFields () const
 
- Public Member Functions inherited from cValueContainer
 cValueContainer (const char *name=nullptr)
 
- Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 
 cOwnedObject (const char *name, bool namepooling=true)
 
 cOwnedObject (const cOwnedObject &obj)
 
virtual ~cOwnedObject ()
 
cOwnedObjectoperator= (const cOwnedObject &o)
 
virtual cObjectgetOwner () const override
 
virtual bool isOwnedObject () const override
 
- 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 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 cObjectgetThisPtr () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual bool isSoftOwner () const
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Additional Inherited Members

- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cSoftOwnergetOwningContext ()
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cValueMap() [1/2]

cValueMap ( const cValueMap other)
inline

Copy constructor. Contained objects will be duplicated so that the new cValueArray will have its own copy of them.

Note that this behavior is different from most other container classes in the simulation library like cQueue, which only duplicate the objects they own, and leave externally owned objects alone.

◆ cValueMap() [2/2]

cValueMap ( const char *  name = nullptr)
inlineexplicit

Constructor.

◆ ~cValueMap()

virtual ~cValueMap ( )
virtual

Destructor. The contained objects that were owned by the container will be deleted.

Member Function Documentation

◆ operator=()

cValueMap& operator= ( const cValueMap other)

Assignment operator. The name member is not copied; see cNamedObject::operator=() for details. Contained objects that are owned by cValueMap will be duplicated so that the new cValueMap will have its own copy of them.

◆ dup()

virtual cValueMap* dup ( ) const
inlineoverridevirtual

Creates and returns an exact copy of this object. Contained objects will be duplicated so that the new cValueMap will have its own copy of them.

Note that this behavior is different from most other container classes in the simulation library like cQueue, which only duplicate the objects they own, and leave externally owned objects alone.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Produces a one-line description of the object's contents. See cObject for more details.

Reimplemented from cObject.

◆ forEachChild()

virtual void forEachChild ( cVisitor v)
overridevirtual

Calls v->visit(this) for each contained object. See cObject for more details.

Reimplemented from cObject.

◆ size()

virtual int size ( ) const
inlinevirtual

Returns the number of entries in the map.

◆ clear()

virtual void clear ( )
virtual

Makes the container empty.

◆ set()

virtual void set ( const char *  key,
const cValue value 
)
virtual

Adds or overwrites an entry in the map.

◆ containsKey()

virtual bool containsKey ( const char *  key) const
virtual

Returns true if the given key is present in the map.

◆ get()

virtual const cValue& get ( const char *  key) const
virtual

Returns the value with the given key.

◆ operator[]()

const cValue& operator[] ( const char *  key) const
inline

Equivalent to get(const char *) const.

◆ erase()

virtual void erase ( const char *  key)
virtual

Erases the entry with the given key.

◆ getFields()

const std::map<std::string,cValue>& getFields ( ) const
inline

Provides readonly access to the underlying std::map.


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