OMNeT++ API 6.1
Discrete Event Simulation Library
cEnum Class Reference

Description

Provides string representation for enums.

The class basically implements efficient integer-to-string and string-to-integer mapping. The primary usage is to support displaying symbolic names for integer enum values.

Inheritance diagram for cEnum:
[legend]

Public Member Functions

Constructors, destructor, assignment.
 cEnum (const char *name=nullptr)
 
 cEnum (const cEnum &cenum)
 
virtual ~cEnum ()
 
cEnumoperator= (const cEnum &list)
 
Redefined cObject member functions.
virtual cEnumdup () const override
 
virtual std::string str () const override
 
Insertion and lookup.
void insert (intval_t value, const char *name)
 
const char * getStringFor (intval_t value)
 
intval_t lookup (const char *name, intval_t fallback=-1)
 
intval_t resolve (const char *name)
 
const std::map< std::string, intval_t > & getNameValueMap () const
 
- 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 void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
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
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Static Public Member Functions

cEnum lookup.
static cEnumfind (const char *enumName, const char *contextNamespace=nullptr)
 
static cEnumget (const char *enumName, const char *contextNamespace=nullptr)
 
- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cSoftOwnergetOwningContext ()
 

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

◆ cEnum() [1/2]

cEnum ( const char *  name = nullptr)
explicit

Constructor.

◆ cEnum() [2/2]

cEnum ( const cEnum cenum)

Copy constructor.

◆ ~cEnum()

virtual ~cEnum ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ operator=()

cEnum& operator= ( const cEnum list)

Assignment operator. The name member is not copied; see cOwnedObject's operator=() for more details.

◆ dup()

virtual cEnum* dup ( ) const
inlineoverridevirtual

Creates and returns an exact copy of this object. See cObject for more details.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Returns a textual representation of this enum.

Reimplemented from cObject.

◆ insert()

void insert ( intval_t  value,
const char *  name 
)

Add an item to the enum. If that numeric code exist, overwrite it.

◆ getStringFor()

const char* getStringFor ( intval_t  value)

Look up value and return string representation. Return nullptr if not found.

◆ lookup()

intval_t lookup ( const char *  name,
intval_t  fallback = -1 
)

Look up string and return numeric code. If not found, return second argument (or -1).

◆ resolve()

intval_t resolve ( const char *  name)

Look up string and return numeric code. Throws an error if not found.

◆ getNameValueMap()

const std::map<std::string,intval_t>& getNameValueMap ( ) const
inline

Returns a map with the enum members (names as key, and numeric value map value).

◆ find()

static cEnum* find ( const char *  enumName,
const char *  contextNamespace = nullptr 
)
static

Returns the cEnum for the given enum name, or nullptr if not found. The enum must have been registered previously with the Register_Enum() macro.

◆ get()

static cEnum* get ( const char *  enumName,
const char *  contextNamespace = nullptr 
)
static

Like find(), but throws an error if the object was not found.


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