66// FIXME: crossed references. ofPoint adds ofVec3f which adds ofVec2f and ofVec4f
77#include " ofPoint.h"
88
9- #include " ofRectangle.h"
10- #include " ofLog.h"
119#include " ofColor.h"
10+ #include " ofLog.h"
11+ #include " ofRectangle.h"
1212
1313#include " ofMathConstants.h"
1414
@@ -34,6 +34,8 @@ class ofAbstractParameter {
3434 virtual std::string getEscapedName () const ;
3535 virtual std::string valueType () const = 0;
3636
37+ virtual bool isInit () const = 0;
38+
3739 virtual void setParent (ofParameterGroup & _parent) = 0;
3840 std::vector<std::string> getGroupHierarchyNames () const ;
3941
@@ -180,6 +182,13 @@ class ofParameterGroup : public ofAbstractParameter {
180182 ofParameter<ofRectangle> & getRectangle (std::size_t pos);
181183 ofParameterGroup & getGroup (std::size_t pos);
182184
185+ bool isInit () const {
186+ for (int i = 0 ; i < size (); i++) {
187+ if (!get (i).isInit ()) return false ;
188+ }
189+ return true ;
190+ }
191+
183192 const ofAbstractParameter & get (const std::string & name) const ;
184193 const ofAbstractParameter & get (std::size_t pos) const ;
185194
@@ -507,6 +516,7 @@ class ofParameter : public ofAbstractParameter {
507516 ParameterType getMax () const ;
508517
509518 ParameterType getInit () const ;
519+
510520 void reInit ();
511521
512522 // / \brief queries the parameter's event about its notification state
@@ -580,6 +590,7 @@ class ofParameter : public ofAbstractParameter {
580590 void setMin (const ParameterType & min);
581591 void setMax (const ParameterType & max);
582592 void setInit (const ParameterType & init);
593+ bool isInit () const ;
583594
584595 void setSerializable (bool serializable);
585596 std::shared_ptr<ofAbstractParameter> newReference () const ;
@@ -824,6 +835,11 @@ ParameterType ofParameter<ParameterType>::getInit() const {
824835 return obj->init ;
825836}
826837
838+ template <typename ParameterType>
839+ bool ofParameter<ParameterType>::isInit() const {
840+ return obj->value == obj->init ;
841+ }
842+
827843template <typename ParameterType>
828844void ofParameter<ParameterType>::reInit() {
829845 setMethod (obj->init );
@@ -1014,6 +1030,8 @@ class ofParameter<void> : public ofAbstractParameter {
10141030 ofParameter ();
10151031 ofParameter (const std::string & name);
10161032
1033+ bool isInit () const { return false ; }
1034+
10171035 ofParameter<void > & set (const std::string & name);
10181036
10191037 void setName (const std::string & name);
@@ -1188,6 +1206,7 @@ class ofReadOnlyParameter : public ofAbstractParameter {
11881206 void setMin (const ParameterType & min);
11891207 void setMax (const ParameterType & max);
11901208 void setInit (const ParameterType & init);
1209+ bool isInit () const ;
11911210
11921211 void fromString (const std::string & str);
11931212
@@ -1474,6 +1493,15 @@ inline void ofReadOnlyParameter<ParameterType, Friend>::setInit(const ParameterT
14741493 parameter.setInit (init);
14751494}
14761495
1496+ template <typename ParameterType, typename Friend>
1497+ inline bool ofReadOnlyParameter<ParameterType, Friend>::isInit() const {
1498+ // not sure what the expected behaviour for isInit() would be for ReadOnlyParameter
1499+ // as-is, it fails with : No member named 'value' in 'ofParameter<std::string>'
1500+ // returning true while informaing with a log msg seems sane
1501+ ofLogVerbose (" ofReadOnlyParameter::isInit()" ) << " isInit() called on ofReadOnlyParameter, where it always returns true" ;
1502+ return true ;
1503+ }
1504+
14771505template <typename ParameterType, typename Friend>
14781506inline void ofReadOnlyParameter<ParameterType, Friend>::fromString(const std::string & str) {
14791507 parameter.fromString (str);
0 commit comments