15 #ifndef __IPSDKBASEPROCESSING_PROCESSORHDRDETAILSMACROS_H__ 16 #define __IPSDKBASEPROCESSING_PROCESSORHDRDETAILSMACROS_H__ 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> 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), 51 #define IPSDK_PROCESSOR_INIT_ATTRIBUTE_END_MACRO(s, _, AttributeInfo) \ 56 #define IPSDK_PROCESSOR_ACCESS_ATTRIBUTE(attributeSeq) \ 58 BOOST_PP_SEQ_FOR_EACH_I(IPSDK_PROCESSOR_INIT_ATTRIBUTE_START_MACRO, \ 60 AccessError<TAttribute> \ 61 BOOST_PP_SEQ_FOR_EACH(IPSDK_PROCESSOR_INIT_ATTRIBUTE_END_MACRO, \ 68 #define IPSDK_PROCESSOR_ACCESS_NO_ATTRIBUTE() \ 69 typedef AccessError ResultType; 73 #define IPSDK_DECLARE_PROCESSOR_STRUCT_ACCESS_ATTRIBUTE_MACRO(s, className, n, AttributeInfo) \ 75 struct BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, AttributeInfo), Access) \ 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) \ 81 BOOST_PP_CAT(object._p, BOOST_PP_SEQ_ELEM(1, AttributeInfo))->init(value); \ 83 template <typename TAttribute, typename Enable = void> \ 84 struct AttributeValueSetter \ 86 static void set(className& object, const typename TAttribute::ValueType& value) {} \ 88 template <typename TAttribute> \ 89 struct AttributeValueSetter<TAttribute, \ 90 typename boost::enable_if_c<TAttribute::g_hasValueInit, void>::type> \ 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); \ 96 static void setAttributeValue(className& object, const AttributeType::ValueType& value) \ 98 AttributeValueSetter<AttributeType>::set(object, value); \ 100 static const AttributeType& getAttribute(const className& object) { \ 101 return *BOOST_PP_CAT(object._p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)); \ 103 static AttributeType& getAttribute(className& object) { \ 104 return *BOOST_PP_CAT(object._p, BOOST_PP_SEQ_ELEM(1, AttributeInfo)); \ 110 #define IPSDK_DECLARE_PROCESSOR_ATTRIBUTE_MACRO(s, _, n, AttributeInfo) \ 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)); 118 #define IPSDK_DECLARE_PROCESSOR_INITIALIZER_MACRO(s, _, AttributeInfo) \ 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); \ 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) 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); 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))); 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))); 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) 176 #define IPSDK_DECLARE_PROCESSOR_ATTRIBUTES(className, attributeSeq) \ 178 template <typename TAttribute> \ 181 static void setAttribute(className& object, \ 182 const typename TAttribute::StorageType& value) \ 184 BOOST_STATIC_ASSERT_MSG(sizeof(TAttribute) == 0, \ 185 "Invalid attribute type for initialization"); \ 187 static void setAttributeValue(className& object, \ 188 const typename TAttribute::ValueType& value) \ 190 BOOST_STATIC_ASSERT_MSG(sizeof(TAttribute) == 0, \ 191 "Invalid attribute type for initialization"); \ 193 static const TAttribute& getAttribute(const className& object) { \ 194 BOOST_STATIC_ASSERT_MSG(sizeof(TAttribute) == 0, \ 195 "Invalid attribute type for getAttribute"); \ 198 BOOST_PP_SEQ_FOR_EACH_I(IPSDK_DECLARE_PROCESSOR_STRUCT_ACCESS_ATTRIBUTE_MACRO, \ 199 className, attributeSeq) \ 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] %\ 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); \ 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] %\ 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); \ 226 template <typename TAttribute> \ 227 const TAttribute& get() const { \ 228 IPSDKBASEPROCESSING_CHECK(isInit() == true, \ 229 [ipsdk::processor::eProcessorMessage::eProcessorNotInit] %\ 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); \ 236 template <typename TAttribute> \ 237 typename boost::enable_if_c<TAttribute::g_bOutput, \ 238 typename TAttribute::StorageType>::type \ 240 IPSDKBASEPROCESSING_CHECK(isInit() == true, \ 241 [ipsdk::processor::eProcessorMessage::eProcessorNotInit] %\ 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(); \ 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) \ 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)\ 261 #define IPSDK_DECLARE_PROCESSOR(libraryName, className, RuleString, attributeSeq) \ 262 IPSDK_DECLARE_ACTION(libraryName, className) \ 263 friend class ipsdk::processor::ProcessorFactory; \ 265 static boost::shared_ptr<className> createProcessor(); \ 267 static ipsdk::processor::ProcessorPtr createBaseProcessor(); \ 273 static const ipsdk::processor::ProcessorDispatchPolicy& getDefaultDispatchPolicy(); \ 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); \ 281 ipsdk::processor::RulePtr createRule() const { \ 282 ipsdk::processor::RulePtr pRule = RuleString; \ 285 IPSDK_DECLARE_PROCESSOR_ATTRIBUTES(className, attributeSeq) 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) \ 297 ipsdk::core::ExecResult mainProcess(); 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) \ 307 ipsdk::processor::RetrievalResult \ 308 retrieveProvider(const ipsdk::core::BasePriority& priority, \ 309 ipsdk::core::ActionProviderPtr& pProvider); 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) \ 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); 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) \ 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); 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) \ 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); 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) \ 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); 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) \ 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); 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) \ 405 ipsdk::processor::RetrievalResult \ 406 retrieveProvider(const ipsdk::core::BasePriority& priority, \ 407 const ipsdk::ipUInt32 curNbIter, \ 408 ipsdk::core::ActionProviderPtr& pProvider); 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) \ 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); 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); 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); 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.