IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RuleIPEnumValue.h
1 // RuleIPEnumValue.h:
3 // ------------------
4 //
14 
15 #ifndef __IPSDKIMAGEPROCESSING_RULEIPENUMVALUE_H__
16 #define __IPSDKIMAGEPROCESSING_RULEIPENUMVALUE_H__
17 
18 #include <IPSDKImageProcessing/Rule/IPEnum/BaseIPEnumRule.h>
19 #include <IPSDKImageProcessing/Attribute/IPEnum/IPEnumAttribute.h>
20 
21 namespace ipsdk {
22 namespace imaproc {
23 
26 
27 template <typename EnumType>
29 {
30 // predefined public type
31 public:
32  // enumerate type associated to rule
33  typedef EnumType EnumerateType;
34 
35  // attribute type associated to rule
37 
38  // weak pointer to enumerate attribute
39  typedef boost::weak_ptr<const AttributeType> AttributeConstWeakPtr;
40 public:
43  RuleIPEnumValue() {}
44  ~RuleIPEnumValue() {}
46 
47 // methods
48 public:
52  void init(const AttributeConstWeakPtr& pAttribute,
53  const EnumType& enumValue)
54  {
55  initBase(pAttribute);
56  _enumValue = enumValue;
57  }
58 
59 protected:
61  bool testRule() const
62  {
63  // retrieve associated attribute
64  const AttributeType& attribute = static_cast<const AttributeType&>(getAttribute1());
65 
66  return attribute.getValue() == _enumValue;
67  }
68 
70  std::string getTargetValue() const
71  {
72  return _enumValue.str();
73  }
74 
76  std::string getAttributeValue() const
77  {
78  // retrieve associated attribute
79  const AttributeType& attribute = static_cast<const AttributeType&>(getAttribute1());
80 
81  return attribute.getValue().str();
82  }
83 
84 // attributes
85 protected:
87  EnumType _enumValue;
88 };
89 
92 
93 } // end of namespace imaproc
94 } // end of namespace ipsdk
95 
96 #endif // __IPSDKIMAGEPROCESSING_RULEIPENUMVALUE_H__
bool testRule() const
test whether rule is satisfied
Definition: RuleIPEnumValue.h:61
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
const BaseAttribute & getAttribute1() const
retrieve first attribute associated to object
void initBase()
base class initialization method
EnumType _enumValue
enumerate value associated to rule
Definition: RuleIPEnumValue.h:87
Definition: RuleIPEnumValue.h:28
std::string getAttributeValue() const
retrieve string associated to attribute value
Definition: RuleIPEnumValue.h:76
Base class for rules on image processing enumerates.
Definition: BaseIPEnumRule.h:29
Template base class for attributes associated to image processing enumerates.
Definition: ImageBufferTypeAttributeTypes.h:26
std::string getTargetValue() const
retrieve string associated to target value
Definition: RuleIPEnumValue.h:70
virtual EnumType getValue() const =0
get value associated to attribute
void init(const AttributeConstWeakPtr &pAttribute, const EnumType &enumValue)
initialization of object
Definition: RuleIPEnumValue.h:52