ObserverMacros.h File Reference
#include <mc_observers/Observer.h>
#include <mc_rtc/version.h>
Include dependency graph for ObserverMacros.h:

Go to the source code of this file.

Macros

#define OBSERVER_MODULE_CHECK_VERSION(NAME)
 
#define EXPORT_OBSERVER_MODULE(NAME, TYPE)
 

Macro Definition Documentation

◆ EXPORT_OBSERVER_MODULE

#define EXPORT_OBSERVER_MODULE (   NAME,
  TYPE 
)
Value:
extern "C" \
{ \
OBSERVER_MODULE_API void MC_RTC_OBSERVER_MODULE(std::vector<std::string> & names) \
{ \
OBSERVER_MODULE_CHECK_VERSION(NAME) \
names = {NAME}; \
} \
OBSERVER_MODULE_API void destroy(mc_observers::Observer * ptr) \
{ \
delete ptr; \
} \
OBSERVER_MODULE_API unsigned int create_args_required() \
{ \
return 2; \
} \
OBSERVER_MODULE_API mc_observers::Observer * create(const std::string & type, const double & dt) \
{ \
return new TYPE{type, dt}; \
} \
}

◆ OBSERVER_MODULE_CHECK_VERSION

#define OBSERVER_MODULE_CHECK_VERSION (   NAME)
Value:
if(mc_rtc::MC_RTC_VERSION != mc_rtc::version()) \
{ \
"{} was compiled with {} but mc_rtc is currently at version {}, you might experience subtle issues and " \
"should recompile your code", \
NAME, mc_rtc::MC_RTC_VERSION, mc_rtc::version()); \
}

A simple compile-time versus run-time version checking macro

If you are not relying on EXPORT_OBSERVER_MODULE you should use this in your MC_RTC_OBSERVER_MODULE implementation

mc_observers::Observer
State observation API.
Definition: Observer.h:50
mc_rtc::log::error
void error(Args &&... args)
Definition: logging.h:63