IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
ProcessorHdrDetailsMacros.h
Go to the documentation of this file.
1 // ProcessorHdrDetailsMacros.h:
3 // ----------------------------
4 //
14 
15 #ifndef __IPSDKBASEPROCESSING_PROCESSORHDRDETAILSMACROS_H__
16 #define __IPSDKBASEPROCESSING_PROCESSORHDRDETAILSMACROS_H__
17 
19 #include <IPSDKBaseData/Range/ElementsRange.h>
21 #include <IPSDKBaseProcessing/Processor/Instances/BaseSyncProcessor.h>
22 #include <IPSDKBaseProcessing/Processor/Instances/BaseAsync1Processor.h>
23 #include <IPSDKBaseProcessing/Processor/Instances/BaseAsync2Processor.h>
24 #include <IPSDKBaseProcessing/Processor/Instances/BaseAsync3Processor.h>
25 #include <IPSDKBaseProcessing/Processor/Instances/BaseAsync4Processor.h>
26 #include <IPSDKBaseProcessing/Processor/Instances/BaseIterativeAsync1Processor.h>
27 #include <IPSDKBaseProcessing/Processor/Instances/BaseIterativeAsync2Processor.h>
28 #include <IPSDKBaseProcessing/Processor/Instances/BaseRepeatedAsync1Processor.h>
29 #include <IPSDKBaseProcessing/Processor/Instances/BaseRepeatedAsync2Processor.h>
33 #include <boost/mpl/if.hpp>
34 #include <boost/type_traits/is_same.hpp>
35 #include <boost/static_assert.hpp>
36 #include <boost/make_shared.hpp>
37 
40 
43 #define IPSDK_PROCESSOR_INIT_ATTRIBUTE_START_MACRO(s, _, n, AttributeInfo) \
44  typename boost::mpl::if_c<boost::is_same< \
45  IPSDK_NAMESPACE_NAME(BOOST_PP_SEQ_ELEM(0, AttributeInfo)) \
46  BOOST_PP_SEQ_ELEM(1, AttributeInfo), TAttribute>::value, \
47  BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, AttributeInfo), Access),
48 
51 #define IPSDK_PROCESSOR_INIT_ATTRIBUTE_END_MACRO(s, _, AttributeInfo) \
52  >::type
53 
56 #define IPSDK_PROCESSOR_ACCESS_ATTRIBUTE(attributeSeq) \
57  typedef \
58  BOOST_PP_SEQ_FOR_EACH_I(IPSDK_PROCESSOR_INIT_ATTRIBUTE_START_MACRO, \
59  _, attributeSeq) \
60  AccessError<TAttribute> \
61  BOOST_PP_SEQ_FOR_EACH(IPSDK_PROCESSOR_INIT_ATTRIBUTE_END_MACRO, \
62  _, attributeSeq) \
63  ResultType;
64 
68 #define IPSDK_PROCESSOR_ACCESS_NO_ATTRIBUTE() \
69  typedef AccessError ResultType;
70 
73 #define IPSDK_DECLARE_PROCESSOR_STRUCT_ACCESS_ATTRIBUTE_MACRO(s, className, n, AttributeInfo) \
74 protected: \
75  struct BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, AttributeInfo), Access) \
76  { \
77  typedef IPSDK_NAMESPACE_NAME(BOOST_PP_SEQ_ELEM(0, AttributeInfo)) \
78  BOOST_PP_SEQ_ELEM(1, AttributeInfo) AttributeType; \
79  static void setAttribute(className& object, const AttributeType::StorageType& value) \
80  { \
81  BOOST_PP_CAT(object._p, BOOST_PP_SEQ_ELEM(1, AttributeInfo))->init(value); \
82  } \
83  template <typename TAttribute, typename Enable = void> \
84  struct AttributeValueSetter \
85  { \
86  static void set(className& object, const typename TAttribute::ValueType& value) {} \
87  }; \
88  template <typename TAttribute> \
89  struct AttributeValueSetter<TAttribute, \
90  typename boost::enable_if_c<TAttribute::g_hasValueInit, void>::type> \
91  { \
92  static void set(className& object, const typename TAttribute::ValueType& value) { \
93  BOOST_PP_CAT(object._p, BOOST_PP_SEQ_ELEM(1, AttributeInfo))->init(value); \
94  } \
95  }; \
96  static void setAttributeValue(className& object, const AttributeType::ValueType& value) \
97  { \
98  AttributeValueSetter<AttributeType>::set(object, value); \
99  } \
100  static const AttributeType& getAttribute(const className& object) { \
101  return *BOOST_PP_CAT(object._p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)); \
102  } \
103  static AttributeType& getAttribute(className& object) { \
104  return *BOOST_PP_CAT(object._p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)); \
105  } \
106  };
107 
110 #define IPSDK_DECLARE_PROCESSOR_ATTRIBUTE_MACRO(s, _, n, AttributeInfo) \
111 protected: \
112  boost::shared_ptr<IPSDK_NAMESPACE_NAME(BOOST_PP_SEQ_ELEM(0, AttributeInfo)) \
113  BOOST_PP_SEQ_ELEM(1, AttributeInfo)> \
114  BOOST_PP_CAT(_p, BOOST_PP_SEQ_ELEM(1, AttributeInfo));
115 
118 #define IPSDK_DECLARE_PROCESSOR_INITIALIZER_MACRO(s, _, AttributeInfo) \
119 protected: \
120  BOOST_PP_IF(BOOST_PP_SUB(BOOST_PP_SEQ_SIZE(AttributeInfo), 2), \
121  ipsdk::processor::OutputInitializerPtr \
122  BOOST_PP_CAT(BOOST_PP_CAT(_p, \
123  BOOST_PP_SEQ_ELEM(1, AttributeInfo)),Initializer); \
124  , )
125 
128 #define IPSDK_PROCESSOR_ENUM_ATTRIBUTES_TYPE_MACRO(s, _, n, AttributeInfo) \
129  BOOST_PP_COMMA_IF(n) \
130  IPSDK_NAMESPACE_NAME(BOOST_PP_SEQ_ELEM(0, AttributeInfo)) \
131  BOOST_PP_SEQ_ELEM(1, AttributeInfo)
132 
136 #define IPSDK_PROCESSOR_DECLARE_ATTRIBUTES_TYPE_MACRO(s, _, n, AttributeInfo) \
137  typedef IPSDK_NAMESPACE_NAME(BOOST_PP_SEQ_ELEM(0, AttributeInfo)) \
138  BOOST_PP_SEQ_ELEM(1, AttributeInfo) \
139  BOOST_PP_SEQ_ELEM(1, AttributeInfo);
140 
143 #define IPSDK_REGISTER_PROCESSOR_ATTRIBUTE_MACRO(s, _, n, AttributeInfo) \
144  BOOST_PP_CAT(_p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)) = \
145  boost::make_shared< \
146  IPSDK_NAMESPACE_NAME(BOOST_PP_SEQ_ELEM(0, AttributeInfo)) \
147  BOOST_PP_SEQ_ELEM(1, AttributeInfo)>(); \
148  attributeColl.push_back(BOOST_PP_CAT(_p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)));
149 
152 #define IPSDK_REGISTER_PROCESSOR_OUT_INITIALIZER(AttributeInfo) \
153  {BOOST_STATIC_ASSERT_MSG(IPSDK_NAMESPACE_NAME(BOOST_PP_SEQ_ELEM(0, AttributeInfo)) \
154  BOOST_PP_SEQ_ELEM(1, AttributeInfo)::g_bOutput == true, \
155  "Output initializer should only be defined on output attributes");} \
156  BOOST_PP_CAT(BOOST_PP_CAT(_p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)),Initializer) = \
157  BOOST_PP_SEQ_ELEM(2, AttributeInfo)( \
158  BOOST_PP_SEQ_ENUM((BOOST_PP_CAT(_p, BOOST_PP_SEQ_ELEM(1, AttributeInfo))) \
159  BOOST_PP_IF(BOOST_PP_GREATER(BOOST_PP_SEQ_SIZE(AttributeInfo), 3), \
160  BOOST_PP_SEQ_REST_N( \
161  BOOST_PP_MIN(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(AttributeInfo)), 3), \
162  AttributeInfo),))); \
163  outputInitializerColl.insert(std::make_pair( \
164  BOOST_PP_CAT(_p, BOOST_PP_SEQ_ELEM(1, AttributeInfo))->getObjectName(), \
165  BOOST_PP_CAT(BOOST_PP_CAT(_p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)),Initializer)));
166 
169 #define IPSDK_REGISTER_PROCESSOR_INITIALIZER_MACRO(s, _, n, AttributeInfo) \
170  BOOST_PP_IF(BOOST_PP_SUB(BOOST_PP_SEQ_SIZE(AttributeInfo), 2), \
171  IPSDK_REGISTER_PROCESSOR_OUT_INITIALIZER, \
172  BOOST_PP_TUPLE_EAT(1))(AttributeInfo)
173 
176 #define IPSDK_DECLARE_PROCESSOR_ATTRIBUTES(className, attributeSeq) \
177 protected: \
178  template <typename TAttribute> \
179  struct AccessError \
180  { \
181  static void setAttribute(className& object, \
182  const typename TAttribute::StorageType& value) \
183  { \
184  BOOST_STATIC_ASSERT_MSG(sizeof(TAttribute) == 0, \
185  "Invalid attribute type for initialization"); \
186  } \
187  static void setAttributeValue(className& object, \
188  const typename TAttribute::ValueType& value) \
189  { \
190  BOOST_STATIC_ASSERT_MSG(sizeof(TAttribute) == 0, \
191  "Invalid attribute type for initialization"); \
192  } \
193  static const TAttribute& getAttribute(const className& object) { \
194  BOOST_STATIC_ASSERT_MSG(sizeof(TAttribute) == 0, \
195  "Invalid attribute type for getAttribute"); \
196  } \
197  }; \
198  BOOST_PP_SEQ_FOR_EACH_I(IPSDK_DECLARE_PROCESSOR_STRUCT_ACCESS_ATTRIBUTE_MACRO, \
199  className, attributeSeq) \
200 public: \
201  typedef ipsdk::processor::AttributeCollInfo< \
202  BOOST_PP_SEQ_FOR_EACH_I(IPSDK_PROCESSOR_ENUM_ATTRIBUTES_TYPE_MACRO, _, \
203  attributeSeq) > AttributesInfo; \
204  BOOST_PP_SEQ_FOR_EACH_I(IPSDK_PROCESSOR_DECLARE_ATTRIBUTES_TYPE_MACRO, _, attributeSeq) \
205  template <typename TAttribute> \
206  void set(const typename TAttribute::StorageType& value) { \
207  IPSDKBASEPROCESSING_CHECK(isInit() == true, \
208  [ipsdk::processor::eProcessorMessage::eProcessorNotInit] %\
209  getObjectName()); \
210  BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(attributeSeq(nil))), \
211  IPSDK_PROCESSOR_ACCESS_ATTRIBUTE, \
212  IPSDK_PROCESSOR_ACCESS_NO_ATTRIBUTE)(attributeSeq); \
213  ResultType::setAttribute(*this, value); \
214  } \
215  template <typename TAttribute> \
216  typename boost::enable_if_c<TAttribute::g_hasValueInit, void>::type \
217  set(const typename TAttribute::ValueType& value) { \
218  IPSDKBASEPROCESSING_CHECK(isInit() == true, \
219  [ipsdk::processor::eProcessorMessage::eProcessorNotInit] %\
220  getObjectName()); \
221  BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(attributeSeq(nil))), \
222  IPSDK_PROCESSOR_ACCESS_ATTRIBUTE, \
223  IPSDK_PROCESSOR_ACCESS_NO_ATTRIBUTE)(attributeSeq); \
224  ResultType::setAttributeValue(*this, value); \
225  } \
226  template <typename TAttribute> \
227  const TAttribute& get() const { \
228  IPSDKBASEPROCESSING_CHECK(isInit() == true, \
229  [ipsdk::processor::eProcessorMessage::eProcessorNotInit] %\
230  getObjectName()); \
231  BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(attributeSeq(nil))), \
232  IPSDK_PROCESSOR_ACCESS_ATTRIBUTE, \
233  IPSDK_PROCESSOR_ACCESS_NO_ATTRIBUTE)(attributeSeq); \
234  return ResultType::getAttribute(*this); \
235  } \
236  template <typename TAttribute> \
237  typename boost::enable_if_c<TAttribute::g_bOutput, \
238  typename TAttribute::StorageType>::type \
239  getStorage() { \
240  IPSDKBASEPROCESSING_CHECK(isInit() == true, \
241  [ipsdk::processor::eProcessorMessage::eProcessorNotInit] %\
242  getObjectName()); \
243  BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(attributeSeq(nil))), \
244  IPSDK_PROCESSOR_ACCESS_ATTRIBUTE, \
245  IPSDK_PROCESSOR_ACCESS_NO_ATTRIBUTE)(attributeSeq); \
246  return ResultType::getAttribute(*this).getStorage(); \
247  } \
248  BOOST_PP_SEQ_FOR_EACH_I(IPSDK_DECLARE_PROCESSOR_ATTRIBUTE_MACRO, _, attributeSeq) \
249  BOOST_PP_SEQ_FOR_EACH(IPSDK_DECLARE_PROCESSOR_INITIALIZER_MACRO, _, attributeSeq) \
250 private: \
251  void initAttributeColl(AttributeColl& attributeColl, \
252  OutputInitializerColl& outputInitializerColl) { \
253  attributeColl.clear(); \
254  BOOST_PP_SEQ_FOR_EACH_I(IPSDK_REGISTER_PROCESSOR_ATTRIBUTE_MACRO, _, attributeSeq) \
255  outputInitializerColl.clear(); \
256  BOOST_PP_SEQ_FOR_EACH_I(IPSDK_REGISTER_PROCESSOR_INITIALIZER_MACRO, _, attributeSeq)\
257  }
258 
261 #define IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
262  IPSDK_DECLARE_ACTION(libraryName, className) \
263  friend class ipsdk::processor::ProcessorFactory; \
264 public: \
265  static boost::shared_ptr<className> createProcessor(); \
266 protected: \
267  static ipsdk::processor::ProcessorPtr createBaseProcessor(); \
268 protected: \
269  className(); \
270 public: \
271  ~className(); \
272 public: \
273  static const ipsdk::processor::ProcessorDispatchPolicy& getDefaultDispatchPolicy(); \
274 protected: \
275  ipsdk::BoolResult initDerived(AttributeColl& attributeColl, \
276  OutputInitializerColl& outputInitializerColl, \
277  ipsdk::processor::ProcessorDispatchPolicy& dispatchPolicy, \
278  ipsdk::processor::RulePtr& pGlobalRule, \
279  const ipsdk::processor::eProcessorRulePolicy& rulePolicy); \
280 private: \
281  ipsdk::processor::RulePtr createRule() const { \
282  ipsdk::processor::RulePtr pRule = RuleString; \
283  return pRule; \
284  } \
285  IPSDK_DECLARE_PROCESSOR_ATTRIBUTES(className, attributeSeq)
286 
289 
292 #define IPSDK_DECLARE_SYNC_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
293  class IPSDK_LIB_API(libraryName) className : \
294  public ipsdk::processor::BaseSyncProcessor { \
295  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
296 protected: \
297  ipsdk::core::ExecResult mainProcess();
298 
302 #define IPSDK_DECLARE_ASYNC1_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
303  class IPSDK_LIB_API(libraryName) className : \
304  public ipsdk::processor::BaseAsync1Processor { \
305  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
306 protected: \
307  ipsdk::processor::RetrievalResult \
308  retrieveProvider(const ipsdk::core::BasePriority& priority, \
309  ipsdk::core::ActionProviderPtr& pProvider);
310 
314 #define IPSDK_DECLARE_ASYNC2_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
315  class IPSDK_LIB_API(libraryName) className : \
316  public ipsdk::processor::BaseAsync2Processor { \
317  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
318 protected: \
319  ipsdk::processor::RetrievalResult \
320  retrieveFirstProvider(const ipsdk::core::BasePriority& priority, \
321  ipsdk::core::ActionProviderPtr& pProvider); \
322  ipsdk::processor::RetrievalResult \
323  retrieveSecondProvider(const ipsdk::core::BasePriority& priority, \
324  ipsdk::core::ActionProviderPtr& pProvider);
325 
329 #define IPSDK_DECLARE_ASYNC3_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
330  class IPSDK_LIB_API(libraryName) className : \
331  public ipsdk::processor::BaseAsync3Processor { \
332  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
333 protected: \
334  ipsdk::processor::RetrievalResult \
335  retrieveFirstProvider(const ipsdk::core::BasePriority& priority, \
336  ipsdk::core::ActionProviderPtr& pProvider); \
337  ipsdk::processor::RetrievalResult \
338  retrieveSecondProvider(const ipsdk::core::BasePriority& priority, \
339  ipsdk::core::ActionProviderPtr& pProvider); \
340  ipsdk::processor::RetrievalResult \
341  retrieveThirdProvider(const ipsdk::core::BasePriority& priority, \
342  ipsdk::core::ActionProviderPtr& pProvider);
343 
347 #define IPSDK_DECLARE_ASYNC4_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
348  class IPSDK_LIB_API(libraryName) className : \
349  public ipsdk::processor::BaseAsync4Processor { \
350  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
351 protected: \
352  ipsdk::processor::RetrievalResult \
353  retrieveFirstProvider(const ipsdk::core::BasePriority& priority, \
354  ipsdk::core::ActionProviderPtr& pProvider); \
355  ipsdk::processor::RetrievalResult \
356  retrieveSecondProvider(const ipsdk::core::BasePriority& priority, \
357  ipsdk::core::ActionProviderPtr& pProvider); \
358  ipsdk::processor::RetrievalResult \
359  retrieveThirdProvider(const ipsdk::core::BasePriority& priority, \
360  ipsdk::core::ActionProviderPtr& pProvider); \
361  ipsdk::processor::RetrievalResult \
362  retrieveFourthProvider(const ipsdk::core::BasePriority& priority, \
363  ipsdk::core::ActionProviderPtr& pProvider);
364 
368 #define IPSDK_DECLARE_ITER_ASYNC1_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
369  class IPSDK_LIB_API(libraryName) className : \
370  public ipsdk::processor::BaseIterativeAsync1Processor { \
371  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
372 protected: \
373  ipsdk::ipUInt32 retrieveNbIter(); \
374  ipsdk::processor::RetrievalResult \
375  retrieveProvider(const ipsdk::core::BasePriority& priority, \
376  const ipsdk::ipUInt32 curNbIter, \
377  ipsdk::core::ActionProviderPtr& pProvider);
378 
382 #define IPSDK_DECLARE_ITER_ASYNC2_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
383  class IPSDK_LIB_API(libraryName) className : \
384  public ipsdk::processor::BaseIterativeAsync2Processor { \
385  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
386 protected: \
387  ipsdk::ipUInt32 retrieveNbIter(); \
388  ipsdk::processor::RetrievalResult \
389  retrieveFirstProvider(const ipsdk::core::BasePriority& priority, \
390  const ipsdk::ipUInt32 curNbIter, \
391  ipsdk::core::ActionProviderPtr& pProvider); \
392  ipsdk::processor::RetrievalResult \
393  retrieveSecondProvider(const ipsdk::core::BasePriority& priority, \
394  const ipsdk::ipUInt32 curNbIter, \
395  ipsdk::core::ActionProviderPtr& pProvider);
396 
400 #define IPSDK_DECLARE_REP_ASYNC1_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
401  class IPSDK_LIB_API(libraryName) className : \
402  public ipsdk::processor::BaseRepeatedAsync1Processor { \
403  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
404 protected: \
405  ipsdk::processor::RetrievalResult \
406  retrieveProvider(const ipsdk::core::BasePriority& priority, \
407  const ipsdk::ipUInt32 curNbIter, \
408  ipsdk::core::ActionProviderPtr& pProvider);
409 
413 #define IPSDK_DECLARE_REP_ASYNC2_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
414  class IPSDK_LIB_API(libraryName) className : \
415  public ipsdk::processor::BaseRepeatedAsync2Processor { \
416  IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \
417 protected: \
418  ipsdk::processor::RetrievalResult \
419  retrieveFirstProvider(const ipsdk::core::BasePriority& priority, \
420  const ipsdk::ipUInt32 curNbIter, \
421  ipsdk::core::ActionProviderPtr& pProvider); \
422  ipsdk::processor::RetrievalResult \
423  retrieveSecondProvider(const ipsdk::core::BasePriority& priority, \
424  const ipsdk::ipUInt32 curNbIter, \
425  ipsdk::core::ActionProviderPtr& pProvider);
426 
429 
433 #define IPSDK_DECLARE_STATIC_RESULT_COLL(AttributeType, CollType) \
434  typedef std::map<ipsdk::ipUInt32, AttributeType::StorageType> CollType; \
435  boost::shared_ptr<CollType> BOOST_PP_CAT(_p, CollType);
436 
440 #define IPSDK_DECLARE_DYNAMIC_RESULT_COLL(AttributeType, CollType) \
441  typedef std::map<ipsdk::ElementsRange, AttributeType::StorageType> CollType; \
442  boost::shared_ptr<CollType> BOOST_PP_CAT(_p, CollType);
443 
446 
447 #endif // __IPSDKBASEPROCESSING_PROCESSORHDRDETAILSMACROS_H__
Header part of macros set for action class declaration.
Macro set for template class manipulation.
Logger api for library IPSDKBaseProcessing.
Macros set allowing to manage an attribute collection information.
Log messages description.