47 #ifndef _MIRA_REFLECTORINTERFACE_H_ 48 #define _MIRA_REFLECTORINTERFACE_H_ 51 #include <unordered_map> 54 #include <boost/preprocessor/repetition.hpp> 55 #include <boost/mpl/bool.hpp> 56 #include <boost/type_traits/integral_constant.hpp> 71 namespace serialization {
110 template <
typename Derived>
241 template <
typename T>
275 template <
typename T>
280 MIRA_DEPRECATED(
"Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)",
287 template <
typename T>
291 MIRA_DEPRECATED(
"Please call as requireVersion<MyType>(v) or requireVersion(v, this)",
336 template <
typename T>
346 template <
typename T>
354 template <
typename T>
413 template<
typename T,
typename U>
422 template<
typename T,
typename U>
424 const char* comment,
const U& defaultValue,
432 template<
typename T,
typename U>
434 const char* comment,
const U& defaultValue,
483 template<
typename T,
typename U>
492 template<
typename T,
typename U>
494 const char* comment,
const U& defaultValue,
502 template<
typename T,
typename U>
504 const char* comment,
const U& defaultValue,
584 template<
typename R,
typename... Args,
typename F,
typename... Description>
586 method(
const char*, F&&, Description&&...)
591 template<
typename F,
typename... Description>
593 method(
const char*, F&&, Description&&...)
598 template<
typename R,
typename Class,
typename... Args,
typename... Description>
605 template<
typename R,
typename Class,
typename... Args,
typename... Description>
613 template<
typename R,
typename... Args,
typename F,
typename... Description>
615 method(
const char*, F&&, Description&&...)
618 template<
typename F,
typename... Description>
620 method(
const char*, F&&, Description&&...)
623 template<
typename R,
typename Class,
typename... Args,
typename... Description>
628 template<
typename R,
typename Class,
typename... Args,
typename... Description>
635 template<
typename R,
typename ...Args>
640 "_____________NUMBER OR TYPES OF NAMES/DESCRIPTIONS/SAMPLEVALUES FOR PARAMETERS " 641 "IN CALL TO Reflector::method() DO NOT MATCH THE PROVIDED FUNCTION'S SIGNATURE. " 642 "PLEASE PROVIDE const char* NAME AND DESCRIPTION FOR EACH RPC METHOD PARAMETER, " 643 "OR NAME, DESCRIPTION AND A CORRECTLY TYPED SAMPLE VALUE FOR EACH PARAMETER._____________");
681 void method(
const char* name, Method
method,
const char* comment,
682 const char* paramName,
const char* paramDescription, P paramSampleValue, ...);
708 const char* paramName,
const char* paramDescription, P paramSampleValue, ...);
733 void method(
const char* name, Method
method,
const char* comment,
734 const char* paramName,
const char* paramDescription, P paramSampleValue, ...);
791 template <
typename Base>
802 return Derived::useHumanReadableIDs::value;
825 typeName<Derived>() <<
"::requireReflectBarriers == true, but " <<
826 typeName<Derived>() <<
"::preReflect() not implemented!");
828 return ReflectState();
835 typeName<Derived>() <<
"::requireReflectBarriers == true, but " <<
836 typeName<Derived>() <<
"::postReflect() not implemented!");
844 std::stringstream ss;
850 catch(XInvalidConfig&) {}
874 #define MIRA_REFLECT_VERSION(reflector, versionNumber) reflector.version(versionNumber, this) 893 #define MIRA_REFLECT_REQUIRE_VERSION(reflector, versionNumber) reflector.requireVersion(versionNumber, this) 912 #define MIRA_REFLECT_BASE(reflector, BaseClass) reflector.template reflectBase<BaseClass>(*this) 931 #define MIRA_REFLECT_BASE_NONINTRUSIVE(reflector, BaseClass, object) reflector.template reflectBase<BaseClass>(object) 970 #define MIRA_REFLECT_BASE_IF_VERSION_ATLEAST(reflector, BaseClass, versionvar, minversion) \ 971 if (versionvar < minversion) \ 972 BaseClass::reflect(reflector); \ 974 reflector.template reflectBase<BaseClass>(*this); \ 985 #define MIRA_REFLECT_BASE_NONINTRUSIVE_IF_VERSION_ATLEAST(reflector, BaseClass, object, versionvar, minversion) \ 986 if (versionvar < minversion) \ 987 reflect(reflector, (BaseClass&)object); \ 989 reflector.template reflectBase<BaseClass>(object); \ 1003 #define MIRA_MEMBER_WITH_ID(reflector, name, id, var, ...) \ 1004 if(reflector.usesHumanReadableIDs()) \ 1005 reflector.member(name, id, var, __VA_ARGS__); \ 1007 reflector.member(name, var, __VA_ARGS__); 1009 #define MIRA_PROPERTY_WITH_ID(reflector, name, id, var, ...) \ 1010 if(reflector.usesHumanReadableIDs()) \ 1011 reflector.property(name, id, var, __VA_ARGS__); \ 1013 reflector.property(name, var, __VA_ARGS__); static int checkForcedVersion(const std::string &variable)
Definition: ReflectorInterface.h:841
std::unordered_map< Typename, VersionType > ClassVersionMap
Definition: ReflectorInterface.h:73
void popObjectTrackingStore()
Pop the current object tracking memory from internal stack (restore).
Definition: ReflectorInterface.h:749
void property(const char *name, T &member, const char *comment, const U &defaultValue, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as the corresponding member-method, to indicate that the member is a property and can be altered...
Definition: ReflectorInterface.h:484
VersionType version(VersionType version, const T *caller=NULL)
Specifies the current class version and returns the version found in the data stream.
Definition: ReflectorInterface.h:242
void member(const char *name, const T &member, Setter< T > setter, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, with a special setter method for reading the member.
Definition: ReflectorInterface.h:392
serialization::ClassVersionMap ClassVersionMap
Definition: ReflectorInterface.h:294
void delegate(Getter< T > getter, Setter< T > setter, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Delegates the serialization/reflection of a member directly to the member.
Definition: ReflectorInterface.h:567
void member(const char *name, const std::string &id, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, with an extra parameter for specifying the id explicitly if it differs from name...
Definition: ReflectorInterface.h:384
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void itemName(const std::string &name)
If the currently reflected object is an item within a collection, this allows to specify an explicit ...
Definition: ReflectorInterface.h:541
If 'reflect barriers' are used, each separated reflection block within an object has a separate state...
Definition: ReflectorInterface.h:179
boost::mpl::bool_< false > requireReflectBarriers
Specifies whether the Reflector uses so-called 'reflect barriers' to allow maintaining separate state...
Definition: ReflectorInterface.h:148
Provides property hints and attributes.
InvalidRPCDescription< R(Class::*)(Args...) const, Description... > method(const char *, R(Class::*)(Args...) const, Class *, Description &&...)
Definition: ReflectorInterface.h:607
Class object which supports some kind of class reflection.
Definition: Class.h:97
Setter< T > setter(void(*f)(const T &))
Creates a Setter for global or static class methods taking the argument by const reference.
Definition: GetterSetter.h:443
void member(const char *name, Getter< T > getter, Setter< T > setter, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, with a special getter and setter accessing the member.
Definition: ReflectorInterface.h:402
Holds a boost::function object to a special setter function that must meet the signature "void method...
Definition: GetterSetter.h:395
InvalidRPCDescription< R(Class::*)(Args...), Description... > method(const char *, R(Class::*)(Args...), Class *, Description &&...)
Definition: ReflectorInterface.h:600
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 versi...
Definition: ReflectorInterface.h:276
Get compiler and platform independent typenames.
void desireClassVersions(const ClassVersionMap &versions)
Historically, classes have just been defining their current version themselves during serialization (...
Definition: ReflectorInterface.h:328
uint8 VersionType
Definition: ReflectorInterface.h:72
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
void roproperty(const char *name, const T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
A property that just reflects a runtime state of the object and can be displayed but not altered...
Definition: ReflectorInterface.h:514
This is the public interface of all reflectors that are able to visit a class' reflect() method...
Definition: ReflectorInterface.h:111
ValidRPCDescription< R(Args...), Description... > method(const char *, F &&, Description &&...)
Definition: ReflectorInterface.h:615
A property hint gives optional instructions to the property editor, i.e.
Definition: PropertyHint.h:82
void roproperty(const char *name, Getter< T > getter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, with a special getter method for reading the member.
Definition: ReflectorInterface.h:532
Flags controlling reflector behaviour.
boost::mpl::bool_< true > isReadOnly
Specifies, if the Reflector is read-only (true) or write-only (false).
Definition: ReflectorInterface.h:121
static bool usesHumanReadableIDs()
Returns true, if the concrete derived Reflector supports human readable IDs.
Definition: ReflectorInterface.h:801
Provides RPC SFINAE helper to check whether a provided description parameter pack is valid...
InvalidRPCDescription< F, Description... > method(const char *, F &&, Description &&...)
Definition: ReflectorInterface.h:593
MIRA_DEPRECATED("Please call as requireVersion<MyType>(v) or requireVersion(v, this)", VersionType requireVersion(VersionType version))
Deprecated 'anonymous' (no type) requireVersion().
Definition: ReflectorInterface.h:291
void pushObjectTrackingStore()
Push the current object tracking memory to an internal stack (backup).
Definition: ReflectorInterface.h:746
void reflectBase(Base &base)
Method that can be called to reflect the base class easily.
Definition: ReflectorInterface.h:792
MIRA_BASE_EXPORT std::string resolveEnvironmentVariable(const std::string &envVar)
Resolves an environmental variable.
No flags.
Definition: ReflectControlFlags.h:65
void member(const char *name, Getter< T > getter, Setter< T > setter, const char *comment, const U &defaultValue, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, where a default value can be specified that is used, if the value is not available in ...
Definition: ReflectorInterface.h:433
void property(const char *name, Getter< T > getter, Setter< T > setter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as the corresponding member-method, to indicate that the member is a property and can be altered...
Definition: ReflectorInterface.h:473
MIRA_DEPRECATED("Please call as version<MyType>(v) or version(v, this)", VersionType version(VersionType version))
Deprecated 'anonymous' (no type) version().
Definition: ReflectorInterface.h:248
ValidRPCDescription< R(Class::*)(Args...) const, Description... > method(const char *, R(Class::*)(Args...) const, Class *, Description &&...)
Definition: ReflectorInterface.h:630
ValidRPCDescription< F, Description... > method(const char *, F &&, Description &&...)
Definition: ReflectorInterface.h:620
void invalid_method()
Definition: ReflectorInterface.h:636
Tag class used as parameter to ReflectorInterface::version() etc.
Definition: ReflectorInterface.h:80
ValidRPCDescription< R(Class::*)(Args...), Description... > method(const char *, R(Class::*)(Args...), Class *, Description &&...)
Definition: ReflectorInterface.h:625
VersionType version(VersionType version, AcceptDesiredVersion, const T *caller=NULL)
Extension of version() (see above), that additionally signals the reflector that the caller will prop...
Definition: ReflectorInterface.h:337
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)
Same as the corresponding member-method, to indicate that the member is a property and can be altered...
Definition: ReflectorInterface.h:493
Getter< T > getter(T(*f)())
Creates a Getter for global or static class methods returning the result by value.
Definition: GetterSetter.h:136
InvalidRPCDescription< R(Args...), Description... > method(const char *, F &&, Description &&...)
Definition: ReflectorInterface.h:586
void delegate(const T &member, Setter< T > setter, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Delegates the serialization/reflection of a member directly to the member.
Definition: ReflectorInterface.h:558
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)
Same as the corresponding member-method, to indicate that the member is a property and can be altered...
Definition: ReflectorInterface.h:503
void delegate(T &member, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Delegates the serialization/reflection of a member directly to the member.
Definition: ReflectorInterface.h:549
typename std::enable_if< Private::rpc::isValid< F, Description... >()>::type ValidRPCDescription
Definition: RPCPatternCheck.h:307
typename std::enable_if<!Private::rpc::isValid< F, Description... >()>::type InvalidRPCDescription
Definition: RPCPatternCheck.h:310
void member(const char *name, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Specifies a class member for reflection/serialization.
Definition: ReflectorInterface.h:375
void member(const char *name, T &member, const char *comment, const U &defaultValue, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, where a default value can be specified that is used, if the value is not available in ...
Definition: ReflectorInterface.h:414
void roproperty(const char *name, const std::string &id, const T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, with an extra parameter for specifying the id explicitly if it differs from name...
Definition: ReflectorInterface.h:523
void property(const char *name, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as the corresponding member-method, to indicate that the member is a property and can be altered...
Definition: ReflectorInterface.h:445
serialization::VersionType VersionType
Definition: ReflectorInterface.h:194
Holds a boost::function object to a special getter function that must meet the signature "T method()"...
Definition: GetterSetter.h:87
void property(const char *name, const std::string &id, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, with an extra parameter for specifying the id explicitly if it differs from name...
Definition: ReflectorInterface.h:455
Functions for platform independent resolving of environment variables.
VersionType requireVersion(VersionType version, VersionType minVersion, AcceptDesiredVersion, const T *caller=NULL)
Extension of requireVersion() (see above), that additionally signals the reflector that the caller wi...
Definition: ReflectorInterface.h:347
ReflectCtrlFlags
Control Flags that can modify the behavior of certain reflectors.
Definition: ReflectControlFlags.h:63
serialization::AcceptDesiredVersion AcceptDesiredVersion
Definition: ReflectorInterface.h:330
void requireVersion(VersionType version, AcceptDesiredVersion, const T *caller=NULL)
Extension of requireVersion() (see above), that additionally signals the reflector that the caller wi...
Definition: ReflectorInterface.h:355
void property(const char *name, const T &member, Setter< T > setter, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as the corresponding member-method, to indicate that the member is a property and can be altered...
Definition: ReflectorInterface.h:464
ReflectState preReflect(const char *context="")
If a reflector requires reflection barriers, preReflect() and postReflect() should be called before/a...
Definition: ReflectorInterface.h:822
boost::mpl::bool_< true > useHumanReadableIDs
Specifies, if the Reflector supports human readable IDs.
Definition: ReflectorInterface.h:128
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().
Definition: ReflectorInterface.h:280
Provides definition for getters and setters that are used with the serialization framework.
void member(const char *name, const T &member, Setter< T > setter, const char *comment, const U &defaultValue, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Same as above, where a default value can be specified that is used, if the value is not available in ...
Definition: ReflectorInterface.h:423
Definition: ReflectorInterface.h:114
void requireVersion(VersionType version, const T *caller=NULL)
Specifies the current class version, which is also the minimum (and therefore only) version accepted ...
Definition: ReflectorInterface.h:288
void interface(const char *name)
Indicates that the class implements the specified RPC interface.
Definition: ReflectorInterface.h:581
constexpr std::enable_if<!FunctionTraits< F >::isFunction >::type invalidAssertion()
Definition: RPCPatternCheck.h:282
void postReflect(const ReflectState &)
See preReflect for documentation.
Definition: ReflectorInterface.h:832