IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
DataItemEnumLeaf.h
1 // DataItemEnumLeaf.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKBASEDATA_DATAITEMENUMLEAF_H__
16 #define __IPSDKBASEDATA_DATAITEMENUMLEAF_H__
17 
18 #include <IPSDKBaseData/DataItem/Leaf/BaseDataItemEnumLeaf.h>
19 
20 namespace ipsdk {
21 
24 
25 template <typename enumType>
27 {
28 // predefined public types
29 public:
31  typedef enumType EnumType;
32 
33 public:
36  DataItemEnumLeaf() {}
37  ~DataItemEnumLeaf() {}
39 
40 // methods
41 public:
43  std::string getEnumNameStr() const
44  {
45  return EnumType::getEnumName();
46  }
47 
49  void setValue(const EnumType& enumValue);
50 
52  EnumType getValue() const;
53 
54 protected:
58  bool fromString(const std::string& strValue,
59  ipUInt32& intValue) const
60  {
61  boost::optional<EnumType> optValue = EnumType::get_by_name(strValue.c_str());
62  if (optValue.is_initialized() == true) {
63  intValue = optValue->value();
64  return true;
65  }
66  else
67  return false;
68  }
69 
73  bool toString(const ipUInt32& intValue,
74  std::string& strValue) const
75  {
76  boost::optional<EnumType> optValue = EnumType::get_by_value(intValue);
77  if (optValue.is_initialized() == true) {
78  strValue = optValue->str();
79  return true;
80  }
81  else
82  return false;
83  }
84 
85 // attributes
86 protected:
87 
88 };
89 
92 
93 template <typename enumType>
94 inline void
96 {
97  _enumValue = enumValue.value();
98 }
99 
100 template <typename enumType>
101 inline enumType
103 {
104  return *enumType::get_by_index(static_cast<ipsdk::ipInt32>(_enumValue));
105 }
106 
107 
110 
111 } // end of namespace ipsdk
112 
113 #endif // __IPSDKBASEDATA_DATAITEMENUMLEAF_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void setValue(const EnumType &enumValue)
set value associated to object
Definition: DataItemEnumLeaf.h:95
Concrete class for data item leafs associated to enumerate value.
Definition: DataItemEnumLeaf.h:26
std::string getEnumNameStr() const
method allowing to retrieve enumerate name
Definition: DataItemEnumLeaf.h:43
bool toString(const ipUInt32 &intValue, std::string &strValue) const
method allowing to convert enumerate integer value to a string value
Definition: DataItemEnumLeaf.h:73
enumType EnumType
enumerate type associated to object
Definition: DataItemEnumLeaf.h:31
bool fromString(const std::string &strValue, ipUInt32 &intValue) const
method allowing to convert enumerate string value to an integer value
Definition: DataItemEnumLeaf.h:58
EnumType getValue() const
retrieve value associated to object
Definition: DataItemEnumLeaf.h:102
Base class for data item leafs associated to enumerate value.
Definition: BaseDataItemEnumLeaf.h:25
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53