47 #ifndef _MIRA_ABSTRACTREFLECTOR_H_ 48 #define _MIRA_ABSTRACTREFLECTOR_H_ 62 struct ____MISSING_REFLECT_METHOD_FOR_{
63 static_assert(
sizeof(Type)==0,
64 "Cannot find an (unambiguous) intrusive or nonintrusive reflect method for Type. " 65 "If Type is a class that you have implemented, then you should " 66 "implement its reflect() method. If Type is a common class or " 67 "container from an external library (including std, boost, etc.), you " 68 "probably need to include an adapter header " 69 "like #include <serialization/adapters/std/vector>. \nNote: " 70 "If you are sure a matching reflect() method exists, it might be ambiguous. " 71 "Define MIRA_SERIALIZATION_DISABLE_DETECT_REFLECT to skip MIRA's compile-time check " 72 "and see all candidates considered " 73 "(warning: will probably result in much more messy error message).");
74 static void invoke() {}
78 namespace serialization {
159 template <
typename Derived>
170 template <
typename T>
173 checkVersion<T>(v, minVersion,
false);
177 MIRA_DEPRECATED(
"Please call as requireVersion<MyType>(v, minV) or requireVersion(v, minV, this)",
180 checkVersion(v, minVersion);
185 template <
typename T>
187 requireVersion<T>(requiredVersion, requiredVersion);
190 MIRA_DEPRECATED(
"Please call as requireVersion<MyType>(v) or requireVersion(v, this)",
198 template <
typename T>
202 checkVersion<T>(v, minVersion,
true);
207 template <
typename T>
214 template <
typename T>
217 MIRA_THROW(XIO, (potentiallyDesired ?
"Found or desired " :
"Found ") <<
218 "version for type '" << typeName<T>() <<
219 "': " << (
int)
version <<
", but require " 220 "at least version: " << (
int)minVersion);
226 ", but require at least version: " << (
int)minVersion);
232 template <
typename Base>
249 return static_cast<Derived*
>(
this);
261 this->
This()->invokeOverwrite(
object);
273 using namespace serialization;
276 #ifdef MIRA_SERIALIZATION_DISABLE_DETECT_REFLECT 277 typedef std::true_type hasNonMemberReflect;
281 if constexpr (hasMemberReflect::value) {
284 else if constexpr (hasNonMemberReflect::value) {
299 auto& nonconstObject =
const_cast<TwithoutConst&
>(object);
300 nonconstObject.reflect(*(this->
This()));
320 reflect(*(this->
This()), const_cast<TwithoutConst&>(
object));
327 mira::detail::____MISSING_REFLECT_METHOD_FOR_<TwithoutConst>::invoke();
335 #endif // _MIRA_ABSTRACTREFLECTOR_H_ void reflectMissing(T &object)
Definition: AbstractReflector.h:324
void requireVersion(VersionType requiredVersion, const T *caller=NULL)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:186
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 invokeOverwrite(T &object)
The actual invoke implementation, that may also be overwritten in derived classes to add additional f...
Definition: AbstractReflector.h:271
typename ReflectorInterface< PropertySerializer >::AcceptDesiredVersion AcceptDesiredVersion
Definition: AbstractReflector.h:195
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:177
void requireVersion(VersionType requiredVersion, AcceptDesiredVersion, const T *caller=NULL)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:208
MIRA_DEPRECATED("Please call as requireVersion<MyType>(v) or requireVersion(v, this)", void requireVersion(VersionType requiredVersion))
Definition: AbstractReflector.h:190
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
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:246
void reflectComplexNonintrusive(T &object)
For classes without reflect method, where we need to look somewhere else to get the information for v...
Definition: AbstractReflector.h:312
Abstract base class for most Reflectors.
Definition: AbstractReflector.h:160
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:199
Tag class used as parameter to ReflectorInterface::version() etc.
Definition: ReflectorInterface.h:80
void reflect(Reflector &r, LogRecord &record)
Non-intrusive reflector for LogRecord.
Definition: LoggingCore.h:137
MIRA_MEMBER_DETECTOR(mNoPublicDefaultConstructor)
typename ReflectorInterface< PropertySerializer >::VersionType VersionType
Definition: AbstractReflector.h:165
void reflectBase(Base &base)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:233
void reflectComplexIntrusive(T &object)
For classes with reflect method call their reflect method directly.
Definition: AbstractReflector.h:296
serialization::VersionType VersionType
Definition: ReflectorInterface.h:194
Macros for checking the existence of non-member functions.
Macros for checking the existence of class members.
VersionType requireVersion(VersionType version, VersionType minVersion, const T *caller=NULL)
implements ReflectorInterface (for documentation see ReflectorInterface)
Definition: AbstractReflector.h:171
void invoke(T &object)
Invokes this reflector on the specified object.
Definition: AbstractReflector.h:259