IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RuleCustomLeafCollSize.h
1 // RuleCustomLeafCollSize.h:
3 // -------------------------
4 //
15 
16 #ifndef __IPSDKBASEPROCESSING_RULECUSTOMLEAFCOLLSIZE_H__
17 #define __IPSDKBASEPROCESSING_RULECUSTOMLEAFCOLLSIZE_H__
18 
19 #include <IPSDKBaseProcessing/Rule/Attribute/DataItem/LeafColl/Size/BaseTLeafCollSizeRule.h>
20 #include <boost/function.hpp>
21 
22 namespace ipsdk {
23 namespace processor {
24 
27 
28 template <typename AttributeType,
29  typename LeafCollType,
30  eValueComparisonRuleType::domain ValueComparisonRuleType>
31 class RuleCustomLeafCollSize : public BaseTLeafCollSizeRule<ValueComparisonRuleType>
32 {
33 // predefined public types
34 public:
36  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<AttributeType::g_attributeType>,
37  boost::mpl::int_<eAttributeType::eAT_DataItem> >::type,
38  typename AttributeType::ValueType>::type DataItemType;
39 
41  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<LeafCollType::g_itemType>,
42  boost::mpl::int_<eDataItemType::eDIT_LeafColl> >::type,
43  typename LeafCollType::ValueType>::type ValueType;
44 
46  typedef boost::function<ipUInt32 ()> CustomSizeFun;
47 
48 public:
54 
55 // methods
56 public:
60  void init(const boost::weak_ptr<const AttributeType>& pAttribute,
61  CustomSizeFun customSizeFun);
62 
63 protected:
65  std::string getAttributeName() const;
66 
68  ipUInt32 getTargetSize() const;
69 
71  ipUInt32 getCollSize() const;
72 
73 
74 // attributes
75 protected:
78 };
79 
82 
83 template <typename AttributeType, typename LeafCollType, eValueComparisonRuleType::domain ValueComparisonRuleType>
84 inline void
85 RuleCustomLeafCollSize<AttributeType, LeafCollType, ValueComparisonRuleType>::init(const boost::weak_ptr<const AttributeType>& pAttribute,
86  CustomSizeFun customSizeFun)
87 {
88  // store input value
89  _customSizeFun = customSizeFun;
90 
91  // call of base class initialization method
93 }
94 
95 template <typename AttributeType, typename LeafCollType, eValueComparisonRuleType::domain ValueComparisonRuleType>
96 inline std::string
98 {
99  return AttributeType::getObjectNameStr() + "::" +
100  DataItemType::template getNodeNameStr<LeafCollType>() + "{size}";
101 }
102 
103 template <typename AttributeType, typename LeafCollType, eValueComparisonRuleType::domain ValueComparisonRuleType>
104 inline ipUInt32
106 {
107  return _customSizeFun();
108 }
109 
110 template <typename AttributeType, typename LeafCollType, eValueComparisonRuleType::domain ValueComparisonRuleType>
111 inline ipUInt32
113 {
114  // retrieve associated attribute
115  const AttributeType& derivedAttribute = static_cast<const AttributeType&>(this->getAttribute1());
116 
117  return derivedAttribute.getNode().template getSize<LeafCollType>();
118 }
119 
122 
123 } // end of namespace processor
124 } // end of namespace ipsdk
125 
126 #endif // __IPSDKBASEPROCESSING_RULECUSTOMLEAFCOLLSIZE_H__
Concrete class for rules on size of leaf collections of data item attributes with custom target size...
Definition: RuleCustomLeafCollSize.h:31
void init(const boost::weak_ptr< const AttributeType > &pAttribute, CustomSizeFun customSizeFun)
initialization of object
Definition: RuleCustomLeafCollSize.h:85
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
boost::function< ipUInt32()> CustomSizeFun
type associated to functions allowing to retrieve target collection size
Definition: RuleCustomLeafCollSize.h:46
ipUInt32 getTargetSize() const
method allowing to retrieve target size into derived class
Definition: RuleCustomLeafCollSize.h:105
void initBase()
base class initialization method
ipUInt32 getCollSize() const
method allowing to retrieve collection size into derived class
Definition: RuleCustomLeafCollSize.h:112
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: RuleCustomLeafCollSize.h:38
CustomSizeFun _customSizeFun
function allowing to retrieve target collection size
Definition: RuleCustomLeafCollSize.h:77
std::string getAttributeName() const
method allowing to retrieve attribute name into derived class
Definition: RuleCustomLeafCollSize.h:97
Base template class for rules on size of leaf collections of data item attributes.
Definition: BaseTLeafCollSizeRule.h:28
boost::enable_if< typename boost::is_same< boost::mpl::int_< LeafCollType::g_itemType >, boost::mpl::int_< eDataItemType::eDIT_LeafColl > >::type, typename LeafCollType::ValueType >::type ValueType
Value type associated to leaf.
Definition: RuleCustomLeafCollSize.h:43
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53