IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RuleLeafValueComparison.h
1 // RuleLeafValueComparison.h:
3 // --------------------------
4 //
15 
16 #ifndef __IPSDKBASEPROCESSING_RULELEAFVALUECOMPARISON_H__
17 #define __IPSDKBASEPROCESSING_RULELEAFVALUECOMPARISON_H__
18 
19 #include <IPSDKBaseProcessing/Rule/Attribute/DataItem/Leaf/LeafValueComparison/BaseTLeafValueComparisonRule.h>
21 
22 namespace ipsdk {
23 namespace processor {
24 
27 
28 template <typename AttributeType,
29  typename LeafType,
30  eValueComparisonRuleType::domain ValueComparisonRuleType,
31  typename Enable=void>
33 
36 
37 template <typename AttributeType,
38  typename LeafType,
39  eValueComparisonRuleType::domain ValueComparisonRuleType>
40 class RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
41  typename boost::disable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type> :
42  public BaseTLeafValueComparisonRule<typename LeafType::ValueType,
43  ValueComparisonRuleType>
44 {
45 // predefined public types
46 public:
48  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<AttributeType::g_attributeType>,
49  boost::mpl::int_<eAttributeType::eAT_DataItem> >::type,
50  typename AttributeType::ValueType>::type DataItemType;
51 
53  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<LeafType::g_itemType>,
54  boost::mpl::int_<eDataItemType::eDIT_Leaf> >::type,
55  typename LeafType::ValueType>::type ValueType;
56 
57 public:
63 
64 // methods
65 public:
69  void init(const boost::weak_ptr<const AttributeType>& pAttribute,
70  const ValueType& value);
71 
72 protected:
74  std::string getAttributeName() const;
75 
77  ValueType getAttributeValue() const;
78 
79 // attributes
80 protected:
81 
82 };
83 
86 
87 template <typename AttributeType, typename LeafType, eValueComparisonRuleType::domain ValueComparisonRuleType>
88 inline void
89 RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
90  typename boost::disable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type>::
91  init(const boost::weak_ptr<const AttributeType>& pAttribute,
92  const ValueType& value)
93 {
94  // call of base class initialization method
96 }
97 
98 template <typename AttributeType, typename LeafType, eValueComparisonRuleType::domain ValueComparisonRuleType>
99 inline std::string
100 RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
101  typename boost::disable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type>::
102  getAttributeName() const
103 {
104  return AttributeType::getObjectNameStr() + "::" +
105  DataItemType::template getNodeNameStr<LeafType>();
106 }
107 
108 template <typename AttributeType, typename LeafType, eValueComparisonRuleType::domain ValueComparisonRuleType>
109 inline typename RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
110  typename boost::disable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type>::ValueType
111 RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
112  typename boost::disable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type>::
113  getAttributeValue() const
114 {
115  // retrieve associated attribute
116  const AttributeType& derivedAttribute = static_cast<const AttributeType&>(this->getAttribute1());
117 
118  return derivedAttribute.getNode().template getValue<LeafType>();
119 }
120 
123 
124 template <typename AttributeType,
125  typename LeafType,
126  eValueComparisonRuleType::domain ValueComparisonRuleType>
127 class RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
128  typename boost::enable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type> :
129  public BaseTLeafValueComparisonRule<ipInt32,
130  ValueComparisonRuleType>
131 {
132 // predefined public types
133 public:
135  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<AttributeType::g_attributeType>,
136  boost::mpl::int_<eAttributeType::eAT_DataItem> >::type,
137  typename AttributeType::ValueType>::type DataItemType;
138 
140  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<LeafType::g_itemType>,
141  boost::mpl::int_<eDataItemType::eDIT_Leaf> >::type,
142  typename LeafType::ValueType>::type ValueType;
143 
146 
147 public:
153 
154 // methods
155 public:
159  void init(const boost::weak_ptr<const AttributeType>& pAttribute,
160  const ValueType& value);
161 
162 protected:
164  std::string getAttributeName() const;
165 
167  BaseValueType getAttributeValue() const;
168 
169 // attributes
170 protected:
171 
172 };
173 
176 
177 template <typename AttributeType, typename LeafType, eValueComparisonRuleType::domain ValueComparisonRuleType>
178 inline void
179 RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
180  typename boost::enable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type>::
181  init(const boost::weak_ptr<const AttributeType>& pAttribute,
182  const ValueType& value)
183 {
184  // call of base class initialization method
186 }
187 
188 template <typename AttributeType, typename LeafType, eValueComparisonRuleType::domain ValueComparisonRuleType>
189 inline std::string
190 RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
191  typename boost::enable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type>::
192  getAttributeName() const
193 {
194  return AttributeType::getObjectNameStr() + "::" +
195  DataItemType::template getNodeNameStr<LeafType>();
196 }
197 
198 template <typename AttributeType, typename LeafType, eValueComparisonRuleType::domain ValueComparisonRuleType>
199 inline typename RuleLeafValueComparison<AttributeType, LeafType, ValueComparisonRuleType,
200  typename boost::enable_if<typename boost::is_base_of<boost::detail::enum_base<typename LeafType::ValueType>, typename LeafType::ValueType>::type>::type>::BaseValueType
202  getAttributeValue() const
203 {
204  // retrieve associated attribute
205  const AttributeType& derivedAttribute = static_cast<const AttributeType&>(this->getAttribute1());
206 
207  return derivedAttribute.getNode().template getValue<LeafType>().value();
208 }
209 
212 
213 } // end of namespace processor
214 } // end of namespace ipsdk
215 
216 #endif // __IPSDKBASEPROCESSING_RULELEAFVALUECOMPARISON_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
boost::enable_if< typename boost::is_same< boost::mpl::int_< AttributeType::g_attributeType >, boost::mpl::int_< eAttributeType::eAT_DataItem > >::type, typename AttributeType::ValueType >::type DataItemType
retrieve attribute type
Definition: RuleLeafValueComparison.h:50
Base template class for rule allowing to compare leaf value of data item attributes with a given valu...
Definition: BaseTLeafValueComparisonRule.h:33
int32_t ipInt32
Base types definition.
Definition: BaseTypes.h:52
void initBase()
base class initialization method
Definition: DataItemNodeHdrMacrosDetails.h:48
boost::enable_if< typename boost::is_same< boost::mpl::int_< LeafType::g_itemType >, boost::mpl::int_< eDataItemType::eDIT_Leaf > >::type, typename LeafType::ValueType >::type ValueType
Value type associated to leaf.
Definition: RuleLeafValueComparison.h:142
boost::enable_if< typename boost::is_same< boost::mpl::int_< AttributeType::g_attributeType >, boost::mpl::int_< eAttributeType::eAT_DataItem > >::type, typename AttributeType::ValueType >::type DataItemType
retrieve attribute type
Definition: RuleLeafValueComparison.h:137
boost::enable_if< typename boost::is_same< boost::mpl::int_< LeafType::g_itemType >, boost::mpl::int_< eDataItemType::eDIT_Leaf > >::type, typename LeafType::ValueType >::type ValueType
Value type associated to leaf.
Definition: RuleLeafValueComparison.h:55
Concrete class for rule allowing to compare leaf value of data item attributes with a given value...
Definition: RuleLeafValueComparison.h:32
Predefined macros for enumerates management.