Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions libs/openFrameworks/types/ofParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ template <typename ParameterType, typename Friend>
class ofReadOnlyParameter;

class ofParameterGroup;

//----------------------------------------------------------------------
/// Base class for ofParameter, ofReadOnlyParameter and ofParameterGroup
class ofAbstractParameter {
Expand All @@ -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<std::string> getGroupHierarchyNames() const;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<ofAbstractParameter> newReference() const;
Expand Down Expand Up @@ -1071,7 +1078,14 @@ class ofParameter<void> : public ofAbstractParameter {
ofParameter();
ofParameter(const std::string & name);

bool isInit() const { return false; }
bool isInit() const {
ofLogVerbose("ofParameter<void>::isInit()") << "isInit() called on ofParameter<void>, where it always returns true";
return true;
}

void reInit() {
ofLogVerbose("ofParameter<void>::reInit()") << "isInit() called on ofParameter<void>, where it is a no-op";
}

ofParameter<void> & set(const std::string & name);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -1538,11 +1553,18 @@ template <typename ParameterType, typename Friend>
inline bool ofReadOnlyParameter<ParameterType, Friend>::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<std::string>'
// 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 <typename ParameterType, typename Friend>
inline void ofReadOnlyParameter<ParameterType, Friend>::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 <typename ParameterType, typename Friend>
inline void ofReadOnlyParameter<ParameterType, Friend>::fromString(const std::string & str) {
parameter.fromString(str);
Expand Down