XII Release 0.1.0
Loading...
Searching...
No Matches
xiiRttiConverterContext Class Reference

This struct is used to store the information about an object that is currently being converted. It is stored in the xiiRttiConverterContext and allows to look up objects by their guid and vice versa. More...

#include <RttiConverter.h>

Inheritance diagram for xiiRttiConverterContext:
[legend]

Public Member Functions

virtual void Clear ()
 Clears all stored information about objects. This is called when the converter context is reused for multiple conversions. Override this to clear any additional data that your implementation may store.
virtual xiiUuid GenerateObjectGuid (const xiiUuid &parentGuid, const xiiAbstractProperty *pProperty, xiiVariant index, void *pObject) const
 Generates a guid for a new object. Default implementation generates stable guids derived from parentGuid + property name + index and ignores the address of pObject.
virtual xiiInternal::NewInstance< void > CreateObject (const xiiUuid &guid, const xiiRTTI *pRtti)
 Creates a new object for the given guid and type. Default implementation uses the allocator from the RTTI type to create a new instance of the object. Override this to implement custom object creation logic, e.g. to reuse existing objects or to create objects that cannot be allocated through RTTI.
virtual void DeleteObject (const xiiUuid &guid)
 Deletes the object with the given guid. Default implementation uses the allocator from the RTTI type to delete the object. Override this to implement custom object deletion logic, e.g. to reuse existing objects or to delete objects that cannot be allocated through RTTI.
virtual void RegisterObject (const xiiUuid &guid, const xiiRTTI *pRtti, void *pObject)
 Registers an object with the given guid, type and pointer. This is called by the default implementation of CreateObject after creating a new object. Override this to store additional information about the object or to implement custom registration logic.
virtual void UnregisterObject (const xiiUuid &guid)
 Unregisters the object with the given guid. This is called by the default implementation of DeleteObject after deleting an object. Override this to clear any additional information about the object or to implement custom unregistration logic.
virtual xiiRttiConverterObject GetObjectByGUID (const xiiUuid &guid) const
 Returns the object for the given guid. Default implementation looks up the guid in a hash table and returns the corresponding object pointer and type. Override this to implement custom lookup logic, e.g. to look up objects that are not currently instantiated, but only exist as graph nodes.
virtual xiiUuid GetObjectGUID (const xiiRTTI *pRtti, const void *pObject) const
 Returns the guid for the given object pointer. Default implementation looks up the object pointer in a hash table and returns the corresponding guid. Override this to implement custom lookup logic, e.g. to look up guids for objects that are not currently instantiated, but only exist as graph nodes.
virtual const xiiRTTI * FindTypeByName (xiiStringView sName) const
 Returns the type for the given type name. Default implementation looks up the type name in a hash table and returns the corresponding RTTI type. Override this to implement custom lookup logic, e.g. to look up types that are not currently registered in the RTTI system.
template<typename T>
void GetObjectsByType (xiiDynamicArray< T * > &out_objects, xiiDynamicArray< xiiUuid > *out_pUuids=nullptr)
 Returns the type for the given type name hash. Default implementation looks up the type name hash in a hash table and returns the corresponding RTTI type. Override this to implement custom lookup logic, e.g. to look up types that are not currently registered in the RTTI system.
virtual xiiUuid EnqueObject (const xiiUuid &guid, const xiiRTTI *pRtti, void *pObject)
 Enqueues an object for later creation. This is called by the default implementation of AddSubObjectToGraph when adding a sub-object that is not currently instantiated, but only exists as a graph node. Default implementation registers the object with the given guid, type and pointer and adds the guid to a set of queued objects. Override this to implement custom enqueue logic, e.g. to store additional information about the object or to implement custom registration logic.
virtual xiiRttiConverterObject DequeueObject ()
 Dequeues an object for creation. This is called by the default implementation of CreateObject when creating an object that was previously enqueued with EnqueueObject. Default implementation looks up the guid in the set of queued objects and returns the corresponding object pointer and type. Override this to implement custom dequeue logic, e.g. to look up objects that are not currently instantiated, but only exist as graph nodes.
virtual void OnUnknownTypeError (xiiStringView sTypeName)
 Called when an object with a guid that is already registered is created. Default implementation logs an error and returns the existing object. Override this to implement custom logic, e.g. to replace the existing object or to allow multiple objects with the same guid.

Protected Attributes

xiiHashTable< xiiUuid, xiiRttiConverterObject > m_GuidToObject
 Maps guids to objects. The object pointer may be nullptr if the object is not currently instantiated, but only exists as a graph node.
xiiHashTable< const void *, xiiUuid > m_ObjectToGuid
 Maps object pointers to guids. The guid may be invalid if the object is not currently instantiated, but only exists as a graph node.
xiiSet< xiiUuid > m_QueuedObjects
 Set of guids for objects that are enqueued for later creation. The objects may not be currently instantiated, but only exist as graph nodes.

Detailed Description

This struct is used to store the information about an object that is currently being converted. It is stored in the xiiRttiConverterContext and allows to look up objects by their guid and vice versa.

Member Function Documentation

◆ Clear()

void xiiRttiConverterContext::Clear ( )
virtual

Clears all stored information about objects. This is called when the converter context is reused for multiple conversions. Override this to clear any additional data that your implementation may store.

Copyright (c) Theophilus Eriata. All Rights Reserved.

Reimplemented in xiiWorldRttiConverterContext.

◆ CreateObject()

xiiInternal::NewInstance< void > xiiRttiConverterContext::CreateObject ( const xiiUuid & guid,
const xiiRTTI * pRtti )
virtual

Creates a new object for the given guid and type. Default implementation uses the allocator from the RTTI type to create a new instance of the object. Override this to implement custom object creation logic, e.g. to reuse existing objects or to create objects that cannot be allocated through RTTI.

Reimplemented in xiiWorldRttiConverterContext.

◆ DeleteObject()

void xiiRttiConverterContext::DeleteObject ( const xiiUuid & guid)
virtual

Deletes the object with the given guid. Default implementation uses the allocator from the RTTI type to delete the object. Override this to implement custom object deletion logic, e.g. to reuse existing objects or to delete objects that cannot be allocated through RTTI.

Reimplemented in xiiWorldRttiConverterContext.

◆ GenerateObjectGuid()

xiiUuid xiiRttiConverterContext::GenerateObjectGuid ( const xiiUuid & parentGuid,
const xiiAbstractProperty * pProperty,
xiiVariant index,
void * pObject ) const
virtual

Generates a guid for a new object. Default implementation generates stable guids derived from parentGuid + property name + index and ignores the address of pObject.

Reimplemented in xiiApplyNativePropertyChangesContext.

◆ GetObjectByGUID()

xiiRttiConverterObject xiiRttiConverterContext::GetObjectByGUID ( const xiiUuid & guid) const
virtual

Returns the object for the given guid. Default implementation looks up the guid in a hash table and returns the corresponding object pointer and type. Override this to implement custom lookup logic, e.g. to look up objects that are not currently instantiated, but only exist as graph nodes.

Reimplemented in xiiWorldRttiConverterContext.

◆ GetObjectGUID()

xiiUuid xiiRttiConverterContext::GetObjectGUID ( const xiiRTTI * pRtti,
const void * pObject ) const
virtual

Returns the guid for the given object pointer. Default implementation looks up the object pointer in a hash table and returns the corresponding guid. Override this to implement custom lookup logic, e.g. to look up guids for objects that are not currently instantiated, but only exist as graph nodes.

Reimplemented in xiiWorldRttiConverterContext.

◆ OnUnknownTypeError()

void xiiRttiConverterContext::OnUnknownTypeError ( xiiStringView sTypeName)
virtual

Called when an object with a guid that is already registered is created. Default implementation logs an error and returns the existing object. Override this to implement custom logic, e.g. to replace the existing object or to allow multiple objects with the same guid.

Reimplemented in xiiWorldRttiConverterContext.

◆ RegisterObject()

void xiiRttiConverterContext::RegisterObject ( const xiiUuid & guid,
const xiiRTTI * pRtti,
void * pObject )
virtual

Registers an object with the given guid, type and pointer. This is called by the default implementation of CreateObject after creating a new object. Override this to store additional information about the object or to implement custom registration logic.

Reimplemented in xiiWorldRttiConverterContext.

◆ UnregisterObject()

void xiiRttiConverterContext::UnregisterObject ( const xiiUuid & guid)
virtual

Unregisters the object with the given guid. This is called by the default implementation of DeleteObject after deleting an object. Override this to clear any additional information about the object or to implement custom unregistration logic.

Reimplemented in xiiWorldRttiConverterContext.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Serialization/RttiConverter.h
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Serialization/Implementation/RttiConverterWriter.cpp