[DEV] correct interface declaration
This commit is contained in:
parent
28ce277bba
commit
b0dc65af0d
@ -73,7 +73,7 @@ void eproperty::Interface::propertyDisplay(bool _changeOnly) const {
|
||||
}
|
||||
}
|
||||
|
||||
void eproperty::Interface::onPropertyChangeValue(const eproperty::Ref& _paramPointer) {
|
||||
void eproperty::Interface::onPropertyChangeValue() {
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace eproperty {
|
||||
class Interface {
|
||||
friend class eproperty::Property; // to register property in the list.
|
||||
private:
|
||||
std::vector<eproperty::Property*> m_list; //!< list of availlable Propertys (no need to free)
|
||||
std::vector<eproperty::Property*> m_list; //!< list of availlable Propertys (no need to free)
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor.
|
||||
@ -56,16 +56,14 @@ namespace eproperty {
|
||||
* @param[in] changeOnly check at true if the user want to display only property that are not at default value.
|
||||
*/
|
||||
void propertyDisplay(bool _changeOnly = false) const;
|
||||
/**
|
||||
* @brief Called when a property change value.
|
||||
* @param[in] _paramPointer Pointer on the property (to know which property have change);
|
||||
*/
|
||||
virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer);
|
||||
/**
|
||||
* @brief Get All the property configuration:
|
||||
* @return map on the propertys
|
||||
*/
|
||||
std::map<std::string, std::string> propertyGetAll(bool _notIfDefault=true) const;
|
||||
|
||||
// deprecated
|
||||
virtual void onPropertyChangeValue();
|
||||
public:
|
||||
/**
|
||||
* @brief Get count of propertys.
|
||||
|
@ -22,18 +22,24 @@ namespace eproperty {
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with List of element parameter.
|
||||
* @param[in] _objectLink reference on the parameter lister.
|
||||
* @param[in] _owner reference on the parameter lister.
|
||||
* @param[in] _name Static name of the parameter.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
* @param[in] _description description of the parameter.
|
||||
* @param[in] _setObs function of the class that opserve the change of the value
|
||||
*/
|
||||
List(eproperty::Interface& _paramInterfaceLink,
|
||||
template<class CLASS_TYPE>
|
||||
List(CLASS_TYPE* _owner,
|
||||
const std::string& _name,
|
||||
const TYPE& _defaultValue,
|
||||
const std::string& _description="") :
|
||||
Property(_paramInterfaceLink, _name),
|
||||
const std::string& _description="",
|
||||
void (CLASS_TYPE::*_setObs)()=nullptr) :
|
||||
Property(_owner, _name),
|
||||
m_value(_defaultValue),
|
||||
m_default(_defaultValue) {
|
||||
|
||||
if (_setObs != nullptr) {
|
||||
setObserver([=](){(*_owner.*_setObs)();});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Destructor.
|
||||
|
@ -11,22 +11,28 @@
|
||||
#include <eproperty/Property.h>
|
||||
|
||||
|
||||
eproperty::Property::Property(eproperty::Interface& _paramInterfaceLink, const std::string& _name) :
|
||||
eproperty::Property::Property(eproperty::Interface* _paramInterfaceLink, const std::string& _name) :
|
||||
m_interfaceLink(_paramInterfaceLink),
|
||||
m_setObserver(),
|
||||
m_name(_name) {
|
||||
// add a reference on the current Property ...
|
||||
m_interfaceLink.propertyAdd(this);
|
||||
if (m_interfaceLink != nullptr) {
|
||||
m_interfaceLink->propertyAdd(this);
|
||||
}
|
||||
}
|
||||
|
||||
void eproperty::Property::setObserver(eproperty::Property::Observer _setObs) {
|
||||
m_setObserver = _setObs;
|
||||
}
|
||||
|
||||
std::string eproperty::Property::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void eproperty::Property::notifyChange() const {
|
||||
m_interfaceLink.onPropertyChangeValue(eproperty::Ref(this));
|
||||
}
|
||||
|
||||
bool eproperty::operator==(const eproperty::Ref& _obj, const eproperty::Property& _obj2) noexcept {
|
||||
return &_obj2 == _obj.m_ref;
|
||||
}
|
||||
|
||||
bool eproperty::operator==(const eproperty::Property& _obj2, const eproperty::Ref& _obj) noexcept {
|
||||
return &_obj2 == _obj.m_ref;
|
||||
if (m_setObserver != nullptr) {
|
||||
m_setObserver();
|
||||
}
|
||||
//m_interfaceLink.onPropertyChangeValue();
|
||||
}
|
||||
|
||||
|
@ -10,16 +10,23 @@
|
||||
#include <eproperty/Interface.h>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <functional>
|
||||
|
||||
namespace eproperty {
|
||||
class Ref;
|
||||
class Property {
|
||||
public:
|
||||
using Observer = std::function<void()>;
|
||||
private:
|
||||
eproperty::Interface& m_interfaceLink;
|
||||
eproperty::Interface* m_interfaceLink;
|
||||
Observer m_setObserver;
|
||||
std::string m_name;
|
||||
public:
|
||||
Property(eproperty::Interface& _paramInterfaceLink, const std::string& _name);
|
||||
Property(eproperty::Interface* _paramInterfaceLink, const std::string& _name);
|
||||
virtual ~Property() = default;
|
||||
protected:
|
||||
void setObserver(eproperty::Property::Observer _setObs);
|
||||
public:
|
||||
/**
|
||||
* @brief call main class that PropertyChange
|
||||
*/
|
||||
@ -28,9 +35,7 @@ namespace eproperty {
|
||||
* @brief Get the name of the Property.
|
||||
* @return The name of the Property
|
||||
*/
|
||||
virtual std::string getName() const {
|
||||
return m_name;
|
||||
};
|
||||
virtual std::string getName() const;
|
||||
/**
|
||||
* @brief Description of the Propertys.
|
||||
* @return Descriptive information of the Property (for remote UI).
|
||||
@ -84,15 +89,5 @@ namespace eproperty {
|
||||
template<class TYPE>
|
||||
bool operator> (const TYPE& _obj) const = delete;
|
||||
};
|
||||
class Ref {
|
||||
public:
|
||||
const Property* m_ref;
|
||||
Ref(const Property* _ref) :
|
||||
m_ref(_ref) {
|
||||
// nothing to do ...
|
||||
}
|
||||
};
|
||||
bool operator==(const Ref& _obj, const Property& _obj2) noexcept;
|
||||
bool operator==(const Property& _obj2, const Ref& _obj) noexcept;
|
||||
}
|
||||
|
||||
|
@ -21,25 +21,33 @@ namespace eproperty {
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _objectLink reference on the parameter lister.
|
||||
* @param[in] _owner reference on the parameter lister.
|
||||
* @param[in] _name Static name of the parameter.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
* @param[in] _min Minumum value.
|
||||
* @param[in] _max Maximum value.
|
||||
* @param[in] _description description of the parameter.
|
||||
* @param[in] _setObs function of the class that opserve the change of the value
|
||||
*/
|
||||
Range(eproperty::Interface& _paramInterfaceLink,
|
||||
template<class CLASS_TYPE>
|
||||
Range(CLASS_TYPE* _owner,
|
||||
const std::string& _name,
|
||||
const TYPE& _defaultValue,
|
||||
const TYPE& _min,
|
||||
const TYPE& _max,
|
||||
const std::string& _description = "") :
|
||||
Property(_paramInterfaceLink, _name),
|
||||
const std::string& _description = "",
|
||||
void (CLASS_TYPE::*_setObs)()=nullptr) :
|
||||
Property(_owner, _name),
|
||||
m_value(_defaultValue),
|
||||
m_min(_min),
|
||||
m_max(_max),
|
||||
m_default(_defaultValue) {
|
||||
|
||||
if (m_min > m_max) {
|
||||
//EPROPERTY_CRITICAL("min > max...");
|
||||
}
|
||||
if (_setObs != nullptr) {
|
||||
setObserver([=](){(*_owner.*_setObs)();});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Destructor.
|
||||
|
@ -19,29 +19,24 @@ namespace eproperty {
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _objectLink reference on the parameter lister.
|
||||
* @param[in] _owner Owner of the parameter.
|
||||
* @param[in] _name Static name of the parameter.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
* @param[in] _min Minumum value.
|
||||
* @param[in] _max Maximum value.
|
||||
* @param[in] _description description of the parameter.
|
||||
* @param[in] _setObs function of the class that opserve the change of the value
|
||||
*/
|
||||
Value(eproperty::Interface& _paramInterfaceLink,
|
||||
template<class CLASS_TYPE>
|
||||
Value(CLASS_TYPE* _owner,
|
||||
const std::string& _name,
|
||||
const TYPE& _defaultValue,
|
||||
const std::string& _description = "") :
|
||||
Property(_paramInterfaceLink, _name),
|
||||
const std::string& _description = "",
|
||||
void (CLASS_TYPE::*_setObs)()=nullptr) :
|
||||
Property(_owner, _name),
|
||||
m_value(_defaultValue),
|
||||
m_default(_defaultValue) {
|
||||
|
||||
}
|
||||
Value(eproperty::Interface& _paramListLink,
|
||||
const std::string& _name,
|
||||
const std::string& _description = "") :
|
||||
Property(_paramListLink, _name),
|
||||
m_value(),
|
||||
m_default() {
|
||||
|
||||
if (_setObs != nullptr) {
|
||||
setObserver([=](){(*_owner.*_setObs)();});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Destructor.
|
||||
|
Loading…
Reference in New Issue
Block a user