OMNeT++ Simulation Library
6.0.3
|
#include <cclassdescriptor.h>
Abstract base class for class descriptors.
Subclasses of cClassDescriptor encapsulate reflection information (in the Java sense) which is needed by e.g. Qtenv to display object contents. cClassDescriptor subclasses are normally generated by the message compiler from MSG files.
Public Types | |
enum | { FD_ISARRAY = 0x01, FD_ISCOMPOUND = 0x02, FD_ISPOINTER = 0x04, FD_ISCOBJECT = 0x08, FD_ISCOWNEDOBJECT = 0x10, FD_ISEDITABLE = 0x20, FD_ISREPLACEABLE = 0x40, FD_ISRESIZABLE = 0x80 } |
Field types. More... | |
Public Member Functions | |
Constructors, destructor, assignment. | |
cClassDescriptor (const char *className, const char *baseClassName=nullptr) | |
virtual | ~cClassDescriptor () |
Querying and setting fields of the client object. | |
virtual bool | doesSupport (cObject *obj) const |
virtual cClassDescriptor * | getBaseClassDescriptor () const |
bool | extendsCObject () const |
std::string | getNamespace () const |
int | getInheritanceChainLength () const |
virtual const char ** | getPropertyNames () const =0 |
virtual const char * | getProperty (const char *propertyname) const =0 |
virtual int | getFieldCount () const =0 |
virtual const char * | getFieldName (int field) const =0 |
virtual int | findField (const char *fieldName) const |
virtual unsigned int | getFieldTypeFlags (int field) const =0 |
Utility functions based on getFieldTypeFlags() | |
bool | getFieldIsArray (int field) const |
bool | getFieldIsCompound (int field) const |
bool | getFieldIsPointer (int field) const |
bool | getFieldIsCObject (int field) const |
bool | getFieldIsCOwnedObject (int field) const |
bool | getFieldIsEditable (int field) const |
bool | getFieldIsReplaceable (int field) const |
bool | getFieldIsResizable (int field) const |
virtual const char * | getFieldDeclaredOn (int field) const |
virtual const char * | getFieldTypeString (int field) const =0 |
virtual const char ** | getFieldPropertyNames (int field) const =0 |
virtual const char * | getFieldProperty (int field, const char *propertyname) const =0 |
virtual int | getFieldArraySize (any_ptr object, int field) const =0 |
virtual void | setFieldArraySize (any_ptr object, int field, int size) const =0 |
virtual const char * | getFieldDynamicTypeString (any_ptr object, int field, int i) const |
virtual std::string | getFieldValueAsString (any_ptr object, int field, int i) const =0 |
virtual void | setFieldValueAsString (any_ptr object, int field, int i, const char *value) const =0 |
virtual cValue | getFieldValue (any_ptr object, int field, int i) const =0 |
virtual void | setFieldValue (any_ptr object, int field, int i, const cValue &value) const =0 |
virtual const char * | getFieldStructName (int field) const =0 |
virtual any_ptr | getFieldStructValuePointer (any_ptr object, int field, int i) const =0 |
virtual void | setFieldStructValuePointer (any_ptr object, int field, int i, any_ptr ptr) const =0 |
Public Member Functions inherited from cNoncopyableOwnedObject | |
cNoncopyableOwnedObject (const char *name=nullptr, bool namepooling=true) | |
virtual cNoncopyableOwnedObject * | dup () const override |
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 cObject * | getOwner () 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 () |
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 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 | |
Getting descriptor for an object or a struct. | |
static cClassDescriptor * | getDescriptorFor (const char *classname) |
static cClassDescriptor * | getDescriptorFor (const cObject *object) |
Static Public Member Functions inherited from cOwnedObject | |
static long | getTotalObjectCount () |
static long | getLiveObjectCount () |
static void | resetObjectCounters () |
static cSoftOwner * | getOwningContext () |
Additional Inherited Members | |
Protected Member Functions inherited from cObject | |
virtual void | take (cOwnedObject *obj) |
virtual void | drop (cOwnedObject *obj) |
void | dropAndDelete (cOwnedObject *obj) |
anonymous enum |
Field types.
Enumerator | |
---|---|
FD_ISARRAY | field is an array: int a[]; int a[10]; |
FD_ISCOMPOUND | basic type (T) is struct or class: T a; T *a; T a[10]; T *a[] |
FD_ISPOINTER | field is pointer or pointer array: T *a; T *a[]; T *a[10]; |
FD_ISCOBJECT | if ISCOMPOUND: basic type (T) subclasses from cObject |
FD_ISCOWNEDOBJECT | if ISCOMPOUND: basic type (T) subclasses from cOwnedObject |
FD_ISEDITABLE | whether field supports setFieldValueAsString() |
FD_ISREPLACEABLE | whether field supports setFieldStructValuePointer() |
FD_ISRESIZABLE | whether field supports setFieldArraySize() |
cClassDescriptor | ( | const char * | className, |
const char * | baseClassName = nullptr |
||
) |
Constructor.
|
inlinevirtual |
Destructor.
|
static |
Returns the descriptor object for the given class. The returned descriptor object must not be deleted.
|
static |
Returns the descriptor object for the given object. This can return descriptor for a base class, if there is no exact match. The returned descriptor object must not be deleted.
|
inlinevirtual |
Returns true if this descriptor supports the given object's class. If obj can be cast (dynamic_cast) to the class the descriptor supports, the method should return true.
|
virtual |
Returns the descriptor for the base class, if available.
bool extendsCObject | ( | ) | const |
Returns true if cObject's class descriptor is present on the inheritance chain.
std::string getNamespace | ( | ) | const |
Returns the namespace of this object (getFullName() minus trailing "::" + getName()).
int getInheritanceChainLength | ( | ) | const |
Returns the number of base classes up to the root, as reflected in the descriptors (see getBaseClassDescriptor()).
|
pure virtual |
Returns a NUL-terminated string array with the names of properties on this class. The list includes the properties of the ancestor classes as well.
|
pure virtual |
Returns the value of the given property of the descriptor as a single string. Returns nullptr if there is no such property. For structured property values (with multiple keys and/or list(s) inside), the value is returned as a single unparsed string. If a property appears in a base class and its subclass too, the subclass's property will be returned.
|
pure virtual |
Returns the number of fields in the described class.
|
pure virtual |
Returns the name of a field in the described class. The argument must be in the 0..getFieldCount()-1 range, inclusive.
|
virtual |
Returns the index of the field with the given name, or -1 if not found. cClassDescriptor provides an default implementation, but it is recommended to replace it in subclasses with a more efficient version.
|
pure virtual |
Returns the type flags of a field in the described class. Flags is a binary OR of the following: FD_ISARRAY, FD_ISCOMPOUND, FD_ISPOINTER, FD_ISCOWNEDOBJECT, FD_ISCOBJECT. The argument must be in the 0..getFieldCount()-1 range, inclusive.
|
virtual |
Returns the name of the class on which the given field was declared.
|
pure virtual |
Returns the declared type of a field in the described class as a string. The argument must be in the 0..getFieldCount()-1 range, inclusive.
|
pure virtual |
Returns a nullptr-terminated string array with the names of the given field's properties.
|
pure virtual |
Returns the value of the given property of the given field in the described class as a single string. Returns nullptr if there is no such property. For structured property values (with multiple keys and/or list(s) inside), the value is returned as a single unparsed string.
|
pure virtual |
Returns the array size of a field in the given object. If the field is not an array, it returns 0.
|
pure virtual |
Sets the array size of a field in the given object. If the operation is not successful, an exception is thrown.
The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.
|
inlinevirtual |
Returns the runtime type of the given field as a string if it can be determined. (This method is relevant if the field contains a pointer or or an array of pointers to objects with RTTI.) If a runtime type is not available, nullptr is returned, and the caller should use the declared type instead (getFieldTypeString()).
The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.
|
pure virtual |
Returns the value of the given field in the given object as a string. For compound fields, the message compiler generates code which calls operator<<.
The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.
|
pure virtual |
Sets the value of a field in the given object by parsing the given value string. If the operation is not successful, an exception is thrown.
The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.
Returns the value of the given field in the given object.
The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.
|
pure virtual |
Sets the value of a field in the given object. If the operation is not successful, an exception is thrown.
The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.
|
pure virtual |
Returns the declared type name of a compound field in the described class. The field is a pointer, the "*" is removed. The return value may be used as class name to obtain a class descriptor for this compound field.
Returns the pointer to the value of a compound field in the given object. The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.
|
pure virtual |
Sets a pointer field in the given object. If the operation is not successful, an exception is thrown.
The field argument must be in the 0..getFieldCount()-1 range. The i argument must be in the 0..getFieldArraySize()-1 range, or 0 if the field is not an array.