IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RuleLeafsComparison.h
1 // RuleLeafsComparison.h:
3 // ----------------------
4 //
15 
16 #ifndef __IPSDKBASEPROCESSING_RULELEAFSCOMPARISON_H__
17 #define __IPSDKBASEPROCESSING_RULELEAFSCOMPARISON_H__
18 
19 #include <IPSDKBaseProcessing/Rule/Attribute/DataItem/Leaf/LeafsComparison/BaseTLeafsComparisonRule.h>
20 
21 namespace ipsdk {
22 namespace processor {
23 
26 
27 template <typename AttributeType1,
28  typename LeafType1,
29  typename AttributeType2,
30  typename LeafType2,
31  eValueComparisonRuleType::domain ValueComparisonRuleType>
32 class RuleLeafsComparison : public BaseTLeafsComparisonRule<typename LeafType1::ValueType,
33  ValueComparisonRuleType>
34 {
35 // predefined public types
36 public:
39  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<AttributeType1::g_attributeType>,
40  boost::mpl::int_<eAttributeType::eAT_DataItem> >::type,
41  typename AttributeType1::ValueType>::type DataItemType1;
42  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<AttributeType2::g_attributeType>,
43  boost::mpl::int_<eAttributeType::eAT_DataItem> >::type,
44  typename AttributeType2::ValueType>::type DataItemType2;
46 
49  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<LeafType1::g_itemType>,
50  boost::mpl::int_<eDataItemType::eDIT_Leaf> >::type,
51  typename LeafType1::ValueType>::type ValueType1;
52  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<LeafType2::g_itemType>,
53  boost::mpl::int_<eDataItemType::eDIT_Leaf> >::type,
54  typename LeafType2::ValueType>::type ValueType2;
56 
59 
60  typedef typename boost::enable_if<typename boost::is_same<ValueType1, ValueType2>::type,
63 
64 public:
70 
71 // methods
72 public:
78  void init(const boost::weak_ptr<const AttributeType1>& pAttribute1,
79  const boost::weak_ptr<const AttributeType2>& pAttribute2);
80 
81 protected:
84  std::string getAttribute1Name() const;
85  std::string getAttribute2Name() const;
87 
90  const ValueType& getAttribute1Value() const;
91  const ValueType& getAttribute2Value() const;
93 
94 // attributes
95 protected:
96 
97 };
98 
101 
102 template <typename AttributeType1, typename LeafType1, typename AttributeType2, typename LeafType2, eValueComparisonRuleType::domain ValueComparisonRuleType>
103 inline void
105  const boost::weak_ptr<const AttributeType2>& pAttribute2)
106 {
107  // call of base class initialization method
109 }
110 
111 template <typename AttributeType1, typename LeafType1, typename AttributeType2, typename LeafType2, eValueComparisonRuleType::domain ValueComparisonRuleType>
112 inline std::string
114 {
115  return AttributeType1::getObjectNameStr() + "::" +
116  DataItemType1::template getNodeNameStr<LeafType1>();
117 }
118 
119 template <typename AttributeType1, typename LeafType1, typename AttributeType2, typename LeafType2, eValueComparisonRuleType::domain ValueComparisonRuleType>
120 inline std::string
122 {
123  return AttributeType2::getObjectNameStr() + "::" +
124  DataItemType2::template getNodeNameStr<LeafType2>();
125 }
126 
127 template <typename AttributeType1, typename LeafType1, typename AttributeType2, typename LeafType2, eValueComparisonRuleType::domain ValueComparisonRuleType>
130 {
131  // retrieve associated attribute
132  const AttributeType1& derivedAttribute1 = static_cast<const AttributeType1&>(this->getAttribute1());
133 
134  return derivedAttribute1.getNode().template getValue<LeafType1>();
135 }
136 
137 template <typename AttributeType1, typename LeafType1, typename AttributeType2, typename LeafType2, eValueComparisonRuleType::domain ValueComparisonRuleType>
140 {
141  // retrieve associated attribute
142  const AttributeType2& derivedAttribute2 = static_cast<const AttributeType2&>(this->getAttribute2());
143 
144  return derivedAttribute2.getNode().template getValue<LeafType2>();
145 }
146 
149 
150 } // end of namespace processor
151 } // end of namespace ipsdk
152 
153 #endif // __IPSDKBASEPROCESSING_RULELEAFSCOMPARISON_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
std::string getAttribute2Name() const
method allowing to retrieve attributes name into derived class
Definition: RuleLeafsComparison.h:121
boost::enable_if< typename boost::is_same< boost::mpl::int_< AttributeType1::g_attributeType >, boost::mpl::int_< eAttributeType::eAT_DataItem > >::type, typename AttributeType1::ValueType >::type DataItemType1
retrieve DataItem node type associated to attribute
Definition: RuleLeafsComparison.h:41
void initBase()
base class initialization method
Base template class for rule allowing to compare leaf values of data item attributes.
Definition: BaseTLeafsComparisonRule.h:28
boost::enable_if< typename boost::is_same< ValueType1, ValueType2 >::type, ValueType1 >::type ValueType
Value type associated to leaf.
Definition: RuleLeafsComparison.h:61
boost::enable_if< typename boost::is_same< boost::mpl::int_< LeafType1::g_itemType >, boost::mpl::int_< eDataItemType::eDIT_Leaf > >::type, typename LeafType1::ValueType >::type ValueType1
retrieve associated child node information structure
Definition: RuleLeafsComparison.h:51
void init(const boost::weak_ptr< const AttributeType1 > &pAttribute1, const boost::weak_ptr< const AttributeType2 > &pAttribute2)
initialization of object
Definition: RuleLeafsComparison.h:104
const ValueType & getAttribute1Value() const
method allowing to retrieve attribute value into derived class
Definition: RuleLeafsComparison.h:129
std::string getAttribute1Name() const
method allowing to retrieve attributes name into derived class
Definition: RuleLeafsComparison.h:113
Concrete class for rule allowing to compare leaf values of data item attributes.
Definition: RuleLeafsComparison.h:32
boost::enable_if< typename boost::is_same< boost::mpl::int_< AttributeType2::g_attributeType >, boost::mpl::int_< eAttributeType::eAT_DataItem > >::type, typename AttributeType2::ValueType >::type DataItemType2
retrieve DataItem node type associated to attribute
Definition: RuleLeafsComparison.h:44
const ValueType & getAttribute2Value() const
method allowing to retrieve attribute value into derived class
Definition: RuleLeafsComparison.h:139
boost::enable_if< typename boost::is_same< boost::mpl::int_< LeafType2::g_itemType >, boost::mpl::int_< eDataItemType::eDIT_Leaf > >::type, typename LeafType2::ValueType >::type ValueType2
retrieve associated child node information structure
Definition: RuleLeafsComparison.h:54