#include <cstruct.h>
Inheritance diagram for cStructDescriptor:
Subclasses of cStructDescriptor encapsulate the kind of reflection information (in the Java sense) which is needed by Tkenv to display fields in a message, struct or object created with the .msg syntax. The cStructDescriptor subclass is generated along with the message class, (struct, object, etc.).
When Tkenv encounters a message object, it creates an appropriate cStructDescriptor object and uses that to find out what fields the message object has, what are their values etc. The message object is said to be the `client object' of the cStructDescriptor object.
In this class, the copy constructor, dup() and the assignment operator are redefined to raise an error (throw cRuntimeError), since they would be of no use in subclasses.
Public Types | |
enum | { FT_BASIC, FT_SPECIAL, FT_STRUCT, FT_BASIC_ARRAY, FT_SPECIAL_ARRAY, FT_STRUCT_ARRAY, FT_INVALID } |
Public Member Functions | |
Constructors, destructor, assignment. | |
cStructDescriptor (const char *_baseclassname=NULL) | |
cStructDescriptor (const cStructDescriptor &cs) | |
virtual | ~cStructDescriptor () |
cStructDescriptor & | operator= (const cStructDescriptor &) |
Getting and setting client object. | |
void | setStruct (void *_p) |
void * | getStruct () const |
Querying and setting fields of the client object. | |
virtual int | getFieldCount ()=0 |
virtual const char * | getFieldName (int field)=0 |
virtual int | getFieldType (int field)=0 |
virtual const char * | getFieldTypeString (int field)=0 |
virtual const char * | getFieldEnumName (int field)=0 |
virtual int | getArraySize (int field)=0 |
virtual bool | getFieldAsString (int field, int i, char *buf, int bufsize)=0 |
virtual bool | setFieldAsString (int field, int i, const char *value)=0 |
virtual sFieldWrapper * | getFieldWrapper (int field, int i)=0 |
virtual const char * | getFieldStructName (int field)=0 |
virtual void * | getFieldStructPointer (int field, int i)=0 |
Static Public Member Functions | |
Getting descriptor for an object or a struct. | |
static cStructDescriptor * | createDescriptorFor (const char *classname, void *p) |
|
Field types.
|
|
Constructor. The argument is the client object. |
|
Copy constructor.
|
|
Destructor.
|
|
Creates and returns a descriptor object for the struct passed as argument. The class of the descriptor object will be determined from the 1st argument: an instance of the class classname+"Descriptor" will be created. The passed struct will be the client object for the descriptor object. |
|
Must be redefined in subclasses to return the array size of a field in the client object. If the field is not an array, it should return 0. |
|
Must be redefined in subclasses to return the value of a basic field (of type FT_BASIC(_ARRAY)) in the client object as a string. It is an error if this method is invoked for non-basic fields. Returns true if no error occurred, false otherwise. |
|
Must be redefined in subclasses to return the number of fields in the client object.
|
|
Returns the enum name associated with the field. This makes only sense with integer-type fields (short, int, long, etc.). Returns NULL if there's no associated enum.
|
|
Must be redefined in subclasses to return the name of a field in the client object. The argument must be in the 0..getFieldCount()-1 range, inclusive. |
|
Must be redefined in subclasses to return the type name of an FT_STRUCT(_ARRAY) field in the client object. The return value may be used then as classname to create a descriptor object for this structure field. |
|
Must be redefined in subclasses to return the pointer of an FT_STRUCT(_ARRAY) field in the client object. The return value may be used then as client object pointer to create a descriptor object for this structure field. |
|
Must be redefined in subclasses to return the type of a field in the client object. The argument must be in the 0..getFieldCount()-1 range, inclusive. The returned field type is one of the FT_BASIC, FT_SPECIAL, FT_STRUCT, FT_BASIC_ARRAY, FT_SPECIAL_ARRAY, FT_STRUCT_ARRAY constants, or FT_INVALID if there's no such field. |
|
Must be redefined in subclasses to return the type of a field in the client object as a string. The argument must be in the 0..getFieldCount()-1 range, inclusive. |
|
Must be redefined in subclasses to return a wrapper for an FT_SPECIAL(_ARRAY) field in the client object. There's no corresponding setFieldWrapper() method -- setting the field value should can take place via the wrapper object returned here. Returns NULL if no associated wrapper is defined for this field. |
|
Returns client object.
|
|
Assignment is not supported by this class: this method throws a cRuntimeError when called.
|
|
Must be redefined in subclasses to set the value of a basic field (of type FT_BASIC(_ARRAY)) in the client object as a string. It is an error if this method is invoked for non-basic fields. Returns true if no error occurred, false otherwise. |
|
Sets client object.
|