diff --git a/libs/openFrameworks/types/ofParameter.h b/libs/openFrameworks/types/ofParameter.h index 0869cc7b1d1..779aec5af5f 100644 --- a/libs/openFrameworks/types/ofParameter.h +++ b/libs/openFrameworks/types/ofParameter.h @@ -23,7 +23,7 @@ template class ofReadOnlyParameter; class ofParameterGroup; - + //---------------------------------------------------------------------- /// Base class for ofParameter, ofReadOnlyParameter and ofParameterGroup class ofAbstractParameter { @@ -39,6 +39,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; @@ -192,6 +193,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; @@ -557,7 +564,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 @@ -631,6 +637,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; @@ -1071,7 +1078,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 true"; + return true; + } + + void reInit() { + ofLogVerbose("ofParameter::reInit()") << "isInit() called on ofParameter, where it is a no-op"; + } ofParameter & set(const std::string & name); @@ -1248,6 +1262,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); @@ -1538,11 +1553,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);