From 97999ac87644ede5087d42f9fac248650332a7c6 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 13 Feb 2024 12:28:54 -0500 Subject: [PATCH 1/2] ofAbstractParameter::reInit (virtual) and ofParameterGroup::reInit --- libs/openFrameworks/types/ofParameter.h | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index d71a6edee39..1461f985d1d 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -19,7 +19,7 @@ template class ofReadOnlyParameter; class ofParameterGroup; - + //---------------------------------------------------------------------- /// Base class for ofParameter, ofReadOnlyParameter and ofParameterGroup class ofAbstractParameter { @@ -35,6 +35,7 @@ class ofAbstractParameter { virtual std::string valueType() const = 0; virtual bool isInit() const = 0; + virtual void reInit() = 0; virtual void setParent(ofParameterGroup & _parent) = 0; std::vector getGroupHierarchyNames() const; @@ -188,6 +189,12 @@ class ofParameterGroup : public ofAbstractParameter { } return true; } + + void reInit() { + for (int i = 0; i < size(); i++) { + get(i).reInit(); + } + } const ofAbstractParameter & get(const std::string & name) const; const ofAbstractParameter & get(std::size_t pos) const; @@ -517,7 +524,6 @@ 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 @@ -591,6 +597,7 @@ class ofParameter : public ofAbstractParameter { void setMax(const ParameterType & max); void setInit(const ParameterType & init); bool isInit() const; + void reInit(); void setSerializable(bool serializable); std::shared_ptr newReference() const; @@ -1030,7 +1037,14 @@ class ofParameter : public ofAbstractParameter { ofParameter(); ofParameter(const std::string & name); - bool isInit() const { return false; } + bool isInit() const { + ofLogVerbose("ofParameter::isInit()") << "isInit() called on ofParameter, where it always returns false"; + return false; + } + + void reInit() { + ofLogVerbose("ofParameter::reInit()") << "isInit() called on ofParameter, where it is a no-op"; + } ofParameter & set(const std::string & name); @@ -1207,6 +1221,7 @@ class ofReadOnlyParameter : public ofAbstractParameter { void setMax(const ParameterType & max); void setInit(const ParameterType & init); bool isInit() const; + void reInit(); void fromString(const std::string & str); @@ -1497,11 +1512,18 @@ template inline bool ofReadOnlyParameter::isInit() const { // not sure what the expected behaviour for isInit() would be for ReadOnlyParameter // as-is, it fails with : No member named 'value' in 'ofParameter' - // returning true while informaing with a log msg seems sane + // returning true while informing with a log msg seems sane ofLogVerbose("ofReadOnlyParameter::isInit()") << "isInit() called on ofReadOnlyParameter, where it always returns true"; return true; } +template +inline void ofReadOnlyParameter::reInit() { + // not sure what the expected behaviour for reInit() would be for ReadOnlyParameter + // informing with a log msg seems sane + ofLogVerbose("ofReadOnlyParameter::reInit()") << "reInit() called on ofReadOnlyParameter, where it is a no-op"; +} + template inline void ofReadOnlyParameter::fromString(const std::string & str) { parameter.fromString(str); From 4449f61c57d1b92e5103985ccb8425ed530a0c09 Mon Sep 17 00:00:00 2001 From: alexandre burton Date: Tue, 13 Feb 2024 12:34:04 -0500 Subject: [PATCH 2/2] ofParameter::isInit() inversion of result --- libs/openFrameworks/types/ofParameter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 1461f985d1d..c3fbb0ef7f7 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -1038,8 +1038,8 @@ class ofParameter : public ofAbstractParameter { ofParameter(const std::string & name); bool isInit() const { - ofLogVerbose("ofParameter::isInit()") << "isInit() called on ofParameter, where it always returns false"; - return false; + ofLogVerbose("ofParameter::isInit()") << "isInit() called on ofParameter, where it always returns true"; + return true; } void reInit() {