24 #define JPH_DECLARE_PRIMITIVE(name) T_##name,
45 SerializableAttribute(
const char *inName,
uint inMemberOffset,
pGetMemberPrimitiveType inGetMemberPrimitiveType,
pIsType inIsType,
pReadData inReadData,
pWriteData inWriteData,
pWriteDataType inWriteDataType) : mName(inName), mMemberOffset(inMemberOffset), mGetMemberPrimitiveType(inGetMemberPrimitiveType), mIsType(inIsType), mReadData(inReadData), mWriteData(inWriteData), mWriteDataType(inWriteDataType) { }
48 SerializableAttribute(
const SerializableAttribute &inOther,
int inBaseOffset) : mName(inOther.mName), mMemberOffset(inOther.mMemberOffset + inBaseOffset), mGetMemberPrimitiveType(inOther.mGetMemberPrimitiveType), mIsType(inOther.mIsType), mReadData(inOther.mReadData), mWriteData(inOther.mWriteData), mWriteDataType(inOther.mWriteDataType) { }
51 void SetName(
const char *inName) { mName = inName; }
52 const char *
GetName()
const {
return mName; }
56 inline T *
GetMemberPointer(
void *inObject)
const {
return reinterpret_cast<T *
>(
reinterpret_cast<uint8 *
>(inObject) + mMemberOffset); }
58 inline const T *
GetMemberPointer(
const void *inObject)
const {
return reinterpret_cast<const T *
>(
reinterpret_cast<const uint8 *
>(inObject) + mMemberOffset); }
63 return mGetMemberPrimitiveType();
69 return mIsType(inArrayDepth, inDataType, inClassName);
75 return mReadData(ioStream, GetMemberPointer<void>(inObject));
81 mWriteData(ioStream, GetMemberPointer<void>(inObject));
87 mWriteDataType(ioStream);
std::uint8_t uint8
Definition: Core.h:440
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
EOSDataType
Data type.
Definition: SerializableAttribute.h:15
@ Array
Used in attribute declaration, indicates that this is an array of objects.
@ Object
Start of a new object.
@ Invalid
Next token on the stream was not a valid data type.
@ Pointer
Used in attribute declaration, indicates that an object is a pointer attribute.
@ Instance
Used in attribute declaration, indicates that an object is an instanced attribute (no pointer)
Interface class for reading from an object stream.
Definition: ObjectStream.h:40
Interface class for writing to an object stream.
Definition: ObjectStream.h:74
Attributes are members of classes that need to be serialized.
Definition: SerializableAttribute.h:35
void(*)(IObjectStreamOut &ioStream) pWriteDataType
Definition: SerializableAttribute.h:42
void WriteData(IObjectStreamOut &ioStream, const void *inObject) const
Write the data for this attribute from attribute containing class inObject.
Definition: SerializableAttribute.h:79
void WriteDataType(IObjectStreamOut &ioStream) const
Write the data type of this attribute to a stream.
Definition: SerializableAttribute.h:85
bool(*)(int inArrayDepth, EOSDataType inDataType, const char *inClassName) pIsType
Definition: SerializableAttribute.h:39
const RTTI * GetMemberPrimitiveType() const
In case this attribute contains an RTTI type, return it (note that a Array<sometype> will return the ...
Definition: SerializableAttribute.h:61
const T * GetMemberPointer(const void *inObject) const
Definition: SerializableAttribute.h:58
T * GetMemberPointer(void *inObject) const
Access to the memory location that contains the member.
Definition: SerializableAttribute.h:56
void SetName(const char *inName)
Name of the attribute.
Definition: SerializableAttribute.h:51
SerializableAttribute(const char *inName, uint inMemberOffset, pGetMemberPrimitiveType inGetMemberPrimitiveType, pIsType inIsType, pReadData inReadData, pWriteData inWriteData, pWriteDataType inWriteDataType)
Constructor.
Definition: SerializableAttribute.h:45
bool IsType(int inArrayDepth, EOSDataType inDataType, const char *inClassName) const
Check if this attribute is of a specific type.
Definition: SerializableAttribute.h:67
bool(*)(IObjectStreamIn &ioStream, void *inObject) pReadData
Definition: SerializableAttribute.h:40
bool ReadData(IObjectStreamIn &ioStream, void *inObject) const
Read the data for this attribute into attribute containing class inObject.
Definition: SerializableAttribute.h:73
SerializableAttribute(const SerializableAttribute &inOther, int inBaseOffset)
Construct from other attribute with base class offset.
Definition: SerializableAttribute.h:48
const char * GetName() const
Definition: SerializableAttribute.h:52
const RTTI *(*)() pGetMemberPrimitiveType
@ Serialization functions
Definition: SerializableAttribute.h:38
void(*)(IObjectStreamOut &ioStream, const void *inObject) pWriteData
Definition: SerializableAttribute.h:41