ifw-core  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parameter.hpp
Go to the documentation of this file.
1 
9 #ifndef IFW_CTD_PARAM_PARAMETER_HPP_
10 #define IFW_CTD_PARAM_PARAMETER_HPP_
11 
12 #include <string>
13 
14 #include "ctd/defines/defines.hpp"
16 
17 
18 namespace ctd {
19  namespace param {
20 
21  const std::string NO_VALUE = "__NO__VALUE__";
22 
24  class Parameter {
25  public:
26 
27  Parameter();
28 
30  Parameter(const std::string name,
31  const std::string value,
32  const std::string comment = "");
33 
35  Parameter(const Parameter& source);
36 
37  ~Parameter();
38 
40  Parameter& Clear();
41 
43  Parameter& SetName(const std::string name);
44 
46  std::string GetName() const;
47 
49  Parameter& SetValue(const std::string& value);
50 
52  Parameter& SetValue(const char* value);
53 
55  template <class TYPE>
56  Parameter& SetValue(TYPE& value) {
57  RAD_LOG_TRACE();
58 
60  return *this;
61  }
62 
64  std::string GetValue() const;
65 
67  bool NoValue() const;
68 
70  template <class TYPE>
71  void GetValue(TYPE& value) const {
72  RAD_LOG_TRACE();
73 
75  }
76 
78  Parameter& SetComment(const std::string& comment);
79 
81  std::string GetComment() const;
82 
84  std::string ToString() const;
85 
87  Parameter& operator = (const Parameter& source);
88 
89  protected:
90  std::string m_name;
91  std::string m_value;
92  std::string m_comment;
93 
94  private:
95  void _Copy(const Parameter& source);
96  };
97 
98  }
99 }
100 
101 #endif // !IFW_CTD_PARAM_PARAMETER_HPP_
Parameter & operator=(const Parameter &source)
Copy operator.
Definition: Parameter.cpp:39
void GetValue(TYPE &value) const
Get parameter value as its native data type.
Definition: Parameter.hpp:71
std::string NbToStr(const TYPE number, const std::string &format="")
Convert the given value to a string representation.
Definition: conversion.hpp:26
std::string m_value
Definition: Parameter.hpp:91
bool NoValue() const
Return true if no value has been set for the parameter.
Definition: Parameter.cpp:113
std::string m_comment
Definition: Parameter.hpp:92
Common definitions.
const std::string NO_VALUE
Definition: Parameter.hpp:21
Parameter & SetValue(const std::string &value)
Set parameter value.
Definition: Parameter.cpp:84
std::string GetValue() const
Get parameter value as a string.
Definition: Parameter.cpp:102
Parameter & SetComment(const std::string &comment)
Set parameter comment.
Definition: Parameter.cpp:147
void Convert(const std::string &str_value, std::string &native_value)
Handle case: Conversion of std::string to std::string.
Definition: conversion.cpp:52
Parameter & SetValue(TYPE &value)
Set parameter value as its native data type.
Definition: Parameter.hpp:56
Parameter & Clear()
Clear the internal members.
Definition: Parameter.cpp:48
Parameter & SetName(const std::string name)
Set parameter name.
Definition: Parameter.cpp:68
std::string m_name
Definition: Parameter.hpp:90
~Parameter()
Definition: Parameter.cpp:33
Class to handle information for one parameter.
Definition: Parameter.hpp:24
std::string GetComment() const
Get parameter comment.
Definition: Parameter.cpp:120
Parameter()
Definition: Parameter.cpp:8
std::string GetName() const
Return parameter name.
Definition: Parameter.cpp:77
Data conversion tools.
std::string ToString() const
Print out parameter.
Definition: Parameter.cpp:127