class RTTIType

Provides an interface for accessing fields of a certain class.

Data can be easily accessed by getter and setter methods.

Supported data types:

  • Plain types - All types defined in B3DRTTIField.h, mostly native types and POD (plain old data) structs. Data is parsed byte by byte. No pointers to plain types are supported. Data is passed around by value.
  • Reflectable types - Any class deriving from IReflectable. Data is parsed based on fields in its RTTI class. Can be pointer or value type.
  • Arrays of both plain and reflectable types are supported
  • Data blocks - A managed or unmanaged block of data. See ManagedDataBlock.

Public

Constructors

RTTIType

RTTIType() = default

Methods

~RTTIType

virtual ~RTTIType()

GetDerivedClasses

virtual Vector<RTTIType *> &GetDerivedClasses() const = 0

Returns RTTI type information for all classes that derive from the class that owns this RTTI type.

GetBaseClass

virtual RTTIType *GetBaseClass() const = 0

Returns RTTI type information for the class that owns this RTTI type.

If the class has not base type, null is returned instead.

IsDerivedFrom

virtual bool IsDerivedFrom(const RTTIType *base) const = 0

Returns true if current RTTI class is derived from . (Or if it is the same type as base)

NewRttiObject

virtual SPtr<IReflectable> NewRttiObject() = 0

Creates a new instance of the class owning this RTTI type.

GetRttiName

virtual const String &GetRttiName() = 0

Returns the name of the class owning this RTTI type.

GetRttiId

virtual u32 GetRttiId() const = 0

Returns an RTTI id that uniquely represents each class in the RTTI system.

GetDefaultObject

virtual IReflectable *GetDefaultObject() const = 0

Returns the default constructed object of this type.

Will return null if the class is abstract.

NotifyOperationStarted

virtual void NotifyOperationStarted(IReflectable &object, RTTIOperationTypeFlags operationType, RTTIOperationContext &context) = 0

Called before any operation that is iterating over the type's fields starts.

NotifyOperationEnded

virtual void NotifyOperationEnded(IReflectable &object, RTTIOperationTypeFlags operationType, RTTIOperationContext &context) = 0

Called after any operation that is iterating over the type's fields ends.

GetDeltaHandler

virtual IDeltaHandler &GetDeltaHandler() const

Returns a handler that determines how are deltas generated and applied when it comes to objects of this RTTI type.

A delta is a list of differences between two objects that may be saved, viewed or applied to another object.

GetFieldCount

u32 GetFieldCount() const

Returns the total number of fields in this RTTI type.

GetField

RTTIField *GetField(u32 idx)

Returns a field based on the field index.

Use getNumFields() to get total number of fields available.

FindField

RTTIField *FindField(const String &name)

Tries to find a field with the specified name.

Throws an exception if it can't.

name
The name of the field.

FindField

RTTIField *FindField(int uniqueFieldId)

Tries to find a field with the specified unique ID.

Doesn't throw an exception if it can't find the field (Unlike findField(const String

&

)).

uniqueFieldId
Unique identifier for the field.

Returns: nullptr if it can't find the field.

GetSchema

const SPtr<RTTISchema> &GetSchema() const

Returns a set of serializable meta-data describing the RTTI type.

Internal

Methods

RegisterDerivedClassInternal

virtual void RegisterDerivedClassInternal(RTTIType *derivedClass) = 0

Called by the RTTI system when a class is first found in order to form child/parent class hierarchy.

CloneInternal

virtual RTTIType *CloneInternal(FrameAllocator &alloc) = 0

Constucts a cloned version of the underlying class.

The cloned version will not have any field information and should instead be used for passing to various RTTIField methods during serialization/deserialization. This allows each object instance to have a unique places to store temporary instance-specific data.

InitializeDefaultObject

virtual void InitializeDefaultObject() = 0

Constructs the default object for the type, if it's possible to construct one.

InitSchemaInternal

void InitSchemaInternal()

Initializes the type schema.

Should be called once after construction.

Protected

Methods

AddNewField

void AddNewField(RTTIField *field)

Tries to add a new field to the fields array, and throws an exception if a field with the same name or id already exists.

field
Field, must be non-null.

Fields

mSchema

SPtr<RTTISchema> mSchema

Private

Fields

mFields

Vector<RTTIField *> mFields