47 #ifndef _MIRA_ABSTRACTREFLECTOR_H_ 48 #define _MIRA_ABSTRACTREFLECTOR_H_ 51 #include <boost/type_traits/remove_const.hpp> 52 #include <boost/mpl/assert.hpp> 67 struct ____MISSING_REFLECT_METHOD_FOR_{
68 static_assert(
sizeof(Type)==0,
69 "Cannot find an (unambiguous) intrusive or nonintrusive reflect method for Type. " 70 "If Type is a class that you have implemented, then you should " 71 "implement its reflect() method. If Type is a common class or " 72 "container from an external library (including std, boost, etc.), you " 73 "probably need to include an adapter header " 74 "like #include <serialization/adapters/std/vector>. \nNote: " 75 "If you are sure a matching reflect() method exists, it might be ambiguous. " 76 "Define MIRA_SERIALIZATION_DISABLE_DETECT_REFLECT to skip MIRA's compile-time check " 77 "and see all candidates considered " 78 "(warning: will probably result in much more messy error message).");
79 static void invoke() {}
83 namespace serialization {
164 template <
typename Derived>
175 template <
typename T>
178 checkVersion<T>(v, minVersion,
false);
182 MIRA_DEPRECATED(
"Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)",
185 checkVersion(v, minVersion);
190 template <
typename T>
192 requireVersion<T>(requiredVersion, requiredVersion);
195 MIRA_DEPRECATED(
"Please call as requireVersion<MyType>(v) or requireVersion(v, this)",
203 template <
typename T>
207 checkVersion<T>(v, minVersion,
true);
212 template <
typename T>
219 template <
typename T>
222 MIRA_THROW(XIO, (potentiallyDesired ?
"Found or desired " :
"Found ") <<
223 "version for type '" << typeName<T>() <<
224 "': " << (
int)
version <<
", but require " 225 "at least version: " << (
int)minVersion);
231 ", but require at least version: " << (
int)minVersion);
237 template <
typename Base>
254 return static_cast<Derived*
>(
this);
266 this->
This()->invokeOverwrite(
object);
278 using namespace serialization;
281 #ifdef MIRA_SERIALIZATION_DISABLE_DETECT_REFLECT 282 typedef std::true_type hasNonMemberReflect;
287 boost::mpl::eval_if<hasMemberReflect,
288 boost::mpl::identity< ReflectComplexIntrusive >,
290 boost::mpl::eval_if<hasNonMemberReflect,
291 boost::mpl::identity< ReflectComplexNonintrusive >,
293 boost::mpl::identity< ReflectMissing >
297 chosen_reflect::invoke(*this->
This(),
object);
305 static void invoke(Derived& r, T&
object) {
307 TwithoutConst& nonconstObject =
const_cast<TwithoutConst&
>(object);
308 nonconstObject.reflect(r);
322 static void invoke(Derived& r, T&
object) {
329 reflect(r, const_cast<TwithoutConst&>(
object));
335 static void invoke(Derived& r, T&
object) {
337 mira::detail::____MISSING_REFLECT_METHOD_FOR_<TwithoutConst>::invoke();
346 #endif // _MIRA_ABSTRACTREFLECTOR_H_ void requireVersion(VersionType requiredVersion, const T *caller=NULL)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:191
static void invoke(Derived &r, T &object)
Definition: AbstractReflector.h:335
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
ReflectorInterface< Derived >::VersionType VersionType
Definition: AbstractReflector.h:170
void invokeOverwrite(T &object)
The actual invoke implementation, that may also be overwritten in derived classes to add additional f...
Definition: AbstractReflector.h:276
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
#define MIRA_HAS_NONMEMBER_FUNCTION2(Identifier, ParamType0, ParamType1)
Macro checking the existence of a free function with specific parameter+return types.
Definition: HasNonMember.h:182
MIRA_DEPRECATED("Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)", VersionType requireVersion(VersionType version, VersionType minVersion))
Definition: AbstractReflector.h:182
void requireVersion(VersionType requiredVersion, AcceptDesiredVersion, const T *caller=NULL)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:213
Definition: AbstractReflector.h:333
MIRA_DEPRECATED("Please call as requireVersion<MyType>(v) or requireVersion(v, this)", void requireVersion(VersionType requiredVersion))
Definition: AbstractReflector.h:195
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:81
This is the public interface of all reflectors that are able to visit a class' reflect() method...
Definition: ReflectorInterface.h:111
Derived * This()
"Curiously recurring template pattern" (CRTP).
Definition: AbstractReflector.h:251
Abstract base class for most Reflectors.
Definition: AbstractReflector.h:165
Contains the base interface of all Reflectors, Serializers, etc.
#define MIRA_HAS_MEMBER_TEMPLATE(Class, Identifier)
Definition: HasMember.h:140
#define MIRA_NONMEMBER_FUNCTION2_DETECTOR(ReturnType, FunctionName)
Definition: HasNonMember.h:111
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
VersionType requireVersion(VersionType version, VersionType minVersion, AcceptDesiredVersion, const T *caller=NULL)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:204
Tag class used as parameter to ReflectorInterface::version() etc.
Definition: ReflectorInterface.h:80
ReflectorInterface< Derived >::AcceptDesiredVersion AcceptDesiredVersion
Definition: AbstractReflector.h:200
void reflect(Reflector &r, LogRecord &record)
Non-intrusive reflector for LogRecord.
Definition: LoggingCore.h:136
MIRA_MEMBER_DETECTOR(mNoPublicDefaultConstructor)
static void invoke(Derived &r, T &object)
Definition: AbstractReflector.h:305
For classes with reflect method call their reflect method directly.
Definition: AbstractReflector.h:303
void reflectBase(Base &base)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:238
serialization::VersionType VersionType
Definition: ReflectorInterface.h:194
Macros for checking the existence of non-member functions.
Macros for checking the existence of class members.
For classes without reflect method, where we need to look somewhere else to get the information for v...
Definition: AbstractReflector.h:320
static void invoke(Derived &r, T &object)
Definition: AbstractReflector.h:322
VersionType requireVersion(VersionType version, VersionType minVersion, const T *caller=NULL)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:176
void invoke(T &object)
Invokes this reflector on the specified object.
Definition: AbstractReflector.h:264