| 
    OMNeT++ Simulation Library
    5.4.1
    
   | 
 
#include <cenum.h>
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.
  
 Public Member Functions | |
Constructors, destructor, assignment.  | |
| cEnum (const char *name=nullptr) | |
| cEnum (const char *name, const char *str,...) | |
| cEnum (const cEnum &cenum) | |
| virtual | ~cEnum () | 
| cEnum & | operator= (const cEnum &list) | 
Redefined cObject member functions.  | |
| virtual cEnum * | dup () const override | 
| virtual std::string | str () const override | 
Insertion and lookup.  | |
| void | insert (int value, const char *name) | 
| void | bulkInsert (const char *name1,...) | 
| const char * | getStringFor (int value) | 
| int | lookup (const char *name, int fallback=-1) | 
| int | resolve (const char *name) | 
| std::map< std::string, int > | getNameValueMap () const | 
  Public Member Functions inherited from cOwnedObject | |
| cOwnedObject () | |
| cOwnedObject (const char *name, bool namepooling=true) | |
| cOwnedObject (const cOwnedObject &obj) | |
| virtual | ~cOwnedObject () | 
| cOwnedObject & | operator= (const cOwnedObject &o) | 
| virtual void | parsimPack (cCommBuffer *buffer) const override | 
| virtual void | parsimUnpack (cCommBuffer *buffer) override | 
| virtual cObject * | getOwner () const override | 
| virtual bool | isOwnedObject () const override | 
| virtual bool | isSoftOwner () const | 
  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 _OPPDEPRECATED std::string | info () const | 
| virtual _OPPDEPRECATED std::string | detailedInfo () const | 
| virtual void | forEachChild (cVisitor *v) | 
| cObject * | findObject (const char *name, bool deep=true) | 
| void | copyNotSupported () const | 
Static Public Member Functions | |
cEnum lookup.  | |
| static cEnum * | find (const char *enumName, const char *contextNamespace=nullptr) | 
| static cEnum * | get (const char *enumName, const char *contextNamespace=nullptr) | 
  Static Public Member Functions inherited from cOwnedObject | |
| static long | getTotalObjectCount () | 
| static long | getLiveObjectCount () | 
| static void | resetObjectCounters () | 
| static cDefaultList * | getDefaultOwner () | 
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.
| cEnum | ( | const char * | name, | 
| const char * | str, | ||
| ... | |||
| ) | 
Constructor that allows adding several values to the enum, in a way similar to bulkInsert(). The argument list begins with the object name, which should be followed by an alternating list of names and values, terminated by a nullptr: name1, value1, name2, value2, ..., nullptr.
Example:
enum State { IDLE=0, BUSY };
cEnum stateEnum("state", "IDLE", IDLE, "BUSY", BUSY, nullptr);
 
      
  | 
  virtual | 
Destructor.
Assignment operator. The name member is not copied; see cOwnedObject's operator=() for more details.
      
  | 
  inlineoverridevirtual | 
      
  | 
  overridevirtual | 
Returns a textual representation of this enum.
Reimplemented from cObject.
| void insert | ( | int | value, | 
| const char * | name | ||
| ) | 
Add an item to the enum. If that numeric code exist, overwrite it.
| void bulkInsert | ( | const char * | name1, | 
| ... | |||
| ) | 
Adds several values to the enum. The argument list should be an alternating list of names and values, terminated by a nullptr: name1, value1, name2, value2, ..., nullptr.
Example:
cEnum stateEnum("state"); stateEnum.bulkInsert("IDLE", IDLE, "BUSY", BUSY, nullptr);
| const char* getStringFor | ( | int | value | ) | 
Look up value and return string representation. Return nullptr if not found.
| int lookup | ( | const char * | name, | 
| int | fallback = -1  | 
        ||
| ) | 
Look up string and return numeric code. If not found, return second argument (or -1).
| int resolve | ( | const char * | name | ) | 
Look up string and return numeric code. Throws an error if not found.
      
  | 
  inline | 
Returns a map with the enum members (names as key, and numeric value map value).
      
  | 
  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.
      
  | 
  static | 
Like find(), but throws an error if the object was not found.