Range.hpp
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <eproperty/Interface.hpp>
11 #include <eproperty/Value.hpp>
12 #include <typeinfo>
13 
14 namespace eproperty {
19  template<class TYPE> class Range : public Value<TYPE> {
20  private:
21  TYPE m_min;
22  TYPE m_max;
23  public:
34  template<class CLASS_TYPE>
35  Range(CLASS_TYPE* _owner,
36  const std::string& _name,
37  const TYPE& _defaultValue,
38  const TYPE& _min,
39  const TYPE& _max,
40  const std::string& _description = "",
41  void (CLASS_TYPE::*_setObs)()=nullptr) :
42  eproperty::Value<TYPE>(_owner, _name, _defaultValue, _description, _setObs),
43  m_min(_min),
44  m_max(_max) {
45  if (m_min > m_max) {
46  //EPROPERTY_CRITICAL("min > max...");
47  }
48  };
55  Range(const TYPE& _defaultValue,
56  const TYPE& _min,
57  const TYPE& _max);
61  virtual ~Range() = default;
62  std::string getPropertyType() const override;
63  void setString(const std::string& _newVal) override;
64  std::string getInfo() const override;
65  public:
66  void set(const TYPE& _newVal) override;
67  void setDirectCheck(const TYPE& _newVal) override;
68  };
70  template<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::Range<TYPE>& _obj) {
71  _os << _obj.get();
72  return _os;
73  }
74 }
void setString(const std::string &_newVal) override
Set a new value of the Property (with string interface).
Range template of the property (limit with a min and a max value)
Definition: Range.hpp:19
Range(CLASS_TYPE *_owner, const std::string &_name, const TYPE &_defaultValue, const TYPE &_min, const TYPE &_max, const std::string &_description="", void(CLASS_TYPE::*_setObs)()=nullptr)
Create a parameter with a specific type.
Definition: Range.hpp:35
virtual ~Range()=default
Destructor.
std::string getInfo() const override
Description of the Propertys.
std::string getPropertyType() const override
Get the Property type of the class in string mode.
Simple Value of the property (need to implement fuction etk::from_string<TYPE> to use it) ...
Definition: Value.hpp:20
void setDirectCheck(const TYPE &_newVal) override
Set the value of the current parameter (check range and ... if needed).
eproperty global interface for all property implementation
Definition: Interface.hpp:14