IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
OptionalRuleOperators.h
Go to the documentation of this file.
1 // OptionalRuleOperators.h:
3 // ------------------------
4 //
14 
15 #ifndef __IPSDKBASEPROCESSING_OPTIONALRULEOPERATORS_H__
16 #define __IPSDKBASEPROCESSING_OPTIONALRULEOPERATORS_H__
17 
19 #include <IPSDKBaseProcessing/Rule/Attribute/Optional/RuleOptionalIsSet.h>
20 
21 namespace ipsdk {
22 namespace processor {
23 
26 
30 template <typename AttributeType>
31 inline typename boost::enable_if_c<AttributeType::g_bOptional,
32  RulePtr>::type
33 isSet(const boost::shared_ptr<AttributeType>& pAttribute)
34 {
35  return isSet(boost::weak_ptr<AttributeType>(pAttribute));
36 }
37 template <typename AttributeType>
38 inline typename boost::enable_if_c<AttributeType::g_bOptional,
39  RulePtr>::type
40 isSet(const boost::weak_ptr<AttributeType>& pAttribute)
41 {
42  typedef RuleOptionalIsSet RuleType;
43  boost::shared_ptr<RuleType> pOutputRule = boost::make_shared<RuleType>();
44  pOutputRule->init(pAttribute);
45 
46  return pOutputRule;
47 }
49 
53 template <typename AttributeType>
54 inline typename boost::enable_if_c<AttributeType::g_bOptional,
55  RulePtr>::type
56 ifIsSet(const boost::shared_ptr<AttributeType>& pAttribute,
57  const RulePtr& pRuleTrue)
58 {
59  return ifIsSet(boost::weak_ptr<AttributeType>(pAttribute), pRuleTrue);
60 }
61 template <typename AttributeType>
62 inline typename boost::enable_if_c<AttributeType::g_bOptional,
63  RulePtr>::type
64 ifIsSet(const boost::weak_ptr<AttributeType>& pAttribute,
65  const RulePtr& pRuleTrue)
66 {
67  return If(isSet(pAttribute), pRuleTrue, none());
68 }
70 
73 
74 } // end of namespace processor
75 } // end of namespace ipsdk
76 
77 #endif // __IPSDKBASEPROCESSING_OPTIONALRULEOPERATORS_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Base operators used to combined rules.
IPSDKBASEPROCESSING_API RulePtr none()
function allowing to define an empty rule (always true)
boost::shared_ptr< BaseRule > RulePtr
shared pointer to rule
Definition: RuleTypes.h:104
boost::enable_if_c< AttributeType::g_bOptional, RulePtr >::type ifIsSet(const boost::shared_ptr< AttributeType > &pAttribute, const RulePtr &pRuleTrue)
Definition: OptionalRuleOperators.h:56
Rule allowing to check whether an optional attribute has been set.
Definition: RuleOptionalIsSet.h:26
boost::enable_if_c< AttributeType::g_bOptional, RulePtr >::type isSet(const boost::shared_ptr< AttributeType > &pAttribute)
Definition: OptionalRuleOperators.h:33
void init(const AttributeConstWeakPtr &pAttribute)
initialization of object
IPSDKBASEPROCESSING_API RulePtr If(const RulePtr &pPredicate, const RulePtr &pRuleTrue)
function allowing to define a conditional condition check rule