MIRA
Classes | Namespaces | Macros
ReflectorMacros.h File Reference

Macros for use with reflectors. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ReflectCallHelper< Reflector >
 
struct  ReflectCallHelper< Reflector >::__ReflectBarrier
 
struct  ReflectCallHelper< Reflector >::__NoReflectBarrier
 

Namespaces

 mira
 specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
 
 mira::serialization
 

Macros

#define MIRA_REFLECT_CALL(ReflectorType, reflector, context, COMMAND)
 Whenever a reflection function calls another function that is independently maintained, the call should be marked to the reflector. More...
 

Detailed Description

Macros for use with reflectors.

Author
Christof Schröter
Date
2019/01/11

Macro Definition Documentation

◆ MIRA_REFLECT_CALL

#define MIRA_REFLECT_CALL (   ReflectorType,
  reflector,
  context,
  COMMAND 
)
Value:
{ \
typedef typename serialization::ReflectCallHelper<ReflectorType>::BarrierType type; \
\
typename ReflectorType::ReflectState state = type::preCommand(reflector, context); \
COMMAND; \
type::postCommand(reflector, state); \
}
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295

Whenever a reflection function calls another function that is independently maintained, the call should be marked to the reflector.

The reflector will then regard these as separate reflection blocks and keep a separate state for them. E.g. the BinarySerializer can allow these blocks to have separate reflection versions and will make sure these version numbers are correctly serialized (and deserialized later). Without making the reflector aware, it might know only one state for these different blocks, e.g. the BinarySerializer would potentially assume a version is reported twice for the same object (possibly with different version numbers!), and throw an exception. MIRA_REFLECT_CALL is used to insert the code required to mark the start and end of a call to a separate reflection function to the reflector. It can thus be seen as a generalization of the concept of using reflectBase()/MIRA_REFLECT_BASE instead of calling Base::reflect() directly.

template<typename Reflector>
void reflectMyStruct(Reflector& r, MyStruct& c) {
{
MIRA_REFLECT_CALL(Reflector, r, "MyStruct someReflectMethod", (someReflectMethod(r, c)));
}

context must be a const char* that must persist until after postCommand (e.g. use a string literal or create a static const string).