#include <SerializeContext.h>
Inherits AZ::ReflectContext.
Classes | |
class | ClassBuilder |
class | DataPatchNameUpgrade |
class | DataPatchTypeUpgrade |
class | DataPatchUpgrade |
class | DataPatchUpgradeHandler |
struct | DbgStackEntry |
class | EnumBuilder |
struct | EqualityCompareHelper |
class | ErrorHandler |
struct | NodeUpgradeSortFunctor |
class | PerModuleGenericClassInfo |
Public Types | |
enum | DataPatchUpgradeType : u8 |
using | ClassData = Serialize::ClassData |
using | EnumerateInstanceCallContext = Serialize::EnumerateInstanceCallContext |
using | ClassElement = Serialize::ClassElement |
using | DataElement = Serialize::DataElement |
using | DataElementNode = Serialize::DataElementNode |
using | IObjectFactory = Serialize::IObjectFactory |
using | IDataSerializer = Serialize::IDataSerializer |
using | IDataContainer = Serialize::IDataContainer |
using | IEventHandler = Serialize::IEventHandler |
using | IDataConverter = Serialize::IDataConverter |
using | VersionConverter = bool(*)(SerializeContext& , DataElementNode& ) |
Callback to process data conversion. | |
using | ClassPersistentId = u64(*)(const void* ) |
Callback for persistent ID for an instance. | |
using | ClassDoSave = bool(*)(const void* ) |
Callback to manipulate entity saving on a yes/no base, otherwise you will need provide serializer for more advanced logic. | |
using | UuidToClassMap = AZStd::unordered_map<Uuid, ClassData> |
Public Member Functions | |
AZ_CLASS_ALLOCATOR (SerializeContext, SystemAllocator) | |
AZ_TYPE_INFO_WITH_NAME_DECL (SerializeContext) | |
AZ_RTTI_NO_TYPE_INFO_DECL () | |
SerializeContext (bool registerIntegralTypes=true, bool createEditContext=false) | |
If registerIntegralTypes is true we will register the default serializer for all integral types. | |
SerializeContext (const SerializeContext &)=delete | |
Deleting copy ctor because we own unique_ptr's of IDataContainers. | |
SerializeContext & | operator= (const SerializeContext &)=delete |
bool | IsTypeReflected (AZ::Uuid typeId) const override |
EditContext * | CreateEditContext () |
Create an edit context for this serialize context. If one already exist it will be returned. | |
void | DestroyEditContext () |
Destroys the internal edit context, all edit related data will be freed. You don't have call DestroyEditContext, it's called when you destroy the serialize context. | |
EditContext * | GetEditContext () const |
Returns the pointer to the current edit context or NULL if one was not created. | |
![]() | |
AZ_TYPE_INFO_WITH_NAME_DECL (ReflectContext) | |
AZ_RTTI_NO_TYPE_INFO_DECL () | |
void | EnableRemoveReflection () |
void | DisableRemoveReflection () |
bool | IsRemovingReflection () const |
bool | IsOnDemandTypeReflected (AZ::Uuid typeId) |
Check if an OnDemandReflection type's typeid is already reflected. | |
void | ExecuteQueuedOnDemandReflections () |
Execute all queued OnDemandReflection calls. | |
Function to enumerate the hierarchy of an instance using the serialization info. | |
enum | EnumerationAccessFlags { ENUM_ACCESS_FOR_READ = 0 , ENUM_ACCESS_FOR_WRITE = 1 << 0 , ENUM_ACCESS_HOLD = 1 << 1 } |
using | BeginElemEnumCB = AZStd::function< bool (void* , const ClassData* , const ClassElement* ) > |
EnumerateInstance() calls this callback for each node in the instance hierarchy. Return true to also enumerate the node's children, otherwise false. | |
using | EndElemEnumCB = AZStd::function< bool () > |
EnumerateInstance() calls this callback when enumeration of an element's sub-branch has completed. Return true to continue enumeration of the element's siblings, otherwise false. | |
typedef AZStd::function< bool(const ClassData *, const Uuid &) > | TypeInfoCB |
TypeInfo enumeration callback. Return true to continue enumeration, otherwise false. | |
using | DataPatchUpgradeList = AZStd::set<DataPatchUpgrade*, NodeUpgradeSortFunctor> |
using | DataPatchUpgradeMap = AZStd::map<unsigned int, DataPatchUpgradeList> |
using | DataPatchFieldUpgrades = AZStd::unordered_map<AZ::Crc32, DataPatchUpgradeMap> |
bool | EnumerateInstanceConst (EnumerateInstanceCallContext *callContext, const void *ptr, const Uuid &classId, const ClassData *classData, const ClassElement *classElement) const |
bool | EnumerateInstance (EnumerateInstanceCallContext *callContext, void *ptr, Uuid classId, const ClassData *classData, const ClassElement *classElement) const |
bool | EnumerateInstanceConst (const void *ptr, const Uuid &classId, const BeginElemEnumCB &beginElemCB, const EndElemEnumCB &endElemCB, unsigned int accessFlags, const ClassData *classData, const ClassElement *classElement, ErrorHandler *errorHandler=nullptr) const |
bool | EnumerateInstance (void *ptr, const Uuid &classId, const BeginElemEnumCB &beginElemCB, const EndElemEnumCB &endElemCB, unsigned int accessFlags, const ClassData *classData, const ClassElement *classElement, ErrorHandler *errorHandler=nullptr) const |
template<class T > | |
bool | EnumerateObject (T *obj, const BeginElemEnumCB &beginElemCB, const EndElemEnumCB &endElemCB, unsigned int accessFlags, ErrorHandler *errorHandler=nullptr) const |
Traverses a give object EnumerateInstance assuming that object is a root element (not classData/classElement information). | |
template<class T > | |
bool | EnumerateObject (const T *obj, const BeginElemEnumCB &beginElemCB, const EndElemEnumCB &endElemCB, unsigned int accessFlags, ErrorHandler *errorHandler=nullptr) const |
void | EnumerateDerived (const TypeInfoCB &callback, const Uuid &classId=Uuid::CreateNull(), const Uuid &typeId=Uuid::CreateNull()) const |
Enumerate all derived classes of classId type in addition we use the typeId to check any rtti possible match. | |
void | EnumerateBase (const TypeInfoCB &callback, const Uuid &classId) |
Enumerate all base classes of classId type. | |
template<class T > | |
void | EnumerateDerived (const TypeInfoCB &callback) |
template<class T > | |
void | EnumerateBase (const TypeInfoCB &callback) |
void | EnumerateAll (const TypeInfoCB &callback, bool includeGenerics=false) const |
template<class T > | |
T * | CloneObject (const T *obj) |
Makes a copy of obj. The behavior is the same as if obj was first serialized out and the copy was then created from the serialized data. | |
void * | CloneObject (const void *ptr, const Uuid &classId) |
template<class T > | |
void | CloneObjectInplace (T &dest, const T *obj) |
void | CloneObjectInplace (void *dest, const void *ptr, const Uuid &classId) |
const ClassData * | FindClassData (const Uuid &classId, const SerializeContext::ClassData *parent=nullptr, u32 elementNameCrc=0) const |
Find a class data (stored information) based on a class ID and possible parent class data. | |
AZStd::vector< AZ::Uuid > | FindClassId (const AZ::Crc32 &classNameCrc) const |
Find a class data (stored information) based on a class name. | |
GenericClassInfo * | FindGenericClassInfo (const Uuid &classId) const |
Find GenericClassData data based on the supplied class ID. | |
AZStd::any | CreateAny (const Uuid &classId) |
Creates an AZStd::any based on the provided class Uuid, or returns an empty AZStd::any if no class data is found or the class is virtual. | |
void | RegisterGenericClassInfo (const AZ::Uuid &typeId, GenericClassInfo *genericClassInfo, const CreateAnyFunc &createAnyFunc) |
Register GenericClassInfo with the SerializeContext. | |
void | CleanupModuleGenericClassInfo () |
Unregisters all GenericClassInfo instances registered in the current module and deletes the GenericClassInfo instances. | |
bool | CanDowncast (const Uuid &fromClassId, const Uuid &toClassId, const IRttiHelper *fromClassHelper=nullptr, const IRttiHelper *toClassHelper=nullptr) const |
void * | DownCast (void *instance, const Uuid &fromClassId, const Uuid &toClassId, const IRttiHelper *fromClassHelper=nullptr, const IRttiHelper *toClassHelper=nullptr) const |
template<class T > | |
T | Cast (void *instance, const Uuid &instanceClassId) const |
void | RegisterDataContainer (AZStd::unique_ptr< IDataContainer > dataContainer) |
AZ::TypeId | GetUnderlyingTypeId (const TypeId &enumTypeId) const |
PerModuleGenericClassInfo & | GetCurrentSerializeContextModule () |
Code to bind classes and variables for serialization. | |
For details about what can you expose in a class and what options you have SerializeContext::ClassBuilder | |
using | CreateAnyFunc = AZStd::any(*)(SerializeContext*) |
Function Pointer which is used to construct an AZStd::any for a registered type using the Serialize Context. | |
using | CreateAnyActionHandler = AZStd::function<AZStd::any::action_handler_for_t(SerializeContext* serializeContext)> |
template<class T , class... TBaseClasses> | |
ClassBuilder | Class () |
template<class T , class... TBaseClasses> | |
ClassBuilder | Class (IObjectFactory *factory) |
template<typename EnumType > | |
EnumBuilder | Enum () |
template<typename EnumType > | |
EnumBuilder | Enum (IObjectFactory *factory) |
ClassBuilder | RegisterType (const AZ::TypeId &typeId, AZ::SerializeContext::ClassData &&classData, CreateAnyFunc createAnyFunc=[](SerializeContext *) -> AZStd::any { return {};}) |
bool | UnregisterType (const AZ::TypeId &typeId) |
template<class ValueType > | |
void | RegisterGenericType () |
void | ClassDeprecate (const char *name, const AZ::Uuid &typeUuid, VersionConverter converter=nullptr) |
Additional Inherited Members | |
![]() | |
bool | m_isRemoveReflection |
True if all calls in the context should be considered to remove not to add reflection. | |
AZStd::unordered_map< AZ::Uuid, AZStd::weak_ptr< Internal::ReflectionFunctionRef > > | m_onDemandReflection |
Store the on demand reflect functions so we can avoid double-reflecting something. | |
AZStd::vector< AZStd::pair< AZ::Uuid, StaticReflectionFunctionPtr > > | m_toProcessOnDemandReflection |
OnDemandReflection functions that need to be called. | |
AZStd::deque< AZ::Uuid > | m_currentlyProcessingTypeIds |
The type ids of the currently reflecting type. Used to prevent circular references. Is a set to prevent recursive circular references. | |
friend | OnDemandReflectionOwner |
Serialize context is a class that manages information about all reflected data structures. You will use it for all related information when you declare you data for serialization. In addition it will handle data version control.
using AZ::SerializeContext::ClassPersistentId = u64(*)(const void* ) |
Callback for persistent ID for an instance.
using AZ::SerializeContext::CreateAnyActionHandler = AZStd::function<AZStd::any::action_handler_for_t(SerializeContext* serializeContext)> |
Function object which is used to create an instance of an ActionHandler function which can be supplied to the AZStd::any::type_info handler object to allow type erased operations such as construct/destruct, copy/move
bool AZ::SerializeContext::CanDowncast | ( | const Uuid & | fromClassId, |
const Uuid & | toClassId, | ||
const IRttiHelper * | fromClassHelper = nullptr, | ||
const IRttiHelper * | toClassHelper = nullptr ) const |
Checks if a type can be downcast to another using Uuid and AZ_RTTI. All classes must be registered with the system.
T AZ::SerializeContext::Cast | ( | void * | instance, |
const Uuid & | instanceClassId ) const |
Casts a pointer using the instance pointer and its class id. In order for the cast to succeed, both types must either support azrtti or be reflected with the serialization context.
SerializeContext::ClassBuilder AZ::SerializeContext::Class | ( | IObjectFactory * | factory | ) |
When a default object factory can't be used, example a singleton class with private constructors or non default constructors you will have to provide a custom factory.
void * AZ::SerializeContext::DownCast | ( | void * | instance, |
const Uuid & | fromClassId, | ||
const Uuid & | toClassId, | ||
const IRttiHelper * | fromClassHelper = nullptr, | ||
const IRttiHelper * | toClassHelper = nullptr ) const |
Offsets a pointer from a derived class to a common base class All classes must be registered with the system otherwise a NULL will be returned.
SerializeContext::EnumBuilder AZ::SerializeContext::Enum | ( | ) |
Exposes a C++ enum type to the SerializeContext The SerializeContext::ClassBuilder has the list of supported options for exposing Enum Type data The primary function on the EnumBuilder class for adding an Enum value is EnumBuilder::Value()
bool AZ::SerializeContext::EnumerateInstanceConst | ( | EnumerateInstanceCallContext * | callContext, |
const void * | ptr, | ||
const Uuid & | classId, | ||
const ClassData * | classData, | ||
const ClassElement * | classElement ) const |
Call this function to traverse an instance's hierarchy by providing address and classId, if you have the typed pointer you can just call EnumerateObject
ptr | pointer to the object for traversal |
classId | classId of object for traversal |
beginElemCB | callback when we begin/open a child element |
endElemCB | callback when we end/close a child element |
accessFlags | EnumerationAccessFlags |
classData | pointer to the class data for the traversed object to avoid calling FindClassData(classId) (can be null) |
classElement | pointer to class element (null for root elements) |
errorHandler | optional pointer to the error handler. |
|
overridevirtual |
Reimplemented from AZ::ReflectContext.
ClassBuilder AZ::SerializeContext::RegisterType | ( | const AZ::TypeId & | typeId, |
AZ::SerializeContext::ClassData && | classData, | ||
CreateAnyFunc | createAnyFunc = [](SerializeContext *) -> AZStd::any { return {};} ) |
Allows registration of a TypeId without the need to supply a C++ type If the type is not already registered, then the ClassData is moved into the SerializeContext internal structure
bool AZ::SerializeContext::UnregisterType | ( | const AZ::TypeId & | typeId | ) |
Unregister a type from the SerializeContext and removes all internal mappings