From 503b805ce5a6405307dc3349a67730f80377c62f Mon Sep 17 00:00:00 2001 From: Hiroshi Matoba Date: Fri, 14 Dec 2018 15:07:21 +0100 Subject: [PATCH 1/6] add additional constructor to ofParameter to be able to set serializable via initializer list --- libs/openFrameworks/types/ofParameter.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 9e36af034f2..94a5c0bdc79 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -484,6 +484,7 @@ class ofParameter: public ofAbstractParameter{ ofParameter(const ParameterType & v); ofParameter(const std::string& name, const ParameterType & v); ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max); + ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max, bool serializable); const ParameterType & get() const; const ParameterType * operator->() const; @@ -616,6 +617,14 @@ class ofParameter: public ofAbstractParameter{ ,bInNotify(false) ,serializable(true){} + Value(std::string name, ParameterType v, ParameterType min, ParameterType max, bool serializable) + :name(name) + ,value(v) + ,min(min) + ,max(max) + ,bInNotify(false) + ,serializable(serializable){} + std::string name; ParameterType value; ParameterType min, max; @@ -661,6 +670,10 @@ ofParameter::ofParameter(const std::string& name, const Parameter :obj(std::make_shared(name, v, min, max)) ,setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)){} +template +ofParameter::ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max, bool serializable) +:obj(std::make_shared(name, v, min, max, serializable)) +,setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)){} template inline ofParameter & ofParameter::operator=(const ofParameter & v){ From 52e0e4b1335e055d8ae2476ec0aace39b6fe3d28 Mon Sep 17 00:00:00 2001 From: Hiroshi Matoba Date: Fri, 14 Dec 2018 15:08:01 +0100 Subject: [PATCH 2/6] add additional ofParameter::set to keep same style with its constructor --- libs/openFrameworks/types/ofParameter.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 94a5c0bdc79..63e9e685f28 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -558,6 +558,7 @@ class ofParameter: public ofAbstractParameter{ ofParameter & set(const ParameterType & v); ofParameter & set(const std::string& name, const ParameterType & v); ofParameter & set(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max); + ofParameter & set(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max, bool serializable); ofParameter & setWithoutEventNotifications(const ParameterType & v); @@ -702,6 +703,16 @@ ofParameter & ofParameter::set(const std::string& return *this; } +template +ofParameter & ofParameter::set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max, bool serializable){ + setName(name); + set(value); + setMin(min); + setMax(max); + setSerializable(serializable); + return *this; +} + template ofParameter & ofParameter::set(const std::string& name, const ParameterType & value){ setName(name); From 463692e1032a284fd57c0946e5d8afe9476d1a51 Mon Sep 17 00:00:00 2001 From: Hiroshi Matoba Date: Fri, 14 Dec 2018 15:08:40 +0100 Subject: [PATCH 3/6] add additional constructor to ofReadonlyParameter to be able to set serializable via initializer list --- libs/openFrameworks/types/ofParameter.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 63e9e685f28..60a497fc28d 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -1102,6 +1102,7 @@ class ofReadOnlyParameter: public ofAbstractParameter{ ofReadOnlyParameter(const ParameterType & v); ofReadOnlyParameter(const std::string& name, const ParameterType & v); ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max); + ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max, bool serializable); const ParameterType & get() const; const ParameterType * operator->() const; @@ -1226,6 +1227,9 @@ template inline ofReadOnlyParameter::ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max) :parameter(name,v,min,max){} +template +inline ofReadOnlyParameter::ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max, bool serializable) +:parameter(name,v,min,max,serializable){} template inline const ParameterType & ofReadOnlyParameter::get() const{ From 890748e500504d261c4354330ba809549bc158c4 Mon Sep 17 00:00:00 2001 From: Hiroshi Matoba Date: Fri, 14 Dec 2018 15:09:17 +0100 Subject: [PATCH 4/6] add additional ofReadOnlyParameter::set to keep same style with its constructor --- libs/openFrameworks/types/ofParameter.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 60a497fc28d..481f472d29c 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -1177,6 +1177,7 @@ class ofReadOnlyParameter: public ofAbstractParameter{ ofReadOnlyParameter& set(const std::string& name, const ParameterType & value); ofReadOnlyParameter& set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max); + ofReadOnlyParameter& set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max, bool serializable); void setMin(const ParameterType & min); void setMax(const ParameterType & max); @@ -1468,6 +1469,11 @@ inline ofReadOnlyParameter & ofReadOnlyParameter +inline ofReadOnlyParameter & ofReadOnlyParameter::set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max, bool serializable){ + parameter.set(name,value,min,max,serializable); + return *this; +} template inline void ofReadOnlyParameter::setMin(const ParameterType & min){ From 7fc9b3d3bed3eea9cf607295ea5c7b4649a067a9 Mon Sep 17 00:00:00 2001 From: Hiroshi Matoba Date: Fri, 14 Dec 2018 15:57:41 +0100 Subject: [PATCH 5/6] add more constructor to support ofParameter --- libs/openFrameworks/types/ofParameter.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 481f472d29c..df39d5c30b9 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -483,6 +483,7 @@ class ofParameter: public ofAbstractParameter{ ofParameter(const ofParameter & v); ofParameter(const ParameterType & v); ofParameter(const std::string& name, const ParameterType & v); + ofParameter(const std::string& name, const ParameterType & v, bool serializable); ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max); ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max, bool serializable); @@ -610,6 +611,14 @@ class ofParameter: public ofAbstractParameter{ ,bInNotify(false) ,serializable(true){} + Value(std::string name, ParameterType v, bool serializable) + :name(name) + ,value(v) + ,min(of::priv::TypeInfo::min()) + ,max(of::priv::TypeInfo::max()) + ,bInNotify(false) + ,serializable(serializable){} + Value(std::string name, ParameterType v, ParameterType min, ParameterType max) :name(name) ,value(v) @@ -666,6 +675,11 @@ ofParameter::ofParameter(const std::string& name, const Parameter :obj(std::make_shared(name, v)) ,setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)){} +template +ofParameter::ofParameter(const std::string& name, const ParameterType & v, bool serializable) +:obj(std::make_shared(name, v, serializable)) +,setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)){} + template ofParameter::ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max) :obj(std::make_shared(name, v, min, max)) From 44363ebebc47b20e5df2686fc1f97e0a6f97df7e Mon Sep 17 00:00:00 2001 From: Hiroshi Matoba Date: Fri, 14 Dec 2018 15:58:00 +0100 Subject: [PATCH 6/6] add more constructor to support ofReadOnlyParameter --- libs/openFrameworks/types/ofParameter.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index df39d5c30b9..1d19927d649 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -1115,6 +1115,7 @@ class ofReadOnlyParameter: public ofAbstractParameter{ // ofReadOnlyParameter(ofReadOnlyParameter & p); ofReadOnlyParameter(const ParameterType & v); ofReadOnlyParameter(const std::string& name, const ParameterType & v); + ofReadOnlyParameter(const std::string& name, const ParameterType & v, bool serializable); ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max); ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max, bool serializable); @@ -1238,6 +1239,10 @@ template inline ofReadOnlyParameter::ofReadOnlyParameter(const std::string& name, const ParameterType & v) :parameter(name,v){} +template +inline ofReadOnlyParameter::ofReadOnlyParameter(const std::string& name, const ParameterType & v, bool serializable) +:parameter(name,v, serializable){} + template inline ofReadOnlyParameter::ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max) :parameter(name,v,min,max){}