C++ TargetRTS
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
RTObject_class Struct Reference

A type descriptor providing information about a type. More...

#include <RTObject_class.h>

Inheritance diagram for RTObject_class:
RTArray_class

Public Types

enum  DestroyOption { DestroyOnly , DestroyAndDeallocate }
 

Public Member Functions

const RTObject_classsuper (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_classlookup (const char *className)
 Lookup a type descriptor by the name of the type it describes.
 
template<typename TYPE >
static const RTObject_classfromType ()
 Get a type descriptor from a type TYPE at compile-time.
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 
template<>
const RTObject_classfromType ()
 

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.
 

Detailed Description

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.

Member Function Documentation

◆ allocate()

void * RTObject_class::allocate ( void  ) const

Allocate new memory for holding an instance of the described type.

Returns
Allocated memory big enough to hold an instance of the described type.

◆ copy()

void RTObject_class::copy ( void *  to,
const void *  from 
) const

Make a copy of an instance of the described type.

Parameters
[in]toThe target object into which the data will be copied.
[in]fromThe source object that will be copied.

◆ decode()

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.

Parameters
[in]dataThe target object into which the decoded data will be written.
[in]decoderThe decoder implementation.
Returns
1 if decoding was successful, 0 otherwise.

◆ destroy()

void RTObject_class::destroy ( void *  inst,
DestroyOption  opt 
) const

Destroy an instance of the described type.

Parameters
[in]instAn instance of the described type to destroy.
[in]optSpecifies whether the memory for the data object should be deallocated as part of destruction or not.

◆ encode()

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).

Parameters
[in]dataThe instance of the described type to encode.
[in]encoderThe encoder implementation.
Returns
1 if encoding was successful, 0 otherwise.

◆ fromType()

template<typename TYPE >
const RTObject_class * RTObject_class::fromType
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.

Returns
The type descriptor for the type, or null if the TYPE doesn't have a type descriptor defined.

◆ init()

void RTObject_class::init ( void *  data) const

Initialize an instance of the described type.

Parameters
[in]dataData object for an instance of the described type, typically allocated by a call to allocate().

◆ install()

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.

Parameters
[in]warnForDuplicatesSet to false to avoid printing a warning if trying to register a type descriptor with a name that is already used.

◆ isKindOf()

int RTObject_class::isKindOf ( const RTObject_class other) const

Determines if the described type is the same, or a subtype of, another type.

Parameters
otherType descriptor for the other type to check the described type against.
Returns
1 if yes, 0 if no.

◆ lookup()

static const RTObject_class * RTObject_class::lookup ( const char *  className)
static

Lookup a type descriptor by the name of the type it describes.

Parameters
[in]classNameName of the type.
Returns
The type descriptor for the type, or null if the TYPE doesn't have a type descriptor defined.

◆ move()

void RTObject_class::move ( void *  to,
void *  from 
) const

Move an instance of the described type.

Parameters
[in]toThe target object into which the data will be moved.
[in]fromThe source object that will be moved from.

◆ name()

const char * RTObject_class::name ( void  ) const

Get the name of the described type.

Returns
Type name

◆ super()

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.

Returns
Type descriptor for the super type, or null if there is no super type.

◆ version()

RTVersionId RTObject_class::version ( void  ) const

Get the version of the described type.

Returns
Type version (usually 0 for the first version, and then incremented by one each time the type changes).

Member Data Documentation

◆ _copy_func

RTCopyFunction RTObject_class::_copy_func

The copy function of the type, i.e.

its copy constructor

◆ _destroy_func

RTDestroyFunction RTObject_class::_destroy_func

The destroy function of the type, i.e.

its destructor

◆ _fields

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.

◆ _init_func

RTInitFunction RTObject_class::_init_func

The init function of the type, i.e.

its default constructor

◆ _move_func

RTMoveFunction RTObject_class::_move_func

The move function of the type, i.e.

its move constructor

◆ _num_fields

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.


The documentation for this struct was generated from the following files: