Menu
Lumberyard
C++ API Reference (Version 1.10)

AZ::SerializeContext::ClassInfo Class Reference

Open 3D Engine (O3DE), the successor to Lumberyard, is now available in Developer Preview. Download O3DE or visit the AWS Game Tech blog to learn more.

Builder class that reflects class members to the serialize context. More...

Public Member Functions

~ClassInfo ()
A destructor. More...
template<class ClassType , class FieldType >
ClassInfo * Field (const char *name, FieldType ClassType::*address)
Reflects a class member to the serialize context. More...
ClassInfo * Version (unsigned int version, VersionConverter converter=nullptr)
Adds versioning to the class and specifies an optional VersionConverter function that converts old versions of the class to the latest version. More...
ClassInfo * EventHandler ( IEventHandler *eventHandler)
Sets an implementation of an event-handling interface that you can use to call special functions before reading or writing a class instance. More...
ClassInfo * PersistentId ( ClassPersistentId persistentId)
Sets the function that returns the persistent ID of a class instance. More...

Friends

class SerializeContext

Detailed Description

Builder class that reflects class members to the serialize context.

To reflect class members to the serialize context, use a builder pattern to call the Field() function of this class. You can reflect any number of class elements (logical elements) and data elements (member data).

For an example of how to reflect class members to the serialize context, see SerializeContext::ClassInfo::Field() in this guide or Reflecting a Component for Serialization and Editing in the Lumberyard User Guide .

Constructor & Destructor Documentation

~ClassInfo()

AZ::SerializeContext::ClassInfo::~ClassInfo ( )
inline

A destructor.

Member Function Documentation

EventHandler()

ClassInfo * AZ::SerializeContext::ClassInfo::EventHandler ( IEventHandler * eventHandler )

Sets an implementation of an event-handling interface that you can use to call special functions before reading or writing a class instance.

Parameters
eventHandler A pointer to an implementation of IEventHandler .
Returns
A pointer to the ClassInfo object that has been updated with the new information.

Field()

template<class ClassType , class FieldType >
ClassInfo * AZ::SerializeContext::ClassInfo::Field ( const char * name ,
FieldType ClassType::* address
)

Reflects a class member to the serialize context.

The following example shows how to use this function to reflect a member variable to the serialize context.

class MyClass
{
public :
int m_data;
static void Reflect( AZ::ReflectContext * context);
};
void MyClass::Reflect( AZ::ReflectContext * context)
{
if (serialize)
{
serialize-> Class <MyClass>()
-> Version (1)
-> Field ( "DataName" , &MyClass::m_data);
}
}
Template Parameters
ClassType The type of class that owns the class member to be reflected.
FieldType The type of class member to be reflected.
Parameters
name The name to use for the reflected class member within the serialize context.
address The address of the class member to reflect.
Returns
A pointer to the ClassInfo object that has been updated with the new information.

PersistentId()

ClassInfo * AZ::SerializeContext::ClassInfo::PersistentId ( ClassPersistentId persistentId )

Sets the function that returns the persistent ID of a class instance.

Persistent IDs enable slices to more easily track instances of classes that are stored in index-based containers like vectors or lists.

Parameters
persistentId A function that returns the persistent ID of the class instance.
Returns
A pointer to the ClassInfo object that has been updated with the new information.

Version()

ClassInfo * AZ::SerializeContext::ClassInfo::Version ( unsigned int version ,
VersionConverter converter = nullptr
)

Adds versioning to the class and specifies an optional VersionConverter function that converts old versions of the class to the latest version.

If you don't add versioning, the serialize context assigns the class version a value of zero.

Versioning works such that when Lumberyard reads the class data from persistent storage, it compares the version in persistent storage with the version in the current serialize context. If the version values do not match, Lumberyard calls the converter, if one was provided from Version() .

If you use Version() to increase the version number but do not provide a converter, Lumberyard assumes that you don't need any class members that don't match the ones in the current serialize context for this class. Mismatching class members are defined as follows:

  • The class member's name doesn't match any names of the current class members.
  • The class member's data does not match the class data reflected.
  • The class member's class data is missing.

For an example of a version converter function, see VersionConverter .

Parameters
version The version number of the class.
converter (Optional) A callback function that converts old versions of a class to the latest version.
Returns
A pointer to the ClassInfo object that has been updated with the new information.

Friends And Related Function Documentation

SerializeContext

friend class SerializeContext
friend

The documentation for this class was generated from the following file: