JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
parametermacros.C
Go to the documentation of this file.
1 
2 // Convenience macro to define a Parameter type. All the ... args are passed to ParameterDef
3 #define JEVOIS_DECLARE_PARAMETER(ParamName, ParamType, ...) \
4  struct ParamName : public virtual jevois::ParameterRegistry, public jevois::ParameterCore<ParamType> \
5  { \
6  typedef ParamType type; \
7  \
8  inline ParamName() : jevois::ParameterCore<ParamType>(jevois::ParameterDef<ParamType>(#ParamName, __VA_ARGS__)) \
9  { jevois::ParameterRegistry::addParameter(this); } \
10  \
11  inline virtual ~ParamName() \
12  { jevois::ParameterRegistry::removeParameter(this); } \
13  \
14  inline virtual jevois::Component const * owner() const override \
15  { return dynamic_cast<jevois::Component const *>(static_cast<jevois::ParameterRegistry const *>(this)); } \
16  };
17 
18 // Convenience macro to define a Parameter type with callback. All the ... args are passed to ParameterDef
19 #define JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(ParamName, ParamType, ...) \
20  struct ParamName : public virtual jevois::ParameterRegistry, public jevois::ParameterCore<ParamType> \
21  { \
22  typedef ParamType type; \
23  \
24  virtual void onParamChange(ParamName const & param, ParamType const & newval) = 0; \
25  \
26  inline ParamName() : jevois::ParameterCore<ParamType>(jevois::ParameterDef<ParamType>(#ParamName, __VA_ARGS__)) \
27  { setCallback([this](ParamType const & newval) { this->onParamChange(*this, newval); }); \
28  jevois::ParameterRegistry::addParameter(this); } \
29  \
30  inline virtual ~ParamName() \
31  { jevois::ParameterRegistry::removeParameter(this); } \
32  \
33  inline virtual jevois::Component const * owner() const override \
34  { return dynamic_cast<jevois::Component const *>(static_cast<jevois::ParameterRegistry const *>(this)); } \
35  };
36