From 459ff0b31e2f206b5069bafa218ba20daaa06662 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Fri, 24 Nov 2023 00:05:03 -0500 Subject: [PATCH 01/11] ofEvent::notify(): code deduplication by wrapping the complete flavour in the nullptr one --- libs/openFrameworks/events/ofEvent.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/libs/openFrameworks/events/ofEvent.h b/libs/openFrameworks/events/ofEvent.h index 7a1fd7e8497..3b80b7ad8b3 100644 --- a/libs/openFrameworks/events/ofEvent.h +++ b/libs/openFrameworks/events/ofEvent.h @@ -580,17 +580,7 @@ class ofEvent: public of::priv::BaseEvent,Mutex>{ } inline bool notify(T & param){ - if(ofEvent::self->enabled && !ofEvent::self->functions.empty()){ - std::unique_lock lck(ofEvent::self->mtx); - auto functions_copy = ofEvent::self->functions; - lck.unlock(); - for(auto & f: functions_copy){ - if(f->notify(nullptr,param)){ - return true; - } - } - } - return false; + return this->notify(nullptr, param); } }; From db903e53cb93230373d9472be7558387fc8e5688 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Fri, 24 Nov 2023 00:48:08 -0500 Subject: [PATCH 02/11] ofEvent::notify(): code deduplication by wrapping the complete flavour in the nullptr one for the version --- libs/openFrameworks/events/ofEvent.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/libs/openFrameworks/events/ofEvent.h b/libs/openFrameworks/events/ofEvent.h index 3b80b7ad8b3..7e48e37efb1 100644 --- a/libs/openFrameworks/events/ofEvent.h +++ b/libs/openFrameworks/events/ofEvent.h @@ -728,17 +728,7 @@ class ofEvent: public of::priv::BaseEvent::self->enabled && !ofEvent::self->functions.empty()){ - std::unique_lock lck(ofEvent::self->mtx); - auto functions_copy = ofEvent::self->functions; - lck.unlock(); - for(auto & f: functions_copy){ - if(f->notify(nullptr)){ - return true; - } - } - } - return false; + return this->notify(nullptr); } }; From 83f7031b54023188deff5b38130a8bff25c9c90f Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Fri, 24 Nov 2023 20:57:33 -0500 Subject: [PATCH 03/11] ofEvent::did_notify(): initial implementation --- libs/openFrameworks/events/ofEvent.h | 62 +++++++++++++++++++++------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/libs/openFrameworks/events/ofEvent.h b/libs/openFrameworks/events/ofEvent.h index 7e48e37efb1..ac074f4ec02 100644 --- a/libs/openFrameworks/events/ofEvent.h +++ b/libs/openFrameworks/events/ofEvent.h @@ -565,15 +565,30 @@ class ofEvent: public of::priv::BaseEvent,Mutex>{ ofEvent::self->remove(*make_function(std::function::function_type>(function), priority)->id); } - inline bool notify(const void* sender, T & param){ - if(ofEvent::self->enabled && !ofEvent::self->functions.empty()){ - std::unique_lock lck(ofEvent::self->mtx); - auto functions_copy = ofEvent::self->functions; - lck.unlock(); - for(auto & f: functions_copy){ - if(f->notify(sender,param)){ - return true; - } + /// \brief checks the state of the event + /// \returns true if the Event's state was notified since the last check + bool did_notify() { + if (notified.load(std::memory_order_relaxed)) { + notified.store(false, std::memory_order_seq_cst); + return true; + } else { + return false; + } + } + std::atomic notified; + + inline bool notify(const void* sender, T & param) { + if (ofEvent::self->enabled) { + notified.store(true, std::memory_order_relaxed); + if (!ofEvent::self->functions.empty()) { + std::unique_lock lck(ofEvent::self->mtx); + auto functions_copy = ofEvent::self->functions; + lck.unlock(); + for (auto & f: functions_copy) { + if (f->notify(sender,param)) { + return true; + } + } } } return false; @@ -713,14 +728,29 @@ class ofEvent: public of::priv::BaseEvent::self->remove(*make_function(std::function::function_type>(function),priority)->id); } + /// \brief checks the state of the event + /// \returns true if the Event's state was notified since the last check + bool did_notify() { + if (notified_.load(std::memory_order_relaxed)) { + notified_.store(false, std::memory_order_seq_cst); + return true; + } else { + return false; + } + } + std::atomic notified_; + bool notify(const void* sender){ - if(ofEvent::self->enabled && !ofEvent::self->functions.empty()){ - std::unique_lock lck(ofEvent::self->mtx); - auto functions_copy = ofEvent::self->functions; - lck.unlock(); - for(auto & f: functions_copy){ - if(f->notify(sender)){ - return true; + if(ofEvent::self->enabled) { + notified_.store(true, std::memory_order_relaxed); + if (!ofEvent::self->functions.empty()) { + std::unique_lock lck(ofEvent::self->mtx); + auto functions_copy = ofEvent::self->functions; + lck.unlock(); + for (auto & f: functions_copy) { + if (f->notify(sender)) { + return true; + } } } } From 1a21bf84ca39355fec8abc99f63008e936aa52c1 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Fri, 24 Nov 2023 20:57:58 -0500 Subject: [PATCH 04/11] ofParameter::did_notify(): initial implementation --- libs/openFrameworks/types/ofParameter.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index de83c666dc3..a5cbe260f5e 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -516,6 +516,12 @@ class ofParameter: public ofAbstractParameter{ ParameterType getInit() const; void reInit(); + /// \brief queries the parameter's event about its notification state + /// \returns true if the event was notified since last check + auto did_notify() { + return obj->changedE.did_notify(); + } + std::string toString() const; void fromString(const std::string & name); @@ -1047,6 +1053,12 @@ class ofParameter: public ofAbstractParameter{ return obj->changedE.newListener(args...); } + /// \brief queries the parameter's event about its notification state + /// \returns true if the event was notified since last check + auto did_notify() { + return obj->changedE.did_notify(); + } + void trigger(); void trigger(const void * sender); From 6841d35c2580993f6a091cfd4b75bbb6b8930e18 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Fri, 24 Nov 2023 21:00:13 -0500 Subject: [PATCH 05/11] clang-format --- libs/openFrameworks/types/ofParameter.h | 1353 +++++++++++------------ 1 file changed, 658 insertions(+), 695 deletions(-) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index a5cbe260f5e..15c060500a9 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -1,29 +1,27 @@ #pragma once +#include "ofColor.h" +#include "ofConstants.h" #include "ofEvents.h" +#include "ofLog.h" #include "ofPoint.h" #include "ofRectangle.h" -#include "ofLog.h" -#include "ofConstants.h" -#include "ofColor.h" #include -template +template class ofParameter; -template +template class ofReadOnlyParameter; class ofParameterGroup; - - //---------------------------------------------------------------------- /// Base class for ofParameter, ofReadOnlyParameter and ofParameterGroup -class ofAbstractParameter{ +class ofAbstractParameter { public: - virtual ~ofAbstractParameter(){} + virtual ~ofAbstractParameter() { } virtual std::string getName() const = 0; virtual void setName(const std::string & name) = 0; virtual std::string toString() const = 0; @@ -36,75 +34,72 @@ class ofAbstractParameter{ virtual void setParent(ofParameterGroup & _parent) = 0; std::vector getGroupHierarchyNames() const; - template - ofParameter & cast(){ + template + ofParameter & cast() { return static_cast &>(*this); } - template - const ofParameter & cast() const{ + template + const ofParameter & cast() const { return static_cast &>(*this); } - template - ofReadOnlyParameter & castReadOnly(){ + template + ofReadOnlyParameter & castReadOnly() { return static_cast &>(*this); } - template - const ofReadOnlyParameter & castReadOnly() const{ + template + const ofReadOnlyParameter & castReadOnly() const { return static_cast &>(*this); } - template + template bool isOfType() const { return typeid(*this) == typeid(ofParameter); } - + ofParameterGroup & castGroup(); const ofParameterGroup & castGroup() const; - friend std::ostream& operator<<(std::ostream& os, const ofAbstractParameter& p); - friend std::istream& operator>>(std::istream& is, ofAbstractParameter& p); + friend std::ostream & operator<<(std::ostream & os, const ofAbstractParameter & p); + friend std::istream & operator>>(std::istream & is, ofAbstractParameter & p); virtual bool isSerializable() const = 0; virtual bool isReadOnly() const = 0; virtual std::shared_ptr newReference() const = 0; - virtual bool isReferenceTo(const ofAbstractParameter& other) const; + virtual bool isReferenceTo(const ofAbstractParameter & other) const; protected: virtual const ofParameterGroup getFirstParent() const = 0; - virtual void setSerializable(bool serializable)=0; - virtual std::string escape(const std::string& str) const; - virtual const void* getInternalObject() const = 0; + virtual void setSerializable(bool serializable) = 0; + virtual std::string escape(const std::string & str) const; + virtual const void * getInternalObject() const = 0; }; - - - //---------------------------------------------------------------------- /// A collection of parameters with events to notify if a parameter changed /// and serialization facilities -class ofParameterGroup: public ofAbstractParameter { +class ofParameterGroup : public ofAbstractParameter { public: ofParameterGroup(); - template + template ofParameterGroup(const std::string & name) - :obj(std::make_shared()){ + : obj(std::make_shared()) { setName(name); } - template - ofParameterGroup(const std::string & name, Args&... p) - :obj(std::make_shared()){ + template + ofParameterGroup(const std::string & name, Args &... p) + : obj(std::make_shared()) { add(p...); setName(name); } - template - void add(ofAbstractParameter & p, Args&... parameters){ + template + void add(ofAbstractParameter & p, Args &... parameters) { add(p); add(parameters...); } @@ -114,26 +109,25 @@ class ofParameterGroup: public ofAbstractParameter { void remove(ofAbstractParameter & param); void remove(std::size_t index); - void remove(const std::string& name); + void remove(const std::string & name); void clear(); - const ofParameter & getVoid(const std::string& name) const; - const ofParameter & getBool(const std::string& name) const; - const ofParameter & getInt(const std::string& name) const; - const ofParameter & getFloat(const std::string& name) const; - const ofParameter & getChar(const std::string& name) const; - const ofParameter & getString(const std::string& name) const; - const ofParameter & getPoint(const std::string& name) const; - const ofParameter & getVec2f(const std::string& name) const; - const ofParameter & getVec3f(const std::string& name) const; - const ofParameter & getVec4f(const std::string& name) const; - const ofParameter & getColor(const std::string& name) const; - const ofParameter & getShortColor(const std::string& name) const; - const ofParameter & getFloatColor(const std::string& name) const; - const ofParameter & getRectangle(const std::string& name) const; - const ofParameterGroup & getGroup(const std::string& name) const; - + const ofParameter & getVoid(const std::string & name) const; + const ofParameter & getBool(const std::string & name) const; + const ofParameter & getInt(const std::string & name) const; + const ofParameter & getFloat(const std::string & name) const; + const ofParameter & getChar(const std::string & name) const; + const ofParameter & getString(const std::string & name) const; + const ofParameter & getPoint(const std::string & name) const; + const ofParameter & getVec2f(const std::string & name) const; + const ofParameter & getVec3f(const std::string & name) const; + const ofParameter & getVec4f(const std::string & name) const; + const ofParameter & getColor(const std::string & name) const; + const ofParameter & getShortColor(const std::string & name) const; + const ofParameter & getFloatColor(const std::string & name) const; + const ofParameter & getRectangle(const std::string & name) const; + const ofParameterGroup & getGroup(const std::string & name) const; const ofParameter & getVoid(std::size_t pos) const; const ofParameter & getBool(std::size_t pos) const; @@ -151,22 +145,21 @@ class ofParameterGroup: public ofAbstractParameter { const ofParameter & getRectangle(std::size_t pos) const; const ofParameterGroup & getGroup(std::size_t pos) const; - ofParameter & getVoid(const std::string& name); - ofParameter & getBool(const std::string& name); - ofParameter & getInt(const std::string& name); - ofParameter & getFloat(const std::string& name); - ofParameter & getChar(const std::string& name); - ofParameter & getString(const std::string& name); - ofParameter & getPoint(const std::string& name); - ofParameter & getVec2f(const std::string& name); - ofParameter & getVec3f(const std::string& name); - ofParameter & getVec4f(const std::string& name); - ofParameter & getColor(const std::string& name); - ofParameter & getShortColor(const std::string& name); - ofParameter & getFloatColor(const std::string& name); - ofParameter & getRectangle(const std::string& name); - ofParameterGroup & getGroup(const std::string& name); - + ofParameter & getVoid(const std::string & name); + ofParameter & getBool(const std::string & name); + ofParameter & getInt(const std::string & name); + ofParameter & getFloat(const std::string & name); + ofParameter & getChar(const std::string & name); + ofParameter & getString(const std::string & name); + ofParameter & getPoint(const std::string & name); + ofParameter & getVec2f(const std::string & name); + ofParameter & getVec3f(const std::string & name); + ofParameter & getVec4f(const std::string & name); + ofParameter & getColor(const std::string & name); + ofParameter & getShortColor(const std::string & name); + ofParameter & getFloatColor(const std::string & name); + ofParameter & getRectangle(const std::string & name); + ofParameterGroup & getGroup(const std::string & name); ofParameter & getVoid(std::size_t pos); ofParameter & getBool(std::size_t pos); @@ -184,57 +177,57 @@ class ofParameterGroup: public ofAbstractParameter { ofParameter & getRectangle(std::size_t pos); ofParameterGroup & getGroup(std::size_t pos); - const ofAbstractParameter & get(const std::string& name) const; + const ofAbstractParameter & get(const std::string & name) const; const ofAbstractParameter & get(std::size_t pos) const; - const ofAbstractParameter & operator[](const std::string& name) const; + const ofAbstractParameter & operator[](const std::string & name) const; const ofAbstractParameter & operator[](std::size_t pos) const; - ofAbstractParameter & get(const std::string& name); + ofAbstractParameter & get(const std::string & name); ofAbstractParameter & get(std::size_t pos); - ofAbstractParameter & operator[](const std::string& name); + ofAbstractParameter & operator[](const std::string & name); ofAbstractParameter & operator[](std::size_t pos); - template - const ofParameter & get(const std::string& name) const; + template + const ofParameter & get(const std::string & name) const; - template + template const ofParameter & get(std::size_t pos) const; - template - ofParameter & get(const std::string& name); + template + ofParameter & get(const std::string & name); - template + template ofParameter & get(std::size_t pos); - template - const ofReadOnlyParameter & getReadOnly(const std::string& name) const; + template + const ofReadOnlyParameter & getReadOnly(const std::string & name) const; - template + template const ofReadOnlyParameter & getReadOnly(std::size_t pos) const; - template - ofReadOnlyParameter & getReadOnly(const std::string& name); + template + ofReadOnlyParameter & getReadOnly(const std::string & name); - template + template ofReadOnlyParameter & getReadOnly(std::size_t pos); std::size_t size() const; std::string getName(std::size_t position) const; std::string getType(std::size_t position) const; bool getIsReadOnly(int position) const; - int getPosition(const std::string& name) const; + int getPosition(const std::string & name) const; - friend std::ostream& operator<<(std::ostream& os, const ofParameterGroup& group); + friend std::ostream & operator<<(std::ostream & os, const ofParameterGroup & group); std::string getName() const; - void setName(const std::string& name); + void setName(const std::string & name); std::string getEscapedName() const; std::string toString() const; - void fromString(const std::string& name); + void fromString(const std::string & name); - bool contains(const std::string& name) const; + bool contains(const std::string & name) const; ofAbstractParameter & back(); ofAbstractParameter & front(); @@ -252,28 +245,28 @@ class ofParameterGroup: public ofAbstractParameter { ofEvent & parameterChangedE(); - std::vector >::iterator begin(); - std::vector >::iterator end(); - std::vector >::const_iterator begin() const; - std::vector >::const_iterator end() const; - std::vector >::reverse_iterator rbegin(); - std::vector >::reverse_iterator rend(); - std::vector >::const_reverse_iterator rbegin() const; - std::vector >::const_reverse_iterator rend() const; + std::vector>::iterator begin(); + std::vector>::iterator end(); + std::vector>::const_iterator begin() const; + std::vector>::const_iterator end() const; + std::vector>::reverse_iterator rbegin(); + std::vector>::reverse_iterator rend(); + std::vector>::const_reverse_iterator rbegin() const; + std::vector>::const_reverse_iterator rend() const; protected: - const void* getInternalObject() const; + const void * getInternalObject() const; private: - class Value{ + class Value { public: Value() - :serializable(true){} + : serializable(true) { } void notifyParameterChanged(ofAbstractParameter & param); - std::map parametersIndex; - std::vector > parameters; + std::map parametersIndex; + std::vector> parameters; std::string name; bool serializable; std::vector> parents; @@ -281,208 +274,205 @@ class ofParameterGroup: public ofAbstractParameter { }; std::shared_ptr obj; ofParameterGroup(std::shared_ptr obj) - :obj(obj){} + : obj(obj) { } - template + template friend class ofParameter; - template + template friend class ofReadOnlyParameter; const ofParameterGroup getFirstParent() const; }; -template -const ofParameter & ofParameterGroup::get(const std::string& name) const{ - return static_cast& >(get(name)); +template +const ofParameter & ofParameterGroup::get(const std::string & name) const { + return static_cast &>(get(name)); } -template -const ofParameter & ofParameterGroup::get(std::size_t pos) const{ - return static_cast& >(get(pos)); +template +const ofParameter & ofParameterGroup::get(std::size_t pos) const { + return static_cast &>(get(pos)); } -template -ofParameter & ofParameterGroup::get(const std::string& name){ - return static_cast& >(get(name)); +template +ofParameter & ofParameterGroup::get(const std::string & name) { + return static_cast &>(get(name)); } -template -ofParameter & ofParameterGroup::get(std::size_t pos){ - return static_cast& >(get(pos)); +template +ofParameter & ofParameterGroup::get(std::size_t pos) { + return static_cast &>(get(pos)); } - -template -const ofReadOnlyParameter & ofParameterGroup::getReadOnly(const std::string& name) const{ - return static_cast& >(get(name)); +template +const ofReadOnlyParameter & ofParameterGroup::getReadOnly(const std::string & name) const { + return static_cast &>(get(name)); } -template -const ofReadOnlyParameter & ofParameterGroup::getReadOnly(std::size_t pos) const{ - return static_cast& >(get(pos)); +template +const ofReadOnlyParameter & ofParameterGroup::getReadOnly(std::size_t pos) const { + return static_cast &>(get(pos)); } -template -ofReadOnlyParameter & ofParameterGroup::getReadOnly(const std::string& name){ - return static_cast& >(get(name)); +template +ofReadOnlyParameter & ofParameterGroup::getReadOnly(const std::string & name) { + return static_cast &>(get(name)); } -template -ofReadOnlyParameter & ofParameterGroup::getReadOnly(std::size_t pos){ - return static_cast& >(get(pos)); +template +ofReadOnlyParameter & ofParameterGroup::getReadOnly(std::size_t pos) { + return static_cast &>(get(pos)); } - /*! \cond PRIVATE */ -namespace of{ -namespace priv{ - //---------------------------------------------------------------------- - // Mechanism to provide min and max default values for types where it makes sense - template - struct TypeInfo_ { - }; +namespace of { +namespace priv { +//---------------------------------------------------------------------- +// Mechanism to provide min and max default values for types where it makes sense +template +struct TypeInfo_ { +}; - // Types with numeric_limits resolve to this template specialization: - template - struct TypeInfo_ { - static T min() { return std::numeric_limits::lowest(); } - static T max() { return std::numeric_limits::max(); } - }; +// Types with numeric_limits resolve to this template specialization: +template +struct TypeInfo_ { + static T min() { return std::numeric_limits::lowest(); } + static T max() { return std::numeric_limits::max(); } +}; - template<> - struct TypeInfo_ { - static float min() { return 0; } - static float max() { return 1; } - }; +template <> +struct TypeInfo_ { + static float min() { return 0; } + static float max() { return 1; } +}; - template<> - struct TypeInfo_ { - static float min() { return 0; } - static float max() { return 1; } - }; +template <> +struct TypeInfo_ { + static float min() { return 0; } + static float max() { return 1; } +}; - // Types without numeric_limits resolve to this template specialization: - template - struct TypeInfo_ { - static T min() { return T(); } - static T max() { return T(); } - }; +// Types without numeric_limits resolve to this template specialization: +template +struct TypeInfo_ { + static T min() { return T(); } + static T max() { return T(); } +}; - template - struct TypeInfo : public of::priv::TypeInfo_::is_specialized> { - }; +template +struct TypeInfo : public of::priv::TypeInfo_::is_specialized> { +}; - // Here we provide some of our own specializations: - template<> - struct TypeInfo { - static ofVec2f min() { return ofVec2f(0); } - static ofVec2f max() { return ofVec2f(1); } - }; +// Here we provide some of our own specializations: +template <> +struct TypeInfo { + static ofVec2f min() { return ofVec2f(0); } + static ofVec2f max() { return ofVec2f(1); } +}; - template<> - struct TypeInfo { - static glm::vec2 min() { return glm::vec2(0); } - static glm::vec2 max() { return glm::vec2(1); } - }; +template <> +struct TypeInfo { + static glm::vec2 min() { return glm::vec2(0); } + static glm::vec2 max() { return glm::vec2(1); } +}; - template<> - struct TypeInfo { - static ofVec3f min() { return ofVec3f(0); } - static ofVec3f max() { return ofVec3f(1); } - }; +template <> +struct TypeInfo { + static ofVec3f min() { return ofVec3f(0); } + static ofVec3f max() { return ofVec3f(1); } +}; - template<> - struct TypeInfo { - static glm::vec3 min() { return glm::vec3(0); } - static glm::vec3 max() { return glm::vec3(1); } - }; +template <> +struct TypeInfo { + static glm::vec3 min() { return glm::vec3(0); } + static glm::vec3 max() { return glm::vec3(1); } +}; - template<> - struct TypeInfo { - static ofVec4f min() { return ofVec4f(0); } - static ofVec4f max() { return ofVec4f(1); } - }; +template <> +struct TypeInfo { + static ofVec4f min() { return ofVec4f(0); } + static ofVec4f max() { return ofVec4f(1); } +}; - template<> - struct TypeInfo { - static glm::vec4 min() { return glm::vec4(0); } - static glm::vec4 max() { return glm::vec4(1); } - }; +template <> +struct TypeInfo { + static glm::vec4 min() { return glm::vec4(0); } + static glm::vec4 max() { return glm::vec4(1); } +}; - template - struct TypeInfo > { - static ofColor_ min() { return ofColor_(0,0); } - static ofColor_ max() { return ofColor_(ofColor_::limit(),ofColor_::limit()); } - }; - template<> - struct TypeInfo { +template +struct TypeInfo> { + static ofColor_ min() { return ofColor_(0, 0); } + static ofColor_ max() { return ofColor_(ofColor_::limit(), ofColor_::limit()); } +}; +template <> +struct TypeInfo { //Not really sure what would make sense here!!! - static ofRectangle min() { return ofRectangle(0,0,0,0); } - static ofRectangle max() { return ofRectangle(0,0,1,1); } - }; - - - // detection of stream operators - typedef char yes; - typedef char (&no)[2]; + static ofRectangle min() { return ofRectangle(0, 0, 0, 0); } + static ofRectangle max() { return ofRectangle(0, 0, 1, 1); } +}; - struct anyx { template anyx(const T &); }; +// detection of stream operators +typedef char yes; +typedef char (&no)[2]; - no operator << (const anyx &, const anyx &); - no operator >> (const anyx &, const anyx &); +struct anyx { + template + anyx(const T &); +}; - - template yes check_op(T const&); - no check_op(no); +no operator<<(const anyx &, const anyx &); +no operator>>(const anyx &, const anyx &); - template - struct has_loading_support { - static std::istream & stream; - static T & x; - static constexpr bool value = sizeof(check_op(stream >> x)) == sizeof(yes); - }; +template +yes check_op(T const &); +no check_op(no); - template - struct has_saving_support { - static std::ostream & stream; - static T & x; - static constexpr bool value = sizeof(check_op(stream << x)) == sizeof(yes); - }; +template +struct has_loading_support { + static std::istream & stream; + static T & x; + static constexpr bool value = sizeof(check_op(stream >> x)) == sizeof(yes); +}; - template - struct has_stream_operators { - static constexpr bool can_load = has_loading_support::value; - static constexpr bool can_save = has_saving_support::value; - static constexpr bool value = can_load && can_save; - }; +template +struct has_saving_support { + static std::ostream & stream; + static T & x; + static constexpr bool value = sizeof(check_op(stream << x)) == sizeof(yes); +}; - template - typename std::enable_if::value, std::string>::type toStringImpl(const ParameterType & value){ - return ofToString(value); - } +template +struct has_stream_operators { + static constexpr bool can_load = has_loading_support::value; + static constexpr bool can_save = has_saving_support::value; + static constexpr bool value = can_load && can_save; +}; - template - typename std::enable_if::value, std::string>::type toStringImpl(const ParameterType &){ - throw std::exception(); - } +template +typename std::enable_if::value, std::string>::type toStringImpl(const ParameterType & value) { + return ofToString(value); +} - template - typename std::enable_if::value, ParameterType>::type fromStringImpl(const std::string & str){ - return ofFromString(str); - } +template +typename std::enable_if::value, std::string>::type toStringImpl(const ParameterType &) { + throw std::exception(); +} - template - typename std::enable_if::value, ParameterType>::type fromStringImpl(const std::string &){ - throw std::exception(); +template +typename std::enable_if::value, ParameterType>::type fromStringImpl(const std::string & str) { + return ofFromString(str); +} - } +template +typename std::enable_if::value, ParameterType>::type fromStringImpl(const std::string &) { + throw std::exception(); +} } } /*! \endcond */ - - /// \brief ofParameter holds a value and notifies its listeners when it changes. /// /// ofParameter can be used as the value itself. For example an `ofParameter` @@ -493,50 +483,50 @@ namespace priv{ /// e.g. `myObject->myMethod();`. /// /// \tparam ParameterType The data wrapped by the ofParameter. -template -class ofParameter: public ofAbstractParameter{ +template +class ofParameter : public ofAbstractParameter { public: ofParameter(); ofParameter(const ofParameter & v); 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); + ofParameter(const std::string & name, const ParameterType & v, const ParameterType & min, const ParameterType & max); const ParameterType & get() const; const ParameterType * operator->() const; - operator const ParameterType & () const; + operator const ParameterType &() const; void setName(const std::string & name); std::string getName() const; ParameterType getMin() const; - ParameterType getMax() const; + ParameterType getMax() const; - ParameterType getInit() const; - void reInit(); + ParameterType getInit() const; + void reInit(); /// \brief queries the parameter's event about its notification state /// \returns true if the event was notified since last check auto did_notify() { return obj->changedE.did_notify(); } - + std::string toString() const; void fromString(const std::string & name); - template - void addListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){ - ofAddListener(obj->changedE,listener,method,prio); + template + void addListener(ListenerClass * listener, ListenerMethod method, int prio = OF_EVENT_ORDER_AFTER_APP) { + ofAddListener(obj->changedE, listener, method, prio); } - template - void removeListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){ - ofRemoveListener(obj->changedE,listener,method,prio); + template + void removeListener(ListenerClass * listener, ListenerMethod method, int prio = OF_EVENT_ORDER_AFTER_APP) { + ofRemoveListener(obj->changedE, listener, method, prio); } - template - std::unique_ptr newListener(Args...args) { + template + std::unique_ptr newListener(Args... args) { return obj->changedE.newListener(args...); } @@ -557,94 +547,92 @@ class ofParameter: public ofAbstractParameter{ ParameterType operator--(int v); ofParameter & operator--(); - template + template ofParameter & operator+=(const OtherType & v); - template + template ofParameter & operator-=(const OtherType & v); - template + template ofParameter & operator*=(const OtherType & v); - template + template ofParameter & operator/=(const OtherType & v); - template + template ofParameter & operator%=(const OtherType & v); - template + template ofParameter & operator&=(const OtherType & v); - template + template ofParameter & operator|=(const OtherType & v); - template + template ofParameter & operator^=(const OtherType & v); - template + template ofParameter & operator<<=(const OtherType & v); - template + template ofParameter & operator>>=(const OtherType & v); - 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); + ofParameter & set(const std::string & name, const ParameterType & v, const ParameterType & min, const ParameterType & max); ofParameter & setWithoutEventNotifications(const ParameterType & v); void setMin(const ParameterType & min); - void setMax(const ParameterType & max); - void setInit(const ParameterType & init); + void setMax(const ParameterType & max); + void setInit(const ParameterType & init); void setSerializable(bool serializable); std::shared_ptr newReference() const; void setParent(ofParameterGroup & _parent); - const ofParameterGroup getFirstParent() const{ - obj->parents.erase(std::remove_if(obj->parents.begin(),obj->parents.end(), - [](std::weak_ptr p){return p.lock()==nullptr;}), - obj->parents.end()); - if(!obj->parents.empty()){ + const ofParameterGroup getFirstParent() const { + obj->parents.erase(std::remove_if(obj->parents.begin(), obj->parents.end(), + [](std::weak_ptr p) { return p.lock() == nullptr; }), + obj->parents.end()); + if (!obj->parents.empty()) { return obj->parents.front().lock(); - }else{ + } else { return std::shared_ptr(nullptr); } } size_t getNumListeners() const; - const void* getInternalObject() const; + const void * getInternalObject() const; protected: - private: - class Value{ + class Value { public: Value() - :init(of::priv::TypeInfo::min()) - ,min(of::priv::TypeInfo::min()) - ,max(of::priv::TypeInfo::max()) - ,bInNotify(false) - ,serializable(true){} + : init(of::priv::TypeInfo::min()) + , min(of::priv::TypeInfo::min()) + , max(of::priv::TypeInfo::max()) + , bInNotify(false) + , serializable(true) { } Value(ParameterType v) - :init(v) - ,value(v) - ,min(of::priv::TypeInfo::min()) - ,max(of::priv::TypeInfo::max()) - ,bInNotify(false) - ,serializable(true){} + : init(v) + , value(v) + , min(of::priv::TypeInfo::min()) + , max(of::priv::TypeInfo::max()) + , bInNotify(false) + , serializable(true) { } Value(std::string name, ParameterType v) - :name(name) - ,init(v) - ,value(v) - ,min(of::priv::TypeInfo::min()) - ,max(of::priv::TypeInfo::max()) - ,bInNotify(false) - ,serializable(true){} + : name(name) + , init(v) + , value(v) + , min(of::priv::TypeInfo::min()) + , max(of::priv::TypeInfo::max()) + , bInNotify(false) + , serializable(true) { } Value(std::string name, ParameterType v, ParameterType min, ParameterType max) - :name(name) - ,init(v) - ,value(v) - ,min(min) - ,max(max) - ,bInNotify(false) - ,serializable(true){} + : name(name) + , init(v) + , value(v) + , min(min) + , max(max) + , bInNotify(false) + , serializable(true) { } std::string name; ParameterType init, value, min, max; @@ -660,97 +648,92 @@ class ofParameter: public ofAbstractParameter{ void eventsSetValue(const ParameterType & v); void noEventsSetValue(const ParameterType & v); - template + template friend class ofReadOnlyParameter; }; - -template +template ofParameter::ofParameter() -:obj(std::make_shared()) -,setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)){} + : obj(std::make_shared()) + , setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)) { } -template +template ofParameter::ofParameter(const ofParameter & v) -:obj(v.obj) -,setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)) {} + : obj(v.obj) + , setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)) { } -template +template ofParameter::ofParameter(const ParameterType & v) -:obj(std::make_shared(v)) -,setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)) {} + : obj(std::make_shared(v)) + , setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)) { } -template -ofParameter::ofParameter(const std::string& name, const ParameterType & v) -: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) + : 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, const ParameterType & min, const ParameterType & max) -: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) + : obj(std::make_shared(name, v, min, max)) + , setMethod(std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1)) { } - -template -inline ofParameter & ofParameter::operator=(const ofParameter & v){ +template +inline ofParameter & ofParameter::operator=(const ofParameter & v) { set(v); return *this; } -template -inline const ParameterType & ofParameter::operator=(const ParameterType & v){ +template +inline const ParameterType & ofParameter::operator=(const ParameterType & v) { set(v); return obj->value; } -template -inline ofParameter & ofParameter::set(const ParameterType & v){ +template +inline ofParameter & ofParameter::set(const ParameterType & v) { setMethod(v); return *this; } -template -ofParameter & ofParameter::set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max){ +template +ofParameter & ofParameter::set(const std::string & name, const ParameterType & value, const ParameterType & min, const ParameterType & max) { setName(name); set(value); setMin(min); setMax(max); - setInit(value); + setInit(value); return *this; } -template -ofParameter & ofParameter::set(const std::string& name, const ParameterType & value){ +template +ofParameter & ofParameter::set(const std::string & name, const ParameterType & value) { setName(name); set(value); return *this; } -template -inline ofParameter & ofParameter::setWithoutEventNotifications(const ParameterType & v){ +template +inline ofParameter & ofParameter::setWithoutEventNotifications(const ParameterType & v) { noEventsSetValue(v); return *this; } -template -inline const ParameterType & ofParameter::get() const{ +template +inline const ParameterType & ofParameter::get() const { return obj->value; } -template -inline const ParameterType * ofParameter::operator->() const{ +template +inline const ParameterType * ofParameter::operator->() const { return &obj->value; } -template -inline void ofParameter::eventsSetValue(const ParameterType & v){ +template +inline void ofParameter::eventsSetValue(const ParameterType & v) { // If the object is notifying its parents, just set the value without triggering an event. - if(obj->bInNotify) - { + if (obj->bInNotify) { noEventsSetValue(v); - } - else - { + } else { // Mark the object as in its notification loop. obj->bInNotify = true; @@ -758,24 +741,23 @@ inline void ofParameter::eventsSetValue(const ParameterType & v){ obj->value = v; // Notify any local subscribers. - ofNotifyEvent(obj->changedE,obj->value,this); + ofNotifyEvent(obj->changedE, obj->value, this); // Notify all parents, if there are any. - if(!obj->parents.empty()) - { + if (!obj->parents.empty()) { // Erase each invalid parent obj->parents.erase(std::remove_if(obj->parents.begin(), - obj->parents.end(), - [](const std::weak_ptr & p){ return p.expired(); }), - obj->parents.end()); + obj->parents.end(), + [](const std::weak_ptr & p) { return p.expired(); }), + obj->parents.end()); // notify all leftover (valid) parents of this object's changed value. // this can't happen in the same iterator as above, because a notified listener // might perform similar cleanups that would corrupt our iterator // (which appens for example if the listener calls getFirstParent on us) - for(auto & parent: obj->parents){ + for (auto & parent : obj->parents) { auto p = parent.lock(); - if(p){ + if (p) { p->notifyParameterChanged(*this); } } @@ -784,253 +766,252 @@ inline void ofParameter::eventsSetValue(const ParameterType & v){ } } -template -inline void ofParameter::noEventsSetValue(const ParameterType & v){ +template +inline void ofParameter::noEventsSetValue(const ParameterType & v) { obj->value = v; } - -template -void ofParameter::setSerializable(bool serializable){ +template +void ofParameter::setSerializable(bool serializable) { obj->serializable = serializable; } -template -bool ofParameter::isSerializable() const{ +template +bool ofParameter::isSerializable() const { return of::priv::has_stream_operators::value && obj->serializable; } -template -bool ofParameter::isReadOnly() const{ +template +bool ofParameter::isReadOnly() const { return false; } -template -std::string ofParameter::valueType() const{ +template +std::string ofParameter::valueType() const { return typeid(ParameterType).name(); } -template -void ofParameter::setMin(const ParameterType & min){ +template +void ofParameter::setMin(const ParameterType & min) { obj->min = min; } -template +template ParameterType ofParameter::getMin() const { return obj->min; } -template -void ofParameter::setMax(const ParameterType & max){ - obj->max = max; +template +void ofParameter::setMax(const ParameterType & max) { + obj->max = max; } -template +template ParameterType ofParameter::getMax() const { - return obj->max; + return obj->max; } -template -void ofParameter::setInit(const ParameterType & init){ - obj->init = init; +template +void ofParameter::setInit(const ParameterType & init) { + obj->init = init; } -template +template ParameterType ofParameter::getInit() const { - return obj->init; + return obj->init; } -template +template void ofParameter::reInit() { - setMethod(obj->init); + setMethod(obj->init); } -template -inline ofParameter::operator const ParameterType & () const{ +template +inline ofParameter::operator const ParameterType &() const { return obj->value; } -template -void ofParameter::setName(const std::string & name){ +template +void ofParameter::setName(const std::string & name) { obj->name = name; } -template -std::string ofParameter::getName() const{ +template +std::string ofParameter::getName() const { return obj->name; } -template -inline std::string ofParameter::toString() const{ - try{ +template +inline std::string ofParameter::toString() const { + try { return of::priv::toStringImpl(obj->value); - }catch(...){ + } catch (...) { ofLogError("ofParameter") << "Trying to serialize non-serializable parameter"; return ""; } } -template -inline void ofParameter::fromString(const std::string & str){ - try{ +template +inline void ofParameter::fromString(const std::string & str) { + try { set(of::priv::fromStringImpl(str)); - }catch(...){ + } catch (...) { ofLogError("ofParameter") << "Trying to de-serialize non-serializable parameter"; } } -template -void ofParameter::enableEvents(){ +template +void ofParameter::enableEvents() { setMethod = std::bind(&ofParameter::eventsSetValue, this, std::placeholders::_1); } -template -void ofParameter::disableEvents(){ +template +void ofParameter::disableEvents() { setMethod = std::bind(&ofParameter::noEventsSetValue, this, std::placeholders::_1); } -template -inline ParameterType ofParameter::operator++(int){ +template +inline ParameterType ofParameter::operator++(int) { ParameterType r = obj->value; obj->value++; set(obj->value); return r; } -template -inline ofParameter & ofParameter::operator++(){ +template +inline ofParameter & ofParameter::operator++() { ++obj->value; set(obj->value); return *this; } -template -inline ParameterType ofParameter::operator--(int){ +template +inline ParameterType ofParameter::operator--(int) { ParameterType r = obj->value; obj->value--; set(obj->value); return r; } -template -inline ofParameter & ofParameter::operator--(){ +template +inline ofParameter & ofParameter::operator--() { --obj->value; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator+=(const OtherType & v){ - obj->value+=v; +template +template +inline ofParameter & ofParameter::operator+=(const OtherType & v) { + obj->value += v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator-=(const OtherType & v){ - obj->value-=v; +template +template +inline ofParameter & ofParameter::operator-=(const OtherType & v) { + obj->value -= v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator*=(const OtherType & v){ - obj->value*=v; +template +template +inline ofParameter & ofParameter::operator*=(const OtherType & v) { + obj->value *= v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator/=(const OtherType & v){ - obj->value/=v; +template +template +inline ofParameter & ofParameter::operator/=(const OtherType & v) { + obj->value /= v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator%=(const OtherType & v){ - obj->value%=v; +template +template +inline ofParameter & ofParameter::operator%=(const OtherType & v) { + obj->value %= v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator&=(const OtherType & v){ - obj->value&=v; +template +template +inline ofParameter & ofParameter::operator&=(const OtherType & v) { + obj->value &= v; set(obj->value); return *this; } -template -template -ofParameter & ofParameter::operator|=(const OtherType & v){ - obj->value|=v; +template +template +ofParameter & ofParameter::operator|=(const OtherType & v) { + obj->value |= v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator^=(const OtherType & v){ - obj->value^=v; +template +template +inline ofParameter & ofParameter::operator^=(const OtherType & v) { + obj->value ^= v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator<<=(const OtherType & v){ - obj->value<<=v; +template +template +inline ofParameter & ofParameter::operator<<=(const OtherType & v) { + obj->value <<= v; set(obj->value); return *this; } -template -template -inline ofParameter & ofParameter::operator>>=(const OtherType & v){ - obj->value>>=v; +template +template +inline ofParameter & ofParameter::operator>>=(const OtherType & v) { + obj->value >>= v; set(obj->value); return *this; } -template -void ofParameter::makeReferenceTo(ofParameter & mom){ +template +void ofParameter::makeReferenceTo(ofParameter & mom) { obj = mom.obj; } -template -std::shared_ptr ofParameter::newReference() const{ +template +std::shared_ptr ofParameter::newReference() const { return std::make_shared>(*this); } -template -void ofParameter::setParent(ofParameterGroup & parent){ +template +void ofParameter::setParent(ofParameterGroup & parent) { obj->parents.emplace_back(parent.obj); } -template -size_t ofParameter::getNumListeners() const{ +template +size_t ofParameter::getNumListeners() const { return obj->changedE.size(); } -template -const void* ofParameter::getInternalObject() const{ +template +const void * ofParameter::getInternalObject() const { return obj.get(); } -template<> -class ofParameter: public ofAbstractParameter{ +template <> +class ofParameter : public ofAbstractParameter { public: ofParameter(); - ofParameter(const std::string& name); + ofParameter(const std::string & name); - ofParameter& set(const std::string & name); + ofParameter & set(const std::string & name); void setName(const std::string & name); std::string getName() const; @@ -1038,18 +1019,18 @@ class ofParameter: public ofAbstractParameter{ std::string toString() const; void fromString(const std::string & name); - template - void addListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){ - ofAddListener(obj->changedE,listener,method,prio); + template + void addListener(ListenerClass * listener, ListenerMethod method, int prio = OF_EVENT_ORDER_AFTER_APP) { + ofAddListener(obj->changedE, listener, method, prio); } - template - void removeListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){ - ofRemoveListener(obj->changedE,listener,method,prio); + template + void removeListener(ListenerClass * listener, ListenerMethod method, int prio = OF_EVENT_ORDER_AFTER_APP) { + ofRemoveListener(obj->changedE, listener, method, prio); } - template - std::unique_ptr newListener(Args...args) { + template + std::unique_ptr newListener(Args... args) { return obj->changedE.newListener(args...); } @@ -1058,7 +1039,7 @@ class ofParameter: public ofAbstractParameter{ auto did_notify() { return obj->changedE.did_notify(); } - + void trigger(); void trigger(const void * sender); @@ -1075,30 +1056,30 @@ class ofParameter: public ofAbstractParameter{ void setParent(ofParameterGroup & _parent); - const ofParameterGroup getFirstParent() const{ - auto first = std::find_if(obj->parents.begin(),obj->parents.end(),[](std::weak_ptr p){return p.lock()!=nullptr;}); - if(first!=obj->parents.end()){ + const ofParameterGroup getFirstParent() const { + auto first = std::find_if(obj->parents.begin(), obj->parents.end(), [](std::weak_ptr p) { return p.lock() != nullptr; }); + if (first != obj->parents.end()) { return first->lock(); - }else{ + } else { return std::shared_ptr(nullptr); } } size_t getNumListeners() const; - const void* getInternalObject() const{ + const void * getInternalObject() const { return obj.get(); } -protected: +protected: private: - class Value{ + class Value { public: Value() - :serializable(false){} + : serializable(false) { } Value(std::string name) - :name(name) - ,serializable(false){} + : name(name) + , serializable(false) { } std::string name; ofEvent changedE; @@ -1108,8 +1089,6 @@ class ofParameter: public ofAbstractParameter{ std::shared_ptr obj; }; - - /// \brief ofReadOnlyParameter holds a value and notifies its listeners when it changes. /// /// ofReadOnlyParameter is a "read only" version of `ofPareameter`. "Friend" @@ -1120,19 +1099,19 @@ class ofParameter: public ofAbstractParameter{ /// \sa ofParameter /// \tparam ParameterType The data wrapped by the ofParameter. /// \tparam Friend The type of the "friend" class with write access. -template -class ofReadOnlyParameter: public ofAbstractParameter{ +template +class ofReadOnlyParameter : public ofAbstractParameter { public: ofReadOnlyParameter(); -// ofReadOnlyParameter(ofParameter & p); -// ofReadOnlyParameter(ofReadOnlyParameter & p); + // ofReadOnlyParameter(ofParameter & p); + // ofReadOnlyParameter(ofReadOnlyParameter & p); 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); + ofReadOnlyParameter(const std::string & name, const ParameterType & v, const ParameterType & min, const ParameterType & max); const ParameterType & get() const; const ParameterType * operator->() const; - operator const ParameterType & () const; + operator const ParameterType &() const; std::string getName() const; @@ -1142,16 +1121,16 @@ class ofReadOnlyParameter: public ofAbstractParameter{ std::string toString() const; - template - void addListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP); + template + void addListener(ListenerClass * listener, ListenerMethod method, int prio = OF_EVENT_ORDER_AFTER_APP); - template - void removeListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP); + template + void removeListener(ListenerClass * listener, ListenerMethod method, int prio = OF_EVENT_ORDER_AFTER_APP); std::shared_ptr newReference() const; - template - std::unique_ptr newListener(Args...args); + template + std::unique_ptr newListener(Args... args); bool isSerializable() const; bool isReadOnly() const; @@ -1163,76 +1142,74 @@ class ofReadOnlyParameter: public ofAbstractParameter{ void disableEvents(); void setSerializable(bool s); - template - void makeReferenceTo(ofReadOnlyParameter mom); + template + void makeReferenceTo(ofReadOnlyParameter mom); void makeReferenceTo(ofParameter mom); - ofReadOnlyParameter & operator=(const ofReadOnlyParameter& v); - ofReadOnlyParameter & operator=(const ofParameter& v); + ofReadOnlyParameter & operator=(const ofReadOnlyParameter & v); + ofReadOnlyParameter & operator=(const ofParameter & v); const ParameterType & operator=(const ParameterType & v); ParameterType operator++(int v); - ofReadOnlyParameter& operator++(); + ofReadOnlyParameter & operator++(); ParameterType operator--(int v); - ofReadOnlyParameter& operator--(); - - template - ofReadOnlyParameter& operator+=(const OtherType & v); - template - ofReadOnlyParameter& operator-=(const OtherType & v); - template - ofReadOnlyParameter& operator*=(const OtherType & v); - template - ofReadOnlyParameter& operator/=(const OtherType & v); - template - ofReadOnlyParameter& operator%=(const OtherType & v); - template - ofReadOnlyParameter& operator&=(const OtherType & v); - template - ofReadOnlyParameter& operator|=(const OtherType & v); - template - ofReadOnlyParameter& operator^=(const OtherType & v); - template - ofReadOnlyParameter& operator<<=(const OtherType & v); - template - ofReadOnlyParameter& operator>>=(const OtherType & v); - - - ofReadOnlyParameter& set(const ParameterType & v); - - 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 & operator--(); + + template + ofReadOnlyParameter & operator+=(const OtherType & v); + template + ofReadOnlyParameter & operator-=(const OtherType & v); + template + ofReadOnlyParameter & operator*=(const OtherType & v); + template + ofReadOnlyParameter & operator/=(const OtherType & v); + template + ofReadOnlyParameter & operator%=(const OtherType & v); + template + ofReadOnlyParameter & operator&=(const OtherType & v); + template + ofReadOnlyParameter & operator|=(const OtherType & v); + template + ofReadOnlyParameter & operator^=(const OtherType & v); + template + ofReadOnlyParameter & operator<<=(const OtherType & v); + template + ofReadOnlyParameter & operator>>=(const OtherType & v); + + ofReadOnlyParameter & set(const ParameterType & v); + + ofReadOnlyParameter & set(const std::string & name, const ParameterType & value); + ofReadOnlyParameter & set(const std::string & name, const ParameterType & value, const ParameterType & min, const ParameterType & max); void setMin(const ParameterType & min); - void setMax(const ParameterType & max); - void setInit(const ParameterType & init); + void setMax(const ParameterType & max); + void setInit(const ParameterType & init); void fromString(const std::string & str); void setParent(ofParameterGroup & _parent); - const ofParameterGroup getFirstParent() const{ + const ofParameterGroup getFirstParent() const { return parameter.getFirstParent(); } - const void* getInternalObject() const{ + const void * getInternalObject() const { return parameter.getInternalObject(); } ofParameter parameter; - template + template friend class ofParameter; friend class ofParameterGroup; friend Friend; - template + template friend class ofReadOnlyParameter; }; - -template -inline ofReadOnlyParameter::ofReadOnlyParameter(){} +template +inline ofReadOnlyParameter::ofReadOnlyParameter() { } //template //inline ofReadOnlyParameter::ofReadOnlyParameter(ofParameter & p) @@ -1242,283 +1219,269 @@ inline ofReadOnlyParameter::ofReadOnlyParameter(){} //inline ofReadOnlyParameter::ofReadOnlyParameter(ofReadOnlyParameter & p) //:parameter(p){} -template -inline ofReadOnlyParameter::ofReadOnlyParameter(const ParameterType & v) -:parameter(v){} - -template -inline ofReadOnlyParameter::ofReadOnlyParameter(const std::string& name, const ParameterType & v) -:parameter(name,v){} +template +inline ofReadOnlyParameter::ofReadOnlyParameter(const ParameterType & v) + : parameter(v) { } -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) + : parameter(name, v) { } +template +inline ofReadOnlyParameter::ofReadOnlyParameter(const std::string & name, const ParameterType & v, const ParameterType & min, const ParameterType & max) + : parameter(name, v, min, max) { } -template -inline const ParameterType & ofReadOnlyParameter::get() const{ +template +inline const ParameterType & ofReadOnlyParameter::get() const { return parameter.get(); } -template -inline const ParameterType * ofReadOnlyParameter::operator->() const{ +template +inline const ParameterType * ofReadOnlyParameter::operator->() const { return ¶meter.get(); } -template -inline ofReadOnlyParameter::operator const ParameterType & () const{ +template +inline ofReadOnlyParameter::operator const ParameterType &() const { return parameter.get(); } - -template -inline std::string ofReadOnlyParameter::getName() const{ +template +inline std::string ofReadOnlyParameter::getName() const { return parameter.getName(); } - -template -inline ParameterType ofReadOnlyParameter::getMin() const{ +template +inline ParameterType ofReadOnlyParameter::getMin() const { return parameter.getMin(); } - -template -inline ParameterType ofReadOnlyParameter::getMax() const{ +template +inline ParameterType ofReadOnlyParameter::getMax() const { return parameter.getMax(); } - -template -inline std::string ofReadOnlyParameter::toString() const{ +template +inline std::string ofReadOnlyParameter::toString() const { return parameter.toString(); } -template -std::string ofReadOnlyParameter::valueType() const{ +template +std::string ofReadOnlyParameter::valueType() const { return typeid(ParameterType).name(); } - -template -template -inline void ofReadOnlyParameter::addListener(ListenerClass * listener, ListenerMethod method, int prio){ - parameter.addListener(listener,method,prio); +template +template +inline void ofReadOnlyParameter::addListener(ListenerClass * listener, ListenerMethod method, int prio) { + parameter.addListener(listener, method, prio); } - -template -template -inline void ofReadOnlyParameter::removeListener(ListenerClass * listener, ListenerMethod method, int prio){ - parameter.removeListener(listener,method,prio); +template +template +inline void ofReadOnlyParameter::removeListener(ListenerClass * listener, ListenerMethod method, int prio) { + parameter.removeListener(listener, method, prio); } - -template -template -inline std::unique_ptr ofReadOnlyParameter::newListener(Args...args) { +template +template +inline std::unique_ptr ofReadOnlyParameter::newListener(Args... args) { return parameter.newListener(args...); } -template -inline void ofReadOnlyParameter::setName(const std::string & name){ +template +inline void ofReadOnlyParameter::setName(const std::string & name) { parameter.setName(name); } -template -inline void ofReadOnlyParameter::enableEvents(){ +template +inline void ofReadOnlyParameter::enableEvents() { parameter.enableEvents(); } -template -inline void ofReadOnlyParameter::disableEvents(){ +template +inline void ofReadOnlyParameter::disableEvents() { parameter.disableEvents(); } -template -inline bool ofReadOnlyParameter::isSerializable() const{ +template +inline bool ofReadOnlyParameter::isSerializable() const { return parameter.isSerializable(); } -template -inline bool ofReadOnlyParameter::isReadOnly() const{ +template +inline bool ofReadOnlyParameter::isReadOnly() const { return true; } -template -inline void ofReadOnlyParameter::setSerializable(bool s){ +template +inline void ofReadOnlyParameter::setSerializable(bool s) { parameter.setSerializable(s); } -template -template -inline void ofReadOnlyParameter::makeReferenceTo(ofReadOnlyParameter mom){ +template +template +inline void ofReadOnlyParameter::makeReferenceTo(ofReadOnlyParameter mom) { parameter.makeReferenceTo(mom.parameter); } -template -void ofReadOnlyParameter::makeReferenceTo(ofParameter mom){ +template +void ofReadOnlyParameter::makeReferenceTo(ofParameter mom) { parameter.makeReferenceTo(mom); } -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator=(const ofReadOnlyParameter & v){ +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator=(const ofReadOnlyParameter & v) { parameter = v.parameter; return *this; } -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator=(const ofParameter& v){ +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator=(const ofParameter & v) { parameter = v; return *this; } -template -inline const ParameterType & ofReadOnlyParameter::operator=(const ParameterType & v){ +template +inline const ParameterType & ofReadOnlyParameter::operator=(const ParameterType & v) { parameter = v; return v; } - -template -inline ParameterType ofReadOnlyParameter::operator++(int){ +template +inline ParameterType ofReadOnlyParameter::operator++(int) { return parameter++; } -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator++(){ +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator++() { return ++parameter; } - -template -inline ParameterType ofReadOnlyParameter::operator--(int){ +template +inline ParameterType ofReadOnlyParameter::operator--(int) { return parameter--; } -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator--(){ +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator--() { return --parameter; } - -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator+=(const OtherType & v){ - parameter+=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator+=(const OtherType & v) { + parameter += v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator-=(const OtherType & v){ - parameter-=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator-=(const OtherType & v) { + parameter -= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator*=(const OtherType & v){ - parameter*=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator*=(const OtherType & v) { + parameter *= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator/=(const OtherType & v){ - parameter/=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator/=(const OtherType & v) { + parameter /= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator%=(const OtherType & v){ - parameter%=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator%=(const OtherType & v) { + parameter %= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator&=(const OtherType & v){ - parameter&=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator&=(const OtherType & v) { + parameter &= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator|=(const OtherType & v){ - parameter|=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator|=(const OtherType & v) { + parameter |= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator^=(const OtherType & v){ - parameter^=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator^=(const OtherType & v) { + parameter ^= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator<<=(const OtherType & v){ - parameter<<=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator<<=(const OtherType & v) { + parameter <<= v; return *this; } -template -template -inline ofReadOnlyParameter & ofReadOnlyParameter::operator>>=(const OtherType & v){ - parameter>>=v; +template +template +inline ofReadOnlyParameter & ofReadOnlyParameter::operator>>=(const OtherType & v) { + parameter >>= v; return *this; } - - -template -inline ofReadOnlyParameter & ofReadOnlyParameter::set(const ParameterType & v){ +template +inline ofReadOnlyParameter & ofReadOnlyParameter::set(const ParameterType & v) { parameter.set(v); return *this; } -template -inline ofReadOnlyParameter & ofReadOnlyParameter::set(const std::string& name, const ParameterType & value){ - parameter.set(name,value); +template +inline ofReadOnlyParameter & ofReadOnlyParameter::set(const std::string & name, const ParameterType & value) { + parameter.set(name, value); return *this; } -template -inline ofReadOnlyParameter & ofReadOnlyParameter::set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max){ - parameter.set(name,value,min,max); +template +inline ofReadOnlyParameter & ofReadOnlyParameter::set(const std::string & name, const ParameterType & value, const ParameterType & min, const ParameterType & max) { + parameter.set(name, value, min, max); return *this; } - -template -inline void ofReadOnlyParameter::setMin(const ParameterType & min){ +template +inline void ofReadOnlyParameter::setMin(const ParameterType & min) { parameter.setMin(min); } -template -inline void ofReadOnlyParameter::setMax(const ParameterType & max){ +template +inline void ofReadOnlyParameter::setMax(const ParameterType & max) { parameter.setMax(max); } -template -inline void ofReadOnlyParameter::setInit(const ParameterType & init){ - parameter.setInit(init); +template +inline void ofReadOnlyParameter::setInit(const ParameterType & init) { + parameter.setInit(init); } -template -inline void ofReadOnlyParameter::fromString(const std::string & str){ +template +inline void ofReadOnlyParameter::fromString(const std::string & str) { parameter.fromString(str); } -template -std::shared_ptr ofReadOnlyParameter::newReference() const{ - return std::make_shared>(*this); +template +std::shared_ptr ofReadOnlyParameter::newReference() const { + return std::make_shared>(*this); } -template -void ofReadOnlyParameter::setParent(ofParameterGroup & _parent){ +template +void ofReadOnlyParameter::setParent(ofParameterGroup & _parent) { parameter.setParent(_parent); } From 790cb80beef14e9a473ee1e396edadb2ec2e251c Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Fri, 24 Nov 2023 21:08:38 -0500 Subject: [PATCH 06/11] notifyEventExample --- .../notifyEventExample/bin/data/.gitkeep | 0 .../events/notifyEventExample/src/main.cpp | 10 ++++ .../events/notifyEventExample/src/ofApp.cpp | 52 +++++++++++++++++++ .../events/notifyEventExample/src/ofApp.h | 22 ++++++++ 4 files changed, 84 insertions(+) create mode 100644 examples/events/notifyEventExample/bin/data/.gitkeep create mode 100644 examples/events/notifyEventExample/src/main.cpp create mode 100644 examples/events/notifyEventExample/src/ofApp.cpp create mode 100644 examples/events/notifyEventExample/src/ofApp.h diff --git a/examples/events/notifyEventExample/bin/data/.gitkeep b/examples/events/notifyEventExample/bin/data/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/events/notifyEventExample/src/main.cpp b/examples/events/notifyEventExample/src/main.cpp new file mode 100644 index 00000000000..9c9d6da6fef --- /dev/null +++ b/examples/events/notifyEventExample/src/main.cpp @@ -0,0 +1,10 @@ +#include "ofApp.h" +#include "ofMain.h" + +int main() { + + ofGLWindowSettings settings; + auto window = ofCreateWindow(settings); + ofRunApp(window, std::make_shared()); + ofRunMainLoop(); +} diff --git a/examples/events/notifyEventExample/src/ofApp.cpp b/examples/events/notifyEventExample/src/ofApp.cpp new file mode 100644 index 00000000000..9db94780e08 --- /dev/null +++ b/examples/events/notifyEventExample/src/ofApp.cpp @@ -0,0 +1,52 @@ +#include "ofApp.h" + +void ofApp::update() { + + // you can check the state of a specific ofParameter + // (wrapper around it's own "hidden Event") + // no listeners/callbacks are required + + if (size.did_notify()) { + ofLogNotice("new size") << size; + } + + if (refresh.did_notify()) { + color = ofColor::fromHsb(ofRandom(360), 128, 128); + ofLogNotice("boosch") << color; + } + + if (animate.did_notify()) { // this is the ofAbstractParameter::did_notify() + if (animate != animating) { // sanity check + animating = animate; + if (animating) { + ofLogNotice("stop animation"); + } else { + ofLogNotice("begin animation"); + size = 0; + } + } + } + + if (auto what = params.parameterChangedE().did_notify()) { // this is the Events::did_notify() + // something happended in params, but you don't know what + } +} + +void ofApp::draw() { + ofBackground(0); + if (animating) { + ofSetColor(color); + ofDrawCircle(ofGetWidth() / 2, ofGetHeight() / 2, size); + size = size + 1; + if (size > 100) size -= 100; + } + ofDrawBitmapString(" to toggle automation", 10, 10); + ofDrawBitmapString(" to randomize size", 10, 20); + ofDrawBitmapString(" to change color", 10, 30); +} + +void ofApp::keyPressed(int key) { + if (key == 'a') animate = !animate; + if (key == 'r') size = ofRandom(50, 100); + if (key == 'c') refresh.trigger(); +} diff --git a/examples/events/notifyEventExample/src/ofApp.h b/examples/events/notifyEventExample/src/ofApp.h new file mode 100644 index 00000000000..1931790ee3c --- /dev/null +++ b/examples/events/notifyEventExample/src/ofApp.h @@ -0,0 +1,22 @@ +#pragma once + +#include "ofMain.h" + +// note: this example, inspired by simpleEvents, is kept voluntarily +// as small as possible to give a sense of the bare minimum requirements + +class ofApp : public ofBaseApp { + + ofParameter animate { "animate", false }; + ofParameter refresh { "refresh" }; + ofParameter size { "size", 1.0f, 0.0f, 100.0f }; + ofParameterGroup params { "myCallbacksAndSettings", animate, refresh, size }; + + bool animating { false }; + ofColor color { ofColor::white }; + +public: + void update() override; + void draw() override; + void keyPressed(int key) override; +}; From 5ac43cac438a377ed99089718842aa066565d49c Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Sat, 25 Nov 2023 01:39:41 -0500 Subject: [PATCH 07/11] ofEvent::did_notify(): typo/cohesion --- libs/openFrameworks/events/ofEvent.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/events/ofEvent.h b/libs/openFrameworks/events/ofEvent.h index ac074f4ec02..2667e23469d 100644 --- a/libs/openFrameworks/events/ofEvent.h +++ b/libs/openFrameworks/events/ofEvent.h @@ -568,18 +568,18 @@ class ofEvent: public of::priv::BaseEvent,Mutex>{ /// \brief checks the state of the event /// \returns true if the Event's state was notified since the last check bool did_notify() { - if (notified.load(std::memory_order_relaxed)) { - notified.store(false, std::memory_order_seq_cst); + if (notified_.load(std::memory_order_relaxed)) { + notified_.store(false, std::memory_order_seq_cst); return true; } else { return false; } } - std::atomic notified; + std::atomic notified_; inline bool notify(const void* sender, T & param) { if (ofEvent::self->enabled) { - notified.store(true, std::memory_order_relaxed); + notified_.store(true, std::memory_order_relaxed); if (!ofEvent::self->functions.empty()) { std::unique_lock lck(ofEvent::self->mtx); auto functions_copy = ofEvent::self->functions; From 569719d515ba85d2263cc172779ac66147c3155c Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Mon, 27 Nov 2023 19:41:48 -0500 Subject: [PATCH 08/11] ofEvent: rename did_notify() -> didNotify() --- examples/events/notifyEventExample/src/ofApp.cpp | 6 +++--- libs/openFrameworks/events/ofEvent.h | 4 ++-- libs/openFrameworks/types/ofParameter.h | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/events/notifyEventExample/src/ofApp.cpp b/examples/events/notifyEventExample/src/ofApp.cpp index 9db94780e08..c5d31f78318 100644 --- a/examples/events/notifyEventExample/src/ofApp.cpp +++ b/examples/events/notifyEventExample/src/ofApp.cpp @@ -6,16 +6,16 @@ void ofApp::update() { // (wrapper around it's own "hidden Event") // no listeners/callbacks are required - if (size.did_notify()) { + if (size.didNotify()) { ofLogNotice("new size") << size; } - if (refresh.did_notify()) { + if (refresh.didNotify()) { color = ofColor::fromHsb(ofRandom(360), 128, 128); ofLogNotice("boosch") << color; } - if (animate.did_notify()) { // this is the ofAbstractParameter::did_notify() + if (animate.didNotify()) { // this is the ofAbstractParameter::did_notify() if (animate != animating) { // sanity check animating = animate; if (animating) { diff --git a/libs/openFrameworks/events/ofEvent.h b/libs/openFrameworks/events/ofEvent.h index 2667e23469d..5fc53cda809 100644 --- a/libs/openFrameworks/events/ofEvent.h +++ b/libs/openFrameworks/events/ofEvent.h @@ -567,7 +567,7 @@ class ofEvent: public of::priv::BaseEvent,Mutex>{ /// \brief checks the state of the event /// \returns true if the Event's state was notified since the last check - bool did_notify() { + bool didNotify() { if (notified_.load(std::memory_order_relaxed)) { notified_.store(false, std::memory_order_seq_cst); return true; @@ -730,7 +730,7 @@ class ofEvent: public of::priv::BaseEventchangedE.did_notify(); } @@ -1036,8 +1036,8 @@ class ofParameter : public ofAbstractParameter { /// \brief queries the parameter's event about its notification state /// \returns true if the event was notified since last check - auto did_notify() { - return obj->changedE.did_notify(); + auto didNotify() { + return obj->changedE.didNotify(); } void trigger(); From cdd3b96d09d7beb79a2c46e7d53cfc97e24f4cf7 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Mon, 27 Nov 2023 19:42:24 -0500 Subject: [PATCH 09/11] ofEvent: explicit init of notified_ bool; --- libs/openFrameworks/events/ofEvent.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/openFrameworks/events/ofEvent.h b/libs/openFrameworks/events/ofEvent.h index 5fc53cda809..4be3e805d9d 100644 --- a/libs/openFrameworks/events/ofEvent.h +++ b/libs/openFrameworks/events/ofEvent.h @@ -576,6 +576,7 @@ class ofEvent: public of::priv::BaseEvent,Mutex>{ } } std::atomic notified_; + std::atomic notified_ { false }; inline bool notify(const void* sender, T & param) { if (ofEvent::self->enabled) { From c3463f8f2b8158e9ac5223c4a15f91f2e06ab2dd Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Mon, 27 Nov 2023 20:30:28 -0500 Subject: [PATCH 10/11] ofEvent: more thorough didNotify rename --- libs/openFrameworks/events/ofEvent.h | 1 - libs/openFrameworks/types/ofParameter.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/openFrameworks/events/ofEvent.h b/libs/openFrameworks/events/ofEvent.h index 4be3e805d9d..12a1f9976bc 100644 --- a/libs/openFrameworks/events/ofEvent.h +++ b/libs/openFrameworks/events/ofEvent.h @@ -575,7 +575,6 @@ class ofEvent: public of::priv::BaseEvent,Mutex>{ return false; } } - std::atomic notified_; std::atomic notified_ { false }; inline bool notify(const void* sender, T & param) { diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 6ed14394ba8..b7906107297 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -509,7 +509,7 @@ class ofParameter : public ofAbstractParameter { /// \brief queries the parameter's event about its notification state /// \returns true if the event was notified since last check auto didNotify() { - return obj->changedE.did_notify(); + return obj->changedE.didNotify(); } std::string toString() const; From 04d26b8cdf2f4b56d63dd5441e9ec74ef193c64d Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 12 Dec 2023 16:35:07 -0500 Subject: [PATCH 11/11] ofParameter: include fix --- libs/openFrameworks/types/ofParameter.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 87cb0e7d637..d5a3c1fcef5 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -1,16 +1,15 @@ #pragma once -#include "ofColor.h" -#include "ofConstants.h" -#include "ofEvents.h" +#include +#include "ofEvents.h" // FIXME: crossed references. ofPoint adds ofVec3f which adds ofVec2f and ofVec4f #include "ofPoint.h" #include "ofRectangle.h" - - -#include +#include "ofLog.h" +// #include "ofConstants.h" +#include "ofColor.h" template class ofParameter;