C++ TargetRTS
|
A type descriptor providing information about a type. More...
#include <RTObject_class.h>
Public Types | |
enum | DestroyOption { DestroyOnly , DestroyAndDeallocate } |
Public Member Functions | |
const RTObject_class * | super (void) const |
Get the descriptor for the super type, i.e. | |
const char * | name (void) const |
Get the name of the described type. | |
RTVersionId | version (void) const |
Get the version of the described type. | |
int | isKindOf (const RTObject_class *other) const |
Determines if the described type is the same, or a subtype of, another type. | |
void * | allocate (void) const |
Allocate new memory for holding an instance of the described type. | |
void | init (void *data) const |
Initialize an instance of the described type. | |
void | copy (void *to, const void *from) const |
Make a copy of an instance of the described type. | |
void | move (void *to, void *from) const |
Move an instance of the described type. | |
int | decode (void *data, RTDecoding *decoder) const |
Decode an external representation (e.g. | |
int | encode (const void *data, RTEncoding *encoder) const |
Encode an instance of the described type into an external representation (e.g. | |
void | destroy (void *inst, DestroyOption opt) const |
Destroy an instance of the described type. | |
void | install (bool warnForDuplicates=true) const |
Register the type descriptor so it can be looked up quickly using the name of the described type as the key. | |
Static Public Member Functions | |
static const RTObject_class * | lookup (const char *className) |
Lookup a type descriptor by the name of the type it describes. | |
template<typename TYPE > | |
static const RTObject_class * | fromType () |
Get a type descriptor from a type TYPE at compile-time. | |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
template<> | |
const RTObject_class * | fromType () |
Public Attributes | |
const RTObject_class * | _super |
The super type from which the type inherits. | |
RTSuperAccessFunction | _super_accessor |
The super object accessor function for this type. | |
const char * | _name |
The name of the type. | |
RTVersionId | _version |
The version id of the type. | |
RTFieldOffset | _size |
The size (in bytes) of the type. | |
RTInitFunction | _init_func |
The init function of the type, i.e. | |
RTCopyFunction | _copy_func |
The copy function of the type, i.e. | |
RTMoveFunction | _move_func |
The move function of the type, i.e. | |
RTDecodeFunction | _decode_func |
The decode function of the type. | |
RTEncodeFunction | _encode_func |
The encode function of the type. | |
RTDestroyFunction | _destroy_func |
The destroy function of the type, i.e. | |
int | _num_fields |
This variable is used for structured and array-like types to specify the number of fields or elements that are contained in the type. | |
const RTFieldDescriptor * | _fields |
This variable is used for structured and array-like types to specify the type of fields or elements that are contained in the type. | |
A type descriptor providing information about a type.
For most defined types a static variable of this struct will be automatically generated. For more complex types, or to have a type descriptor with a non-default behavior, you can write you own custom type descriptor. Capsule types have their own type descriptor struct; see RTActor_class.
void * RTObject_class::allocate | ( | void | ) | const |
Allocate new memory for holding an instance of the described type.
void RTObject_class::copy | ( | void * | to, |
const void * | from | ||
) | const |
Make a copy of an instance of the described type.
[in] | to | The target object into which the data will be copied. |
[in] | from | The source object that will be copied. |
int RTObject_class::decode | ( | void * | data, |
RTDecoding * | decoder | ||
) | const |
Decode an external representation (e.g.
a string representation) and populate an instance of the described type accordingly.
[in] | data | The target object into which the decoded data will be written. |
[in] | decoder | The decoder implementation. |
void RTObject_class::destroy | ( | void * | inst, |
DestroyOption | opt | ||
) | const |
Destroy an instance of the described type.
[in] | inst | An instance of the described type to destroy. |
[in] | opt | Specifies whether the memory for the data object should be deallocated as part of destruction or not. |
int RTObject_class::encode | ( | const void * | data, |
RTEncoding * | encoder | ||
) | const |
Encode an instance of the described type into an external representation (e.g.
a string representation).
[in] | data | The instance of the described type to encode. |
[in] | encoder | The encoder implementation. |
|
static |
Get a type descriptor from a type TYPE at compile-time.
This template function is specialized for all built-in and RT types. If you have manually implemented a type descriptor for a type you must also manually specialize this template if you need to lookup that type descriptor at compile-time.
void RTObject_class::init | ( | void * | data | ) | const |
Initialize an instance of the described type.
[in] | data | Data object for an instance of the described type, typically allocated by a call to allocate(). |
void RTObject_class::install | ( | bool | warnForDuplicates = true | ) | const |
Register the type descriptor so it can be looked up quickly using the name of the described type as the key.
See lookup() for how to perform the lookup. All generated type descriptors will be automatically installed, so normally this function should not be called from user code. See RTTypeInstaller for more information. However, if you have manually written types for which you want to register a type descriptor, you need to call this function to install it in the registry. The name of the installed type is used as the key in the registry. If a type with that name is already registered (the same type or a different one) this function does nothing, but prints a warning.
[in] | warnForDuplicates | Set to false to avoid printing a warning if trying to register a type descriptor with a name that is already used. |
int RTObject_class::isKindOf | ( | const RTObject_class * | other | ) | const |
Determines if the described type is the same, or a subtype of, another type.
other | Type descriptor for the other type to check the described type against. |
|
static |
Lookup a type descriptor by the name of the type it describes.
[in] | className | Name of the type. |
void RTObject_class::move | ( | void * | to, |
void * | from | ||
) | const |
Move an instance of the described type.
[in] | to | The target object into which the data will be moved. |
[in] | from | The source object that will be moved from. |
const char * RTObject_class::name | ( | void | ) | const |
Get the name of the described type.
const RTObject_class * RTObject_class::super | ( | void | ) | const |
Get the descriptor for the super type, i.e.
the type from which the described type inherits.
RTVersionId RTObject_class::version | ( | void | ) | const |
Get the version of the described type.
RTCopyFunction RTObject_class::_copy_func |
The copy function of the type, i.e.
its copy constructor
RTDestroyFunction RTObject_class::_destroy_func |
The destroy function of the type, i.e.
its destructor
const RTFieldDescriptor* RTObject_class::_fields |
This variable is used for structured and array-like types to specify the type of fields or elements that are contained in the type.
For other kinds of types this variable is not relevant. The variable is an array of descriptor objects, each of which describes one field or element of the type.
RTInitFunction RTObject_class::_init_func |
The init function of the type, i.e.
its default constructor
RTMoveFunction RTObject_class::_move_func |
The move function of the type, i.e.
its move constructor
int RTObject_class::_num_fields |
This variable is used for structured and array-like types to specify the number of fields or elements that are contained in the type.
For other kinds of types this variable is not relevant.