MIRA
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
PropertySerializer Class Reference

A special PropertyReflector that creates a PropertyNode for each reflected property. More...

#include <serialization/PropertySerializer.h>

Inheritance diagram for PropertySerializer:
Inheritance graph
[legend]

Public Types

typedef ReflectorInterface< PropertySerializer >::VersionType VersionType
 
typedef ReflectorInterface< PropertySerializer >::AcceptDesiredVersion AcceptDesiredVersion
 
typedef boost::mpl::bool_< true > isReadOnly
 Specifies, if the Reflector is read-only (true) or write-only (false). More...
 
typedef boost::mpl::bool_< true > useHumanReadableIDs
 Specifies, if the Reflector supports human readable IDs. More...
 
typedef boost::mpl::bool_< false > requireReflectBarriers
 Specifies whether the Reflector uses so-called 'reflect barriers' to allow maintaining separate states for individual blocks of reflected data. More...
 

Public Member Functions

 PropertySerializer ()
 
template<typename T >
void continueWithBaseInvoke (T &member, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
 Is called by invokePropertyMemberOverwrite() and will call the actual Base::invokePropertyMemberOverwrite() method that recursively examines all properties. More...
 
template<typename Getter , typename Setter >
void continueWithBaseInvoke (Accessor< Getter, Setter > &accessor, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
 Specialization of the above method for properties with getters and setters. More...
 
template<typename T >
void invokePropertyMemberOverwrite (T &member, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
 Invokes the PropertyReflector on the specified member. More...
 
void itemName (const std::string &name)
 
template<typename T >
void reflectProperties (PropertyNode *root, const std::string &name, T &object)
 Reflects the properties of the specified 'object'. More...
 
template<typename T >
void reflectProperties (PropertyNode *root, const std::string &name, const std::string &id, T &object)
 Same as above, but additionally, a unique id can be specified for the object. More...
 
template<typename T >
PropertyNodereflectProperties (const std::string &name, T &object)
 Reflects the properties of the specified 'object'. More...
 
template<typename T >
PropertyNodereflectProperties (const std::string &name, const std::string &id, T &object)
 Same as above, but additionally, a unique id can be specified for the object. More...
 
void member (const char *name, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void member (const char *name, const std::string &id, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void member (const char *name, const T &member, Setter< T > setter, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void member (const char *name, Getter< T > getter, Setter< T > setter, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void member (const char *name, T &member, const char *comment, const U &defaultValue, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void member (const char *name, const T &member, Setter< T > setter, const char *comment, const U &defaultValue, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void member (const char *name, Getter< T > getter, Setter< T > setter, const char *comment, const U &defaultValue, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void property (const char *name, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void property (const char *name, const std::string &id, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void property (const char *name, const T &member, Setter< T > setter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void property (const char *name, Getter< T > getter, Setter< T > setter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void property (const char *name, T &member, const char *comment, const U &defaultValue, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void property (const char *name, const T &member, Setter< T > setter, const char *comment, const U &defaultValue, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void property (const char *name, Getter< T > getter, Setter< T > setter, const char *comment, const U &defaultValue, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void roproperty (const char *name, const T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void roproperty (const char *name, const std::string &id, const T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void roproperty (const char *name, Getter< T > getter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void delegate (T &member, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void delegate (const T &member, Setter< T > setter, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void delegate (Getter< T > getter, Setter< T > setter, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
 
void invokeMemberOverwrite (T &member, const ReflectMemberMeta &meta)
 This method should never be called, since the PropertyReflector and derived classes uses their own invokePropertyMember mechanism to invoke the reflector and bypasses the invokeMember() / invokeMemberOverwrite() methods. More...
 
void invokePropertyMember (T &member, const ReflectMemberMeta &meta, PropertyHint &&hint, bool isReadOnly, bool isVolatile)
 Invokes the serializer. More...
 
const ReflectMemberMetagetCurrentMemberMeta () const
 Returns the meta-information of the current member that is reflected. More...
 
const std::string & getCurrentMemberFullID () const
 Returns the full human readable object id / name of the current member being reflected. More...
 
void invokeMember (T &member, const ReflectMemberMeta &meta)
 Is called to invoke this Reflector on the member with the specified meta information. More...
 
void invokePointerObject (T &member)
 Is called to reflect objects of pointers. More...
 
void invokeMemberWithoutDefault (T &member, const ReflectMemberMeta &meta)
 Delegates to invokeMember() and rethrows any occurring XMemberNotFound exception as XIO exception. More...
 
void invokeMemberWithDefault (T &member, const ReflectMemberMeta &meta, const U &defaultValue)
 Delegates to invokeMember() and handles any occurring XMemberNotFound exception by setting the member to the given default value. More...
 
void invokeMemberWithDefault (T &member, const ReflectMemberMeta &meta, const serialization::IgnoreMissing &defaultValue)
 Delegates to invokeMember() and handles any occurring XMemberNotFound exception by ignoring the exception and hence the missing member, as indicated by IgnoreMissing as default value. More...
 
VersionType requireVersion (VersionType version, VersionType minVersion, const T *caller=NULL)
 implements ReflectorInterface (for documentation see ReflectorInterface) More...
 
void requireVersion (VersionType requiredVersion, const T *caller=NULL)
 implements ReflectorInterface (for documentation see ReflectorInterface) More...
 
VersionType requireVersion (VersionType version, VersionType minVersion, AcceptDesiredVersion, const T *caller=NULL)
 implements ReflectorInterface (for documentation see ReflectorInterface) More...
 
void requireVersion (VersionType requiredVersion, AcceptDesiredVersion, const T *caller=NULL)
 implements ReflectorInterface (for documentation see ReflectorInterface) More...
 
 MIRA_DEPRECATED ("Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)", VersionType requireVersion(VersionType version, VersionType minVersion))
 
 MIRA_DEPRECATED ("Please call as requireVersion<MyType>(v) or requireVersion(v, this)", void requireVersion(VersionType requiredVersion))
 
void reflectBase (Base &base)
 implements ReflectorInterface (for documentation see ReflectorInterface) More...
 
ReflectState preReflect (const char *context="")
 If a reflector requires reflection barriers, preReflect() and postReflect() should be called before/after calling an external method within reflect(), to declare these barriers (such a 'barrier' is just a declaration to the reflector, in fact). More...
 
void postReflect (const ReflectState &)
 See preReflect for documentation. More...
 
Visiting methods that are called by the RecursiveMemberReflector

while reflecting the members

void atomic (T &member)
 Is called if the member is an atomic type (int, float, etc). More...
 
void enumeration (T &member)
 Is called by the if the member is an enumeration. More...
 
void object (T &member)
 Is called for each complex object. More...
 
void collection (T &member)
 Is called for each complex object or array, where the IsCollection<T> trait is true_type. More...
 
void trackObject (T &member)
 
void pointer (T *&pointer)
 Is called if the member is a pointer. More...
 
void pointerNormal (T *&pointer, int typeId)
 Is called if a reflected pointer is a "normal" pointer. More...
 
void pointerPolymorphic (T *&pointer, int typeId)
 Is called if a reflected pointer is a polymorphic pointer to an object that is derived from mira::Object. More...
 
void pointerAbstract (T *&pointer, int typeId)
 Is called if a reflected pointer is a pointer to an abstract class. More...
 
Methods for reflecting RPC (remote procedure call) methods
void interface (const char *name)
 Indicates that the class implements the specified RPC interface. More...
 
void method (const char *name, Method method, const char *comment, const char *paramName, const char *paramDescription, P paramSampleValue,...)
 Specifies that the class that is reflected provides a service through the specified static member function or free function. More...
 
void method (const char *name, Method method, Class *object, const char *comment, const char *paramName, const char *paramDescription, P paramSampleValue,...)
 Specifies that the class that is reflected provides a service through the specified non-static member function. More...
 
void method (const char *name, Method method, const char *comment, const char *paramName, const char *paramDescription, P paramSampleValue,...)
 Specifies that the class that is reflected provides a service through the specified function wrapper. More...
 
Controlling the object tracking state.
void pushObjectTrackingStore ()
 Push the current object tracking memory to an internal stack (backup). More...
 
void popObjectTrackingStore ()
 Pop the current object tracking memory from internal stack (restore). More...
 

Static Public Member Functions

static void registerClass ()
 Registers a new polymorphic class at the PolymorphPointerReflector. More...
 
static void unregisterClass ()
 Unregisters the class. More...
 
static bool isReflectedAsPointer ()
 For internal use only: Returns true, if the type T is ever reflected as pointer within the current translation unit (C file). More...
 
static bool usesHumanReadableIDs ()
 Returns true, if the concrete derived Reflector supports human readable IDs. More...
 

Public Attributes

PropertyNodemCurrentNode
 

Protected Member Functions

void invokeTrackObject (T &member)
 tracks the given object (if pointer tracking is enabled for type T) More...
 
PropertySerializerThis ()
 "Curiously recurring template pattern" (CRTP). More...
 
void invoke (T &object)
 Invokes this reflector on the specified object. More...
 
void invokeOverwrite (T &object)
 The actual invoke implementation, that may also be overwritten in derived classes to add additional functionality. More...
 

Static Protected Member Functions

static int checkForcedVersion (const std::string &variable)
 

Static Protected Attributes

static constexpr auto MIRA_REFLECTOR_TOPLEVEL_NAME
 Use this when a reflector needs to choose a name for serializing an object. More...
 

Optional Class Versioning.

These visiting methods may be supported by different reflectors like the RecursiveMemberReflector and the RPCMethodReflector, etc.

Note
Specifying versions for serialized classes is optional.
requireVersion() and version() currently are supported by serialization reflectors only.
VersionType requireVersion (VersionType version, VersionType minVersion, const T *caller=NULL)
 Same as above, but allows to specify a minimum supported version, and throws XIO if the minimum version requirement is not met. More...
 
void requireVersion (VersionType version, const T *caller=NULL)
 Specifies the current class version, which is also the minimum (and therefore only) version accepted (therefore, no need to return a version number). More...
 
VersionType requireVersion (VersionType version, VersionType minVersion, AcceptDesiredVersion, const T *caller=NULL)
 Extension of requireVersion() (see above), that additionally signals the reflector that the caller will properly handle a different version than the one it specifies itself. More...
 
void requireVersion (VersionType version, AcceptDesiredVersion, const T *caller=NULL)
 Extension of requireVersion() (see above), that additionally signals the reflector that the caller will properly handle a different version than it one it specifies itself. More...
 
 MIRA_DEPRECATED ("Please call as version<MyType>(v) or version(v, this)", VersionType version(VersionType version))
 Deprecated 'anonymous' (no type) version(). More...
 
 MIRA_DEPRECATED ("Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)", VersionType requireVersion(VersionType version, VersionType minVersion))
 Deprecated 'anonymous' (no type) requireVersion(). More...
 
 MIRA_DEPRECATED ("Please call as requireVersion<MyType>(v) or requireVersion(v, this)", VersionType requireVersion(VersionType version))
 Deprecated 'anonymous' (no type) requireVersion(). More...
 
VersionType version (VersionType version, const T *caller=NULL)
 Specifies the current class version and returns the version found in the data stream. More...
 
VersionType version (VersionType version, AcceptDesiredVersion, const T *caller=NULL)
 Extension of version() (see above), that additionally signals the reflector that the caller will properly handle a different version than the one it specifies itself. More...
 
void desireClassVersions (const ClassVersionMap &versions)
 Historically, classes have just been defining their current version themselves during serialization (the case where an object exists and its state is read out and serialized), by calling Reflector::version() with the respective version number parameter. More...
 
typedef serialization::ClassVersionMap ClassVersionMap
 

Detailed Description

A special PropertyReflector that creates a PropertyNode for each reflected property.

Moreover, it updates existing property nodes, if a property is updated and reflected again.

Member Typedef Documentation

◆ VersionType

◆ AcceptDesiredVersion

◆ isReadOnly

typedef boost::mpl::bool_<true> isReadOnly
inherited

Specifies, if the Reflector is read-only (true) or write-only (false).

This type must be set to the proper boost::mpl::bool type by the derived Reflector class. (Default is true)

◆ useHumanReadableIDs

typedef boost::mpl::bool_<true> useHumanReadableIDs
inherited

Specifies, if the Reflector supports human readable IDs.

This type must be set to the proper boost::mpl::bool type by the derived Reflector class. (Default is true)

◆ requireReflectBarriers

typedef boost::mpl::bool_<false> requireReflectBarriers
inherited

Specifies whether the Reflector uses so-called 'reflect barriers' to allow maintaining separate states for individual blocks of reflected data.

A reflect barrier is just a virtual separation line declared by a reflected object. It tells the reflector that certain parts of the reflected data should be considered as independent and can have separate states (if the reflector maintains any states for data). As an example, the BinarySerializer reserves space for a version number for each reflected object. If there is more than one individual block, it reserves space for a version for each of the blocks. If the reflector needs reflect barriers, it defines requireReflectBarriers::type to true in its class scope, and defines methods preReflect() and postReflect() that should be called by reflected objects for separation of independent reflection blocks (where the separation is not already implied by visitors like reflector.member()!) (The default is false). Also see ReflectState and MIRA_REFLECT_CALL.

◆ ClassVersionMap

Constructor & Destructor Documentation

◆ PropertySerializer()

PropertySerializer ( )
inline

Member Function Documentation

◆ continueWithBaseInvoke() [1/2]

void continueWithBaseInvoke ( T &  member,
const ReflectMemberMeta meta,
PropertyHint &&  hint,
bool  isReadOnly,
bool  isVolatile 
)
inline

Is called by invokePropertyMemberOverwrite() and will call the actual Base::invokePropertyMemberOverwrite() method that recursively examines all properties.

This method is a helper which is overloaded below, to avoid recursive examination for properties with Getters and Setters which is not implemented yet.

◆ continueWithBaseInvoke() [2/2]

void continueWithBaseInvoke ( Accessor< Getter, Setter > &  accessor,
const ReflectMemberMeta meta,
PropertyHint &&  hint,
bool  isReadOnly,
bool  isVolatile 
)
inline

Specialization of the above method for properties with getters and setters.

For those, a recursive reflection is not yet implemented.

◆ invokePropertyMemberOverwrite()

void invokePropertyMemberOverwrite ( T &  member,
const ReflectMemberMeta meta,
PropertyHint &&  hint,
bool  isReadOnly,
bool  isVolatile 
)
inline

Invokes the PropertyReflector on the specified member.

If the corresponding property node for the member exists already, its content and sub-nodes will be updated. Otherwise, a new property node is created. All sub-properties of the member are invoked recursively.

◆ itemName()

void itemName ( const std::string &  name)
inline

◆ reflectProperties() [1/4]

void reflectProperties ( PropertyNode root,
const std::string &  name,
T &  object 
)
inline

Reflects the properties of the specified 'object'.

The properties will be stored as a sub-node of 'root'. The name of that sub-node will be 'name'.

◆ reflectProperties() [2/4]

void reflectProperties ( PropertyNode root,
const std::string &  name,
const std::string &  id,
T &  object 
)
inline

Same as above, but additionally, a unique id can be specified for the object.

In the above method, the id will be equal to the name.

◆ reflectProperties() [3/4]

PropertyNode* reflectProperties ( const std::string &  name,
T &  object 
)
inline

Reflects the properties of the specified 'object'.

In contrast to the above methods, the created property sub-node is not added to any parent node. Instead it is returned by the method. The name of the created property node can be specified by 'name'.

◆ reflectProperties() [4/4]

PropertyNode* reflectProperties ( const std::string &  name,
const std::string &  id,
T &  object 
)
inline

Same as above, but additionally, a unique id can be specified for the object.

In the above method, the id will be equal to the name.

◆ member() [1/7]

void member ( const char *  name,
T &  member,
const char *  comment,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ member() [2/7]

void member ( const char *  name,
const std::string &  id,
T &  member,
const char *  comment,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ member() [3/7]

void member ( const char *  name,
const T &  member,
Setter< T >  setter,
const char *  comment,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ member() [4/7]

void member ( const char *  name,
Getter< T >  getter,
Setter< T >  setter,
const char *  comment,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ member() [5/7]

void member ( const char *  name,
T &  member,
const char *  comment,
const U &  defaultValue,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ member() [6/7]

void member ( const char *  name,
const T &  member,
Setter< T >  setter,
const char *  comment,
const U &  defaultValue,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ member() [7/7]

void member ( const char *  name,
Getter< T >  getter,
Setter< T >  setter,
const char *  comment,
const U &  defaultValue,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ property() [1/7]

void property ( const char *  name,
T &  member,
const char *  comment,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ property() [2/7]

void property ( const char *  name,
const std::string &  id,
T &  member,
const char *  comment,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ property() [3/7]

void property ( const char *  name,
const T &  member,
Setter< T >  setter,
const char *  comment,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ property() [4/7]

void property ( const char *  name,
Getter< T >  getter,
Setter< T >  setter,
const char *  comment,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ property() [5/7]

void property ( const char *  name,
T &  member,
const char *  comment,
const U &  defaultValue,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ property() [6/7]

void property ( const char *  name,
const T &  member,
Setter< T >  setter,
const char *  comment,
const U &  defaultValue,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ property() [7/7]

void property ( const char *  name,
Getter< T >  getter,
Setter< T >  setter,
const char *  comment,
const U &  defaultValue,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ roproperty() [1/3]

void roproperty ( const char *  name,
const T &  member,
const char *  comment,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ roproperty() [2/3]

void roproperty ( const char *  name,
const std::string &  id,
const T &  member,
const char *  comment,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ roproperty() [3/3]

void roproperty ( const char *  name,
Getter< T >  getter,
const char *  comment,
PropertyHint &&  hint = PropertyHint(),
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ delegate() [1/3]

void delegate ( T &  member,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ delegate() [2/3]

void delegate ( const T &  member,
Setter< T >  setter,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ delegate() [3/3]

void delegate ( Getter< T >  getter,
Setter< T >  setter,
ReflectCtrlFlags  flags = REFLECT_CTRLFLAG_NONE 
)
inlineinherited

◆ invokeMemberOverwrite()

void invokeMemberOverwrite ( T &  member,
const ReflectMemberMeta meta 
)
inlineinherited

This method should never be called, since the PropertyReflector and derived classes uses their own invokePropertyMember mechanism to invoke the reflector and bypasses the invokeMember() / invokeMemberOverwrite() methods.

◆ invokePropertyMember()

void invokePropertyMember ( T &  member,
const ReflectMemberMeta meta,
PropertyHint &&  hint,
bool  isReadOnly,
bool  isVolatile 
)
inlineinherited

Invokes the serializer.

This method delegates the call to the most derived invokePropertyMemberOverwrite() method that usually is overwritten in subclasses.

This bypasses the usual invokeMember() / invokeMemberOverwrite() mechanism of the base serializer. Internally Base::invokeMemberOverwrite() of the base serializer will be called to reflect the members recursively

◆ atomic()

void atomic ( T &  member)
inlineinherited

Is called if the member is an atomic type (int, float, etc).

(Type A1)

As for all the other visit-methods the parameter is a reference to the actual visited/reflected member.

This method usually will be implemented in concrete derived classes.

◆ enumeration()

void enumeration ( T &  member)
inlineinherited

Is called by the if the member is an enumeration.

(Type A2)

As for all the other visit-methods the parameter is a reference to the actual visited/reflected member.

The default implementation casts the enum to an uint32 and calls atomic().

◆ object()

void object ( T &  member)
inlineinherited

Is called for each complex object.

See documentation of RecursiveMemberReflectorBase class for detailed calling sequences. If you overwrite this method in a derived class you should call the method of the Base class to allow recursive reflection of the complex object's members.

◆ collection()

void collection ( T &  member)
inlineinherited

Is called for each complex object or array, where the IsCollection<T> trait is true_type.

The default implementation calls object().

◆ trackObject()

void trackObject ( T &  member)
inlineinherited

◆ pointer()

void pointer ( T *&  pointer)
inlineinherited

Is called if the member is a pointer.

(Type C) The default implementation detects the specific pointer type and calls pointerNormal(), pointerPolymorphic() or pointerAbstract().

◆ pointerNormal()

void pointerNormal ( T *&  pointer,
int  typeId 
)
inlineinherited

Is called if a reflected pointer is a "normal" pointer.

As second parameter the typeId of the concrete objects class is passed. The default implementation recursively reflects the object, the pointer points to (if the pointer is not NULL).

◆ pointerPolymorphic()

void pointerPolymorphic ( T *&  pointer,
int  typeId 
)
inlineinherited

Is called if a reflected pointer is a polymorphic pointer to an object that is derived from mira::Object.

As second parameter the typeId of the concrete objects class is passed (may be -1, if pointer is a NULL pointer) The default implementation recursively reflects the object, the pointer points to (if the pointer is not NULL).

◆ pointerAbstract()

void pointerAbstract ( T *&  pointer,
int  typeId 
)
inlineinherited

Is called if a reflected pointer is a pointer to an abstract class.

As second parameter the typeId of the objects class is passed. The default implementation recursively reflects the object, the pointer points to (if the pointer is not NULL).

◆ registerClass()

static void registerClass ( )
inlinestaticinherited

Registers a new polymorphic class at the PolymorphPointerReflector.

Each RecursiveMemberReflector only is able to process pointers to polymorphic classes that are registered using this method.

The MIRA_CLASS_SERIALIZATION macro provides a simple mechanism to register a class in all known MemberReflectors and calls their registerClass() method. If you implement a new MemberReflector you should modify the MIRA_CLASS_SERIALIZATION macro and add your reflector there.

See also
MIRA_CLASS_SERIALIZATION

◆ unregisterClass()

static void unregisterClass ( )
inlinestaticinherited

Unregisters the class.

The MIRA_CLASS_SERIALIZATION macro provides a simple mechanism to register a class in all known MemberReflectors and calls their registerClass() method. If you implement a new MemberReflector you should modify the MIRA_CLASS_SERIALIZATION macro and add your reflector there.

See also
MIRA_CLASS_SERIALIZATION

◆ getCurrentMemberMeta()

const ReflectMemberMeta& getCurrentMemberMeta ( ) const
inlineinherited

Returns the meta-information of the current member that is reflected.

◆ getCurrentMemberFullID()

const std::string& getCurrentMemberFullID ( ) const
inlineinherited

Returns the full human readable object id / name of the current member being reflected.

This method must not be called if the Reflector has set useHumanReadableIDs to false. If it is called anyway we will assert here.

◆ isReflectedAsPointer()

static bool isReflectedAsPointer ( )
inlinestaticinherited

For internal use only: Returns true, if the type T is ever reflected as pointer within the current translation unit (C file).

◆ invokeTrackObject()

void invokeTrackObject ( T &  member)
inlineprotectedinherited

tracks the given object (if pointer tracking is enabled for type T)

◆ invokeMember()

void invokeMember ( T &  member,
const ReflectMemberMeta meta 
)
inlineinherited

Is called to invoke this Reflector on the member with the specified meta information.

This method delegates the call to the most derived invokeMemberOverwrite() method that may be overwritten in subclasses.

Note
Usually, the RecursiveMemberReflector should be invoked using this invokeMember() method instead of the invoke() method of the ReflectorInterface base class. The invoke() method is called internally by the RecursiveMemberReflector.

◆ invokePointerObject()

void invokePointerObject ( T &  member)
inlineinherited

Is called to reflect objects of pointers.

They will use the same meta as the pointer

◆ invokeMemberWithoutDefault()

void invokeMemberWithoutDefault ( T &  member,
const ReflectMemberMeta meta 
)
inlineinherited

Delegates to invokeMember() and rethrows any occurring XMemberNotFound exception as XIO exception.

◆ invokeMemberWithDefault() [1/2]

void invokeMemberWithDefault ( T &  member,
const ReflectMemberMeta meta,
const U &  defaultValue 
)
inlineinherited

Delegates to invokeMember() and handles any occurring XMemberNotFound exception by setting the member to the given default value.

◆ invokeMemberWithDefault() [2/2]

void invokeMemberWithDefault ( T &  member,
const ReflectMemberMeta meta,
const serialization::IgnoreMissing defaultValue 
)
inlineinherited

Delegates to invokeMember() and handles any occurring XMemberNotFound exception by ignoring the exception and hence the missing member, as indicated by IgnoreMissing as default value.

The value of the member remains unchanged.

◆ requireVersion() [1/8]

VersionType requireVersion ( VersionType  version,
VersionType  minVersion,
const T *  caller = NULL 
)
inlineinherited

implements ReflectorInterface (for documentation see ReflectorInterface)

◆ requireVersion() [2/8]

void requireVersion ( VersionType  requiredVersion,
const T *  caller = NULL 
)
inlineinherited

implements ReflectorInterface (for documentation see ReflectorInterface)

◆ requireVersion() [3/8]

VersionType requireVersion ( VersionType  version,
VersionType  minVersion,
AcceptDesiredVersion  ,
const T *  caller = NULL 
)
inlineinherited

implements ReflectorInterface (for documentation see ReflectorInterface)

◆ requireVersion() [4/8]

void requireVersion ( VersionType  requiredVersion,
AcceptDesiredVersion  ,
const T *  caller = NULL 
)
inlineinherited

implements ReflectorInterface (for documentation see ReflectorInterface)

◆ requireVersion() [5/8]

VersionType requireVersion ( VersionType  version,
VersionType  minVersion,
const T *  caller = NULL 
)
inlineinherited

Same as above, but allows to specify a minimum supported version, and throws XIO if the minimum version requirement is not met.

Calls version() internally.

Usage:

template<typename Reflector>
void reflect(Reflector& r)
{
VersionType v = r.requireVersion(4, 2, this); // specifies version 4,
// requires version 2 or higher
if(v==3) { // handle reading version 3
...
} else // only versions 2 or 4 remain
...
}
Note
Specifying versions for serialized classes is optional.
requireVersion() and version() currently are supported by serialization reflectors only

◆ requireVersion() [6/8]

void requireVersion ( VersionType  version,
const T *  caller = NULL 
)
inlineinherited

Specifies the current class version, which is also the minimum (and therefore only) version accepted (therefore, no need to return a version number).

See above.

◆ requireVersion() [7/8]

VersionType requireVersion ( VersionType  version,
VersionType  minVersion,
AcceptDesiredVersion  ,
const T *  caller = NULL 
)
inlineinherited

Extension of requireVersion() (see above), that additionally signals the reflector that the caller will properly handle a different version than the one it specifies itself.

◆ requireVersion() [8/8]

void requireVersion ( VersionType  version,
AcceptDesiredVersion  ,
const T *  caller = NULL 
)
inlineinherited

Extension of requireVersion() (see above), that additionally signals the reflector that the caller will properly handle a different version than it one it specifies itself.

◆ MIRA_DEPRECATED() [1/5]

MIRA_DEPRECATED ( "Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)"  ,
VersionType  requireVersionVersionType version, VersionType minVersion 
)
inlineinherited

◆ MIRA_DEPRECATED() [2/5]

MIRA_DEPRECATED ( "Please call as requireVersion<MyType>(v) or requireVersion(v, this)"  ,
void  requireVersionVersionType requiredVersion 
)
inlineinherited

◆ MIRA_DEPRECATED() [3/5]

MIRA_DEPRECATED ( "Please call as version<MyType>(v) or version(v, this)"  ,
VersionType  versionVersionType version 
)
inlineinherited

Deprecated 'anonymous' (no type) version().

◆ MIRA_DEPRECATED() [4/5]

MIRA_DEPRECATED ( "Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)"  ,
VersionType  requireVersionVersionType version, VersionType minVersion 
)
inlineinherited

Deprecated 'anonymous' (no type) requireVersion().

◆ MIRA_DEPRECATED() [5/5]

MIRA_DEPRECATED ( "Please call as requireVersion<MyType>(v) or requireVersion(v, this)"  ,
VersionType  requireVersionVersionType version 
)
inlineinherited

Deprecated 'anonymous' (no type) requireVersion().

◆ reflectBase()

void reflectBase ( Base &  base)
inlineinherited

implements ReflectorInterface (for documentation see ReflectorInterface)

◆ This()

PropertySerializer * This ( )
inlineprotectedinherited

"Curiously recurring template pattern" (CRTP).

Safely casts this into Derived. This is safe since when implementing derived class their type is passed as template parameter.

See Wikipedia for more details on CRTP if necessary!

◆ invoke()

void invoke ( T &  object)
inlineprotectedinherited

Invokes this reflector on the specified object.

This is like calling object.reflect(*this). However, this automatically examines if the class T contains a reflect method. In this case it calls the intrusive reflect method, otherwise it uses the non-intrusive reflect method.

◆ invokeOverwrite()

void invokeOverwrite ( T &  object)
inlineprotectedinherited

The actual invoke implementation, that may also be overwritten in derived classes to add additional functionality.

Note
If you overwrite this method you should call the implementation of the base class unless you perform your own invocation process.

◆ version() [1/2]

VersionType version ( VersionType  version,
const T *  caller = NULL 
)
inlineinherited

Specifies the current class version and returns the version found in the data stream.

During serialization (read-only reflector), the specified version usually is stored as class version in the data stream. However, the serialized version can be overridden by setting a specific version for a certain class identifier, using desireClassVersions(). In that case, version() may return a different value than specified, and the class' reflect() method must implement reflection according to that version number. During deserialization (write-only reflector), the reflector reads the version found in the data stream and returns it. Providing the type of the caller enables defining separate version numbers for all base classes of an inherited type. Each class in the inheritance hierarchy can store and retrieve a version number independently of all its bases or sub-classes (assuming reflect() calls the reflect() method of the base class using reflectBase()). The type of the caller is also required to look up whether a specific version is desired (see desireClassVersions()). The sole purpose of the 'caller' parameter is to enable automatic deduction of the template parameter T. It can be omitted when T is given explicitly.

Usage:

template<typename Reflector>
void reflect(Reflector& r)
{
VersionType v = r.version(3, this); // specifies current version 3
// in serialization case, normally returns v=3, unless
// configured differently using desireClassVersions()
// in deserialization case, returns the version read from serialized data
// (or throws XIO if that is higher than 3, i.e. incompatible)
r.member("X", x, "");
if (version >= 2)
r.member("X2", x2, "");
if (version == 3)
...
}
Note
Specifying versions for serialized classes is optional.
requireVersion() and version() currently are supported by serialization reflectors only

◆ version() [2/2]

VersionType version ( VersionType  version,
AcceptDesiredVersion  ,
const T *  caller = NULL 
)
inlineinherited

Extension of version() (see above), that additionally signals the reflector that the caller will properly handle a different version than the one it specifies itself.

◆ desireClassVersions()

void desireClassVersions ( const ClassVersionMap versions)
inlineinherited

Historically, classes have just been defining their current version themselves during serialization (the case where an object exists and its state is read out and serialized), by calling Reflector::version() with the respective version number parameter.

Different versions of a class were only considered during deserialization (i.e. restoring an object state from serialized data). In some cases it may be desirable, however, to serialize a different version (naturally, this can not be a higher version than the class implementation knows, only lower). This is useful e.g. to ensure serializing data that is compatible with a certain other (older) implementation, thus it can be deserialized by another instance.

For such cases, a mechanism is provided to generally enable requesting a specific version for any class from the reflector. This involves providing a map of class types (type names) to version numbers to the reflector. When a class contained in the map calls version() in its reflect() method, the call shall return the version number from the version map instead of the version number indicated by the class implementation itself. The class serialization must then follow that returned version.

A call to this method will always overwrite any previous setting of desired versions, i.e. the map is not cumulative.

Note
Since this is an addition to the ReflectorInterface in MIRABase 1.9.0, it cannot be ensured that all existing classes supported by the MIRA serialization framework (i.e., all classes for which exists an intrusive or non-intrusive reflect() method) properly support this mechanism of external version selection for serialization. In order to allow the reflector to be sure the class understands and observes a different version returned to it (or otherwise make the reflector refrain from changing the version indicated by the class and issue a warning instead), variants of the above version()/requireVersion() methods are introduced which implicitly provide that confirmation when called. See below.

◆ interface()

void interface ( const char *  name)
inlineinherited

Indicates that the class implements the specified RPC interface.

If you indicate that your class implements the specified interface by calling this method in your reflect method, there is an implicit contract that your class provides all methods that are defined by that interface.

◆ method() [1/3]

void method ( const char *  name,
Method  method,
const char *  comment,
const char *  paramName,
const char *  paramDescription,
paramSampleValue,
  ... 
)
inherited

Specifies that the class that is reflected provides a service through the specified static member function or free function.

The method will then be available for RPC calls. For each method its name (used to identify the method in RPC calls) and a comment that describes the method must be specified.

Parameters
nameThe name of the method (used for calling it)
methodThe static member function (or free function) that implements the method
commentA comment that describes the method
paramNameOptional additional argument(s) for the names of the method's parameters
paramDescriptionOptional additional argument(s) for the descriptions of the method's parameters.
paramSampleValueOptional additional argument(s) providing a sample value for each parameter. These are not default values, they are only used for documentation purpose, and should mainly serve to illustrate notation.

The optional parameter documentation arguments must be either a sequence of pairs of const char* values or a sequence of triplets, where each third value is a value of the respective method parameter's type. (name and description must both be provided, for all parameters or for none, and if sample values are to be added, they also need to be added for all parameters).

Examples:

r.method("myMethod1", myStaticMethod1, "static method that does something");
r.method("myMethod2", myStaticMethod2, "static method that does something else",
"x", "1st parameter", "y", "2nd parameter");
r.method("myMethod3", myStaticMethod3, "yet another static method"
"a", "parameter 1", ParamType1(...), "b", "parameter b", ParamType2(...));

◆ method() [2/3]

void method ( const char *  name,
Method  method,
Class object,
const char *  comment,
const char *  paramName,
const char *  paramDescription,
paramSampleValue,
  ... 
)
inherited

Specifies that the class that is reflected provides a service through the specified non-static member function.

The method will then be available for RPC calls. For each method its name (used to identify the method in RPC calls) and a comment that describes the method must be specified.

Parameters
nameThe name of the method (used for calling it)
methodThe non-static member function (const or non-const) that implements the method
objectA pointer to the object on which the function is called (usually "this")
commentA comment that describes the method
paramNameOptional additional argument(s) for the names of the method's parameters
paramDescriptionOptional additional argument(s) for the descriptions of the method's parameters.
paramSampleValueOptional additional argument(s) providing a sample value for each parameter.

See above for documentation of optional parameter documentation arguments.

Example:

r.method("myMethod2", &MyClass::myMethod, this, "a non-static method");

◆ method() [3/3]

void method ( const char *  name,
Method  method,
const char *  comment,
const char *  paramName,
const char *  paramDescription,
paramSampleValue,
  ... 
)
inherited

Specifies that the class that is reflected provides a service through the specified function wrapper.

The method will then be available for RPC calls. For each method its name (used to identify the method in RPC calls) and a comment that describes the method must be specified.

Parameters
nameThe name of the method (used for calling it)
methodThe function wrapper object that implements the method, e.g. created using boost::bind
commentA comment that describes the method
paramNameOptional additional argument(s) for the names of the method's parameters
paramDescriptionOptional additional argument(s) for the descriptions of the method's parameters.
paramSampleValueOptional additional argument(s) providing a sample value for each parameter.

See above for documentation of optional parameter documentation arguments.

Example:

r.method("myMethod3", boost::bind(&MyClass::myMethod, this, 1.23, 4, _1), "a function wrapper");

◆ pushObjectTrackingStore()

void pushObjectTrackingStore ( )
inlineinherited

Push the current object tracking memory to an internal stack (backup).

◆ popObjectTrackingStore()

void popObjectTrackingStore ( )
inlineinherited

Pop the current object tracking memory from internal stack (restore).

◆ usesHumanReadableIDs()

static bool usesHumanReadableIDs ( )
inlinestaticinherited

Returns true, if the concrete derived Reflector supports human readable IDs.

The return value of this method is known at compile time and hence the compiler is able to optimize the code depending on that value.

◆ preReflect()

ReflectState preReflect ( const char *  context = "")
inlineinherited

If a reflector requires reflection barriers, preReflect() and postReflect() should be called before/after calling an external method within reflect(), to declare these barriers (such a 'barrier' is just a declaration to the reflector, in fact).

The base implementation is empty and should not actually be called (if a reflector needs these methods, it must provide own definitions).

Parameters
contextCan be used to provide context, e.g. name of the reflected class or function that is called. How this is used depends on the reflector implementation, e.g. MetaSerializer uses it to generate comments on data elements implicitly defined by preReflect.

The complete process of calling these methods is wrapped by MIRA_REFLECT_CALL. That macro should be used to simplify handling.

See requireReflectBarriers and ReflectState.

◆ postReflect()

void postReflect ( const ReflectState &  )
inlineinherited

See preReflect for documentation.

◆ checkForcedVersion()

static int checkForcedVersion ( const std::string &  variable)
inlinestaticprotectedinherited

Member Data Documentation

◆ mCurrentNode

PropertyNode* mCurrentNode

◆ MIRA_REFLECTOR_TOPLEVEL_NAME

constexpr auto MIRA_REFLECTOR_TOPLEVEL_NAME
staticprotectedinherited

Use this when a reflector needs to choose a name for serializing an object.

Internally this is used to recognize it is not a name defined by the reflected object, but by the reflector.


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