IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RuleMatchLeafToImageSize.h
1 // RuleMatchLeafToImageSize.h:
3 // ----------------------------
4 //
15 
16 #ifndef __IPSDKIMAGEPROCESSING_RULEMATCHLEAFTOIMAGESIZE_H__
17 #define __IPSDKIMAGEPROCESSING_RULEMATCHLEAFTOIMAGESIZE_H__
18 
19 #include <IPSDKImageProcessing/Rule/Image/ImageBinaryMixed/BaseRuleMatchScalarToImageSize.h>
20 #include <IPSDKImageProcessing/Attribute/Image/BaseImageAttribute.h>
22 
23 namespace ipsdk {
24 namespace imaproc {
25 
28 
29 template <typename AttributeType, typename LeafType>
31 {
32 // predefined public types
33 public:
35  typedef AttributeType ValueAttributeType;
36 
38  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<AttributeType::g_attributeType>,
39  boost::mpl::int_<processor::eAttributeType::eAT_DataItem> >::type,
40  typename AttributeType::ValueType>::type DataItemType;
41 
43  typedef typename boost::enable_if<typename boost::is_same<boost::mpl::int_<LeafType::g_itemType>,
44  boost::mpl::int_<eDataItemType::eDIT_Leaf> >::type,
45  typename LeafType::ValueType>::type ValueType;
46 
47 public:
53 
54 // methods
55 public:
61  void init(const eMatchImageSizeType& matchImageSizeType,
62  const eMatchImageSizeScale& matchImageSizeScale,
63  const ImageAttributeConstWeakPtr& pImageAttribute,
64  const boost::weak_ptr<const AttributeType>& pValueAttribute);
65 
66 protected:
68  ipReal64 retrieveValue() const;
69 
71  std::string retrieveValueAttributeName() const;
72 
73 // attributes
74 protected:
75 
76 };
77 
80 
81 template <typename AttributeType, typename LeafType>
82 inline void
84  const eMatchImageSizeScale& matchImageSizeScale,
85  const ImageAttributeConstWeakPtr& pImageAttribute,
86  const boost::weak_ptr<const AttributeType>& pValueAttribute)
87 {
88  // store dimensions considered in the size check in the image
89  _matchImageSizeType = matchImageSizeType;
90 
91  // store image size scale
92  _matchImageSizeScale = matchImageSizeScale;
93 
94  // call of base class initialization method
95  BaseRuleMatchScalarToImageSize::initBase(pImageAttribute, pValueAttribute);
96 }
97 
98 template <typename AttributeType, typename LeafType>
99 inline ipReal64
101 {
102  // retrieve associated attribute
103  const AttributeType& valueAttribute = static_cast<const AttributeType&>(getAttribute2());
104 
105  return static_cast<ipReal64>(valueAttribute.getNode().template getValue<LeafType>());
106 }
107 
108 template <typename AttributeType, typename LeafType>
109 inline std::string
111 {
112  return ValueAttributeType::getObjectNameStr() + "::" +
113  DataItemType::template getNodeNameStr<LeafType>();
114 }
115 
118 
119 } // end of namespace imaproc
120 } // end of namespace ipsdk
121 
122 #endif // __IPSDKIMAGEPROCESSING_RULEMATCHLEAFTOIMAGESIZE_H__
ipReal64 retrieveValue() const
method allowing to retrieve value associated to attribute leaf in derived class
Definition: RuleMatchLeafToImageSize.h:100
eMatchImageSizeScale
enumerate used in comparison between scalar and image size, to determine whether scalar is compared t...
Definition: ImageBinaryMixedRuleTypes.h:59
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
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: RuleMatchLeafToImageSize.h:45
void init(const eMatchImageSizeType &matchImageSizeType, const eMatchImageSizeScale &matchImageSizeScale, const ImageAttributeConstWeakPtr &pImageAttribute, const boost::weak_ptr< const AttributeType > &pValueAttribute)
initialization of object
Definition: RuleMatchLeafToImageSize.h:83
boost::weak_ptr< const BaseImageAttribute > ImageAttributeConstWeakPtr
Definition: ImageAttributeTypes.h:38
AttributeType ValueAttributeType
Value attribute type.
Definition: RuleMatchLeafToImageSize.h:35
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
void initBase()
base class initialization method
boost::enable_if< typename boost::is_same< boost::mpl::int_< AttributeType::g_attributeType >, boost::mpl::int_< processor::eAttributeType::eAT_DataItem > >::type, typename AttributeType::ValueType >::type DataItemType
retrieve DataItem node type associated to attribute
Definition: RuleMatchLeafToImageSize.h:40
Base class for rules allowing to check that a value is lower than the smallest dimension of an image...
Definition: BaseRuleMatchScalarToImageSize.h:31
eMatchImageSizeType
enumerate describing image comparison on image size rule operation type
Definition: ImageRuleTypes.h:50
Rule class allowing to check that a DataItem leaf value is lower than or equals to image size in give...
Definition: RuleMatchLeafToImageSize.h:30
Predefined types for data items.
std::string retrieveValueAttributeName() const
method allowing to retrieve value associated to attribute leaf in derived class
Definition: RuleMatchLeafToImageSize.h:110