reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofParameter.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofEvents.h"
4#include "ofPoint.h"
5#include "ofRectangle.h"
6#include "ofLog.h"
7#include "ofConstants.h"
8#include "ofColor.h"
9
10#include <map>
11
12template<typename ParameterType>
13class ofParameter;
14
15template<typename ParameterType, typename Friend>
17
19
20
21
22//----------------------------------------------------------------------
25public:
27 virtual std::string getName() const = 0;
28 virtual void setName(const std::string & name) = 0;
29 virtual std::string toString() const = 0;
30 virtual void fromString(const std::string & str) = 0;
31
32 virtual std::string type() const;
33 virtual std::string getEscapedName() const;
34 virtual std::string valueType() const = 0;
35
36 virtual void setParent(ofParameterGroup & _parent) = 0;
37 std::vector<std::string> getGroupHierarchyNames() const;
38
39 template<typename ParameterType>
41 return static_cast<ofParameter<ParameterType> &>(*this);
42 }
43
44 template<typename ParameterType>
46 return static_cast<const ofParameter<ParameterType> &>(*this);
47 }
48
49 template<typename ParameterType, typename Friend>
53
54 template<typename ParameterType, typename Friend>
58
60 const ofParameterGroup & castGroup() const;
61
62 friend std::ostream& operator<<(std::ostream& os, const ofAbstractParameter& p);
63 friend std::istream& operator>>(std::istream& is, ofAbstractParameter& p);
64
65 virtual bool isSerializable() const = 0;
66 virtual bool isReadOnly() const = 0;
67 virtual std::shared_ptr<ofAbstractParameter> newReference() const = 0;
68
69 virtual bool isReferenceTo(const ofAbstractParameter& other) const;
70
71protected:
72 virtual const ofParameterGroup getFirstParent() const = 0;
73 virtual void setSerializable(bool serializable)=0;
74 virtual std::string escape(const std::string& str) const;
75 virtual const void* getInternalObject() const = 0;
76};
77
78
79
80
81//----------------------------------------------------------------------
85public:
87
88 template<typename ...Args>
89 ofParameterGroup(const std::string & name)
90 :obj(std::make_shared<Value>()){
91 setName(name);
92 }
93
94 template<typename ...Args>
95 ofParameterGroup(const std::string & name, Args&... p)
96 :obj(std::make_shared<Value>()){
97 add(p...);
98 setName(name);
99 }
100
101 template<typename ...Args>
102 void add(ofAbstractParameter & p, Args&... parameters){
103 add(p);
104 add(parameters...);
105 }
106
107 void add(ofAbstractParameter & param);
108 std::string valueType() const;
109
110 void remove(ofAbstractParameter & param);
111 void remove(std::size_t index);
112 void remove(const std::string& name);
113
114 void clear();
115
116 const ofParameter<void> & getVoid(const std::string& name) const;
117 const ofParameter<bool> & getBool(const std::string& name) const;
118 const ofParameter<int> & getInt(const std::string& name) const;
119 const ofParameter<float> & getFloat(const std::string& name) const;
120 const ofParameter<char> & getChar(const std::string& name) const;
121 const ofParameter<std::string> & getString(const std::string& name) const;
122 const ofParameter<ofPoint> & getPoint(const std::string& name) const;
123 const ofParameter<ofDefaultVec2> & getVec2f(const std::string& name) const;
124 const ofParameter<ofDefaultVec3> & getVec3f(const std::string& name) const;
125 const ofParameter<ofDefaultVec4> & getVec4f(const std::string& name) const;
126 const ofParameter<ofColor> & getColor(const std::string& name) const;
127 const ofParameter<ofShortColor> & getShortColor(const std::string& name) const;
128 const ofParameter<ofFloatColor> & getFloatColor(const std::string& name) const;
129 const ofParameter<ofRectangle> & getRectangle(const std::string& name) const;
130 const ofParameterGroup & getGroup(const std::string& name) const;
131
132
133 const ofParameter<void> & getVoid(std::size_t pos) const;
134 const ofParameter<bool> & getBool(std::size_t pos) const;
135 const ofParameter<int> & getInt(std::size_t pos) const;
136 const ofParameter<float> & getFloat(std::size_t pos) const;
137 const ofParameter<char> & getChar(std::size_t pos) const;
138 const ofParameter<std::string> & getString(std::size_t pos) const;
139 const ofParameter<ofPoint> & getPoint(std::size_t pos) const;
140 const ofParameter<ofDefaultVec2> & getVec2f(std::size_t pos) const;
141 const ofParameter<ofDefaultVec3> & getVec3f(std::size_t pos) const;
142 const ofParameter<ofDefaultVec4> & getVec4f(std::size_t pos) const;
143 const ofParameter<ofColor> & getColor(std::size_t pose) const;
144 const ofParameter<ofShortColor> & getShortColor(std::size_t pos) const;
145 const ofParameter<ofFloatColor> & getFloatColor(std::size_t pos) const;
146 const ofParameter<ofRectangle> & getRectangle(std::size_t pos) const;
147 const ofParameterGroup & getGroup(std::size_t pos) const;
148
149 ofParameter<void> & getVoid(const std::string& name);
150 ofParameter<bool> & getBool(const std::string& name);
151 ofParameter<int> & getInt(const std::string& name);
152 ofParameter<float> & getFloat(const std::string& name);
153 ofParameter<char> & getChar(const std::string& name);
154 ofParameter<std::string> & getString(const std::string& name);
155 ofParameter<ofPoint> & getPoint(const std::string& name);
156 ofParameter<ofDefaultVec2> & getVec2f(const std::string& name);
157 ofParameter<ofDefaultVec3> & getVec3f(const std::string& name);
158 ofParameter<ofDefaultVec4> & getVec4f(const std::string& name);
159 ofParameter<ofColor> & getColor(const std::string& name);
160 ofParameter<ofShortColor> & getShortColor(const std::string& name);
161 ofParameter<ofFloatColor> & getFloatColor(const std::string& name);
162 ofParameter<ofRectangle> & getRectangle(const std::string& name);
163 ofParameterGroup & getGroup(const std::string& name);
164
165
166 ofParameter<void> & getVoid(std::size_t pos);
167 ofParameter<bool> & getBool(std::size_t pos);
168 ofParameter<int> & getInt(std::size_t pos);
169 ofParameter<float> & getFloat(std::size_t pos);
170 ofParameter<char> & getChar(std::size_t pos);
171 ofParameter<std::string> & getString(std::size_t pos);
172 ofParameter<ofPoint> & getPoint(std::size_t pos);
173 ofParameter<ofDefaultVec2> & getVec2f(std::size_t pos);
174 ofParameter<ofDefaultVec3> & getVec3f(std::size_t pos);
175 ofParameter<ofDefaultVec4> & getVec4f(std::size_t pos);
176 ofParameter<ofColor> & getColor(std::size_t pose);
177 ofParameter<ofShortColor> & getShortColor(std::size_t pos);
178 ofParameter<ofFloatColor> & getFloatColor(std::size_t pos);
179 ofParameter<ofRectangle> & getRectangle(std::size_t pos);
180 ofParameterGroup & getGroup(std::size_t pos);
181
182 const ofAbstractParameter & get(const std::string& name) const;
183 const ofAbstractParameter & get(std::size_t pos) const;
184
185 const ofAbstractParameter & operator[](const std::string& name) const;
186 const ofAbstractParameter & operator[](std::size_t pos) const;
187
188 ofAbstractParameter & get(const std::string& name);
189 ofAbstractParameter & get(std::size_t pos);
190
191 ofAbstractParameter & operator[](const std::string& name);
192 ofAbstractParameter & operator[](std::size_t pos);
193
194 template<typename ParameterType>
195 const ofParameter<ParameterType> & get(const std::string& name) const;
196
197 template<typename ParameterType>
198 const ofParameter<ParameterType> & get(std::size_t pos) const;
199
200 template<typename ParameterType>
201 ofParameter<ParameterType> & get(const std::string& name);
202
203 template<typename ParameterType>
204 ofParameter<ParameterType> & get(std::size_t pos);
205
206 template<typename ParameterType, typename Friend>
207 const ofReadOnlyParameter<ParameterType, Friend> & getReadOnly(const std::string& name) const;
208
209 template<typename ParameterType, typename Friend>
210 const ofReadOnlyParameter<ParameterType, Friend> & getReadOnly(std::size_t pos) const;
211
212 template<typename ParameterType, typename Friend>
214
215 template<typename ParameterType, typename Friend>
217
218 std::size_t size() const;
219 std::string getName(std::size_t position) const;
220 std::string getType(std::size_t position) const;
221 bool getIsReadOnly(int position) const;
222 int getPosition(const std::string& name) const;
223
224 friend std::ostream& operator<<(std::ostream& os, const ofParameterGroup& group);
225
226 std::string getName() const;
227 void setName(const std::string& name);
228 std::string getEscapedName() const;
229 std::string toString() const;
230 void fromString(const std::string& name);
231
232 bool contains(const std::string& name) const;
233
236 const ofAbstractParameter & back() const;
237 const ofAbstractParameter & front() const;
238
239 void setSerializable(bool serializable);
240 bool isSerializable() const;
241 bool isReadOnly() const;
242 std::shared_ptr<ofAbstractParameter> newReference() const;
243
244 void setParent(ofParameterGroup & parent);
245
246 operator bool() const;
247
249
250 std::vector<std::shared_ptr<ofAbstractParameter> >::iterator begin();
251 std::vector<std::shared_ptr<ofAbstractParameter> >::iterator end();
252 std::vector<std::shared_ptr<ofAbstractParameter> >::const_iterator begin() const;
253 std::vector<std::shared_ptr<ofAbstractParameter> >::const_iterator end() const;
254 std::vector<std::shared_ptr<ofAbstractParameter> >::reverse_iterator rbegin();
255 std::vector<std::shared_ptr<ofAbstractParameter> >::reverse_iterator rend();
256 std::vector<std::shared_ptr<ofAbstractParameter> >::const_reverse_iterator rbegin() const;
257 std::vector<std::shared_ptr<ofAbstractParameter> >::const_reverse_iterator rend() const;
258
259protected:
260 const void* getInternalObject() const;
261
262private:
263 class Value{
264 public:
265 Value()
266 :serializable(true){}
267
268 void notifyParameterChanged(ofAbstractParameter & param);
269
270 std::map<std::string,std::size_t> parametersIndex;
271 std::vector<std::shared_ptr<ofAbstractParameter> > parameters;
272 std::string name;
273 bool serializable;
274 std::vector<std::weak_ptr<Value>> parents;
275 ofEvent<ofAbstractParameter> parameterChangedE;
276 };
277 std::shared_ptr<Value> obj;
278 ofParameterGroup(std::shared_ptr<Value> obj)
279 :obj(obj){}
280
281 template<typename T>
282 friend class ofParameter;
283
284 template<typename T, typename F>
286
287 const ofParameterGroup getFirstParent() const;
288};
289
290template<typename ParameterType>
291const ofParameter<ParameterType> & ofParameterGroup::get(const std::string& name) const{
292 return static_cast<const ofParameter<ParameterType>& >(get(name));
293}
294
295template<typename ParameterType>
297 return static_cast<const ofParameter<ParameterType>& >(get(pos));
298}
299
300template<typename ParameterType>
302 return static_cast<ofParameter<ParameterType>& >(get(name));
303}
304
305template<typename ParameterType>
307 return static_cast<ofParameter<ParameterType>& >(get(pos));
308}
309
310
311template<typename ParameterType, typename Friend>
313 return static_cast<const ofReadOnlyParameter<ParameterType,Friend>& >(get(name));
314}
315
316template<typename ParameterType, typename Friend>
318 return static_cast<const ofReadOnlyParameter<ParameterType,Friend>& >(get(pos));
319}
320
321template<typename ParameterType, typename Friend>
325
326template<typename ParameterType, typename Friend>
330
331
333namespace of{
334namespace priv{
335 //----------------------------------------------------------------------
336 // Mechanism to provide min and max default values for types where it makes sense
337 template<typename T, bool B>
338 struct TypeInfo_ {
339 };
340
341 // Types with numeric_limits resolve to this template specialization:
342 template<typename T>
343 struct TypeInfo_<T, true> {
344 static T min() { return std::numeric_limits<T>::lowest(); }
345 static T max() { return std::numeric_limits<T>::max(); }
346 };
347
348 template<>
349 struct TypeInfo_<float, true> {
350 static float min() { return 0; }
351 static float max() { return 1; }
352 };
353
354 template<>
355 struct TypeInfo_<double, true> {
356 static float min() { return 0; }
357 static float max() { return 1; }
358 };
359
360 // Types without numeric_limits resolve to this template specialization:
361 template<typename T>
362 struct TypeInfo_<T, false> {
363 static T min() { return T(); }
364 static T max() { return T(); }
365 };
366
367 template<typename T>
368 struct TypeInfo : public of::priv::TypeInfo_<T, std::numeric_limits<T>::is_specialized> {
369 };
370
371 // Here we provide some of our own specializations:
372 template<>
373 struct TypeInfo <ofVec2f> {
374 static ofVec2f min() { return ofVec2f(0); }
375 static ofVec2f max() { return ofVec2f(1); }
376 };
377
378 template<>
379 struct TypeInfo <glm::vec2> {
380 static glm::vec2 min() { return glm::vec2(0); }
381 static glm::vec2 max() { return glm::vec2(1); }
382 };
383
384 template<>
385 struct TypeInfo <ofVec3f> {
386 static ofVec3f min() { return ofVec3f(0); }
387 static ofVec3f max() { return ofVec3f(1); }
388 };
389
390 template<>
391 struct TypeInfo <glm::vec3> {
392 static glm::vec3 min() { return glm::vec3(0); }
393 static glm::vec3 max() { return glm::vec3(1); }
394 };
395
396 template<>
397 struct TypeInfo <ofVec4f> {
398 static ofVec4f min() { return ofVec4f(0); }
399 static ofVec4f max() { return ofVec4f(1); }
400 };
401
402 template<>
403 struct TypeInfo <glm::vec4> {
404 static glm::vec4 min() { return glm::vec4(0); }
405 static glm::vec4 max() { return glm::vec4(1); }
406 };
407
408 template<typename T>
409 struct TypeInfo <ofColor_<T>> {
410 static ofColor_<T> min() { return ofColor_<T>(0,0); }
412 };
413 template<>
414 struct TypeInfo <ofRectangle> {
415 //Not really sure what would make sense here!!!
416 static ofRectangle min() { return ofRectangle(0,0,0,0); }
417 static ofRectangle max() { return ofRectangle(0,0,1,1); }
418 };
419
420
421 // detection of stream operators
422 typedef char yes;
423 typedef char (&no)[2];
424
425 struct anyx { template <class T> anyx(const T &); };
426
427 no operator << (const anyx &, const anyx &);
428 no operator >> (const anyx &, const anyx &);
429
430
431 template <class T> yes check_op(T const&);
432 no check_op(no);
433
434 template <typename T>
435 struct has_loading_support {
436 static std::istream & stream;
437 static T & x;
438 static constexpr bool value = sizeof(check_op(stream >> x)) == sizeof(yes);
439 };
440
441 template <typename T>
442 struct has_saving_support {
443 static std::ostream & stream;
444 static T & x;
445 static constexpr bool value = sizeof(check_op(stream << x)) == sizeof(yes);
446 };
447
448 template <typename T>
449 struct has_stream_operators {
450 static constexpr bool can_load = has_loading_support<T>::value;
451 static constexpr bool can_save = has_saving_support<T>::value;
452 static constexpr bool value = can_load && can_save;
453 };
454
455 template<typename ParameterType>
456 typename std::enable_if<of::priv::has_saving_support<ParameterType>::value, std::string>::type toStringImpl(const ParameterType & value){
457 return ofToString(value);
458 }
459
460 template<typename ParameterType>
461 typename std::enable_if<!of::priv::has_saving_support<ParameterType>::value, std::string>::type toStringImpl(const ParameterType &){
462 throw std::exception();
463 }
464
465 template<typename ParameterType>
466 typename std::enable_if<of::priv::has_loading_support<ParameterType>::value, ParameterType>::type fromStringImpl(const std::string & str){
467 return ofFromString<ParameterType>(str);
468 }
469
470 template<typename ParameterType>
471 typename std::enable_if<!of::priv::has_loading_support<ParameterType>::value, ParameterType>::type fromStringImpl(const std::string &){
472 throw std::exception();
473
474 }
475}
476}
491template<typename ParameterType>
493public:
496 ofParameter(const ParameterType & v);
497 ofParameter(const std::string& name, const ParameterType & v);
498 ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max);
499
500 const ParameterType & get() const;
501 const ParameterType * operator->() const;
502 operator const ParameterType & () const;
503
504 void setName(const std::string & name);
505 std::string getName() const;
506
507 ParameterType getMin() const;
508
509 ParameterType getMax() const;
510
511 ParameterType getInit() const;
512 void reInit();
513
514 std::string toString() const;
515 void fromString(const std::string & name);
516
517 template<class ListenerClass, typename ListenerMethod>
518 void addListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){
519 ofAddListener(obj->changedE,listener,method,prio);
520 }
521
522 template<class ListenerClass, typename ListenerMethod>
523 void removeListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){
524 ofRemoveListener(obj->changedE,listener,method,prio);
525 }
526
527 template<typename... Args>
528 std::unique_ptr<of::priv::AbstractEventToken> newListener(Args...args) {
529 return obj->changedE.newListener(args...);
530 }
531
534 bool isSerializable() const;
535 bool isReadOnly() const;
536 std::string valueType() const;
537
539
541 const ParameterType & operator=(const ParameterType & v);
542
543 ParameterType operator++(int v);
545
546 ParameterType operator--(int v);
548
549 template<typename OtherType>
551 template<typename OtherType>
553 template<typename OtherType>
555 template<typename OtherType>
557 template<typename OtherType>
559 template<typename OtherType>
561 template<typename OtherType>
563 template<typename OtherType>
565 template<typename OtherType>
566 ofParameter<ParameterType> & operator<<=(const OtherType & v);
567 template<typename OtherType>
569
570
571 ofParameter<ParameterType> & set(const ParameterType & v);
572 ofParameter<ParameterType> & set(const std::string& name, const ParameterType & v);
573 ofParameter<ParameterType> & set(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max);
574
576
577 void setMin(const ParameterType & min);
578 void setMax(const ParameterType & max);
579 void setInit(const ParameterType & init);
580
581 void setSerializable(bool serializable);
582 std::shared_ptr<ofAbstractParameter> newReference() const;
583
585
587 obj->parents.erase(std::remove_if(obj->parents.begin(),obj->parents.end(),
588 [](std::weak_ptr<ofParameterGroup::Value> p){return p.lock()==nullptr;}),
589 obj->parents.end());
590 if(!obj->parents.empty()){
591 return obj->parents.front().lock();
592 }else{
593 return std::shared_ptr<ofParameterGroup::Value>(nullptr);
594 }
595 }
596
597 size_t getNumListeners() const;
598 const void* getInternalObject() const;
599
600protected:
601
602private:
603 class Value{
604 public:
605 Value()
606 :init(of::priv::TypeInfo<ParameterType>::min())
607 ,min(of::priv::TypeInfo<ParameterType>::min())
608 ,max(of::priv::TypeInfo<ParameterType>::max())
609 ,bInNotify(false)
610 ,serializable(true){}
611
612 Value(ParameterType v)
613 :init(v)
614 ,value(v)
615 ,min(of::priv::TypeInfo<ParameterType>::min())
616 ,max(of::priv::TypeInfo<ParameterType>::max())
617 ,bInNotify(false)
618 ,serializable(true){}
619
620 Value(std::string name, ParameterType v)
621 :name(name)
622 ,init(v)
623 ,value(v)
624 ,min(of::priv::TypeInfo<ParameterType>::min())
625 ,max(of::priv::TypeInfo<ParameterType>::max())
626 ,bInNotify(false)
627 ,serializable(true){}
628
629 Value(std::string name, ParameterType v, ParameterType min, ParameterType max)
630 :name(name)
631 ,init(v)
632 ,value(v)
633 ,min(min)
634 ,max(max)
635 ,bInNotify(false)
636 ,serializable(true){}
637
638 std::string name;
639 ParameterType init, value, min, max;
640 ofEvent<ParameterType> changedE;
641 bool bInNotify;
642 bool serializable;
643 std::vector<std::weak_ptr<ofParameterGroup::Value>> parents;
644 };
645
646 std::shared_ptr<Value> obj;
647 std::function<void(const ParameterType & v)> setMethod;
648
649 void eventsSetValue(const ParameterType & v);
650 void noEventsSetValue(const ParameterType & v);
651
652 template<typename T, typename F>
654};
655
656
657template<typename ParameterType>
659:obj(std::make_shared<Value>())
660,setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)){}
661
662template<typename ParameterType>
664:obj(v.obj)
665,setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)) {}
666
667template<typename ParameterType>
669:obj(std::make_shared<Value>(v))
670,setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)) {}
671
672template<typename ParameterType>
673ofParameter<ParameterType>::ofParameter(const std::string& name, const ParameterType & v)
674:obj(std::make_shared<Value>(name, v))
675,setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)){}
676
677template<typename ParameterType>
678ofParameter<ParameterType>::ofParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max)
679:obj(std::make_shared<Value>(name, v, min, max))
680,setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)){}
681
682
683template<typename ParameterType>
688
689template<typename ParameterType>
690inline const ParameterType & ofParameter<ParameterType>::operator=(const ParameterType & v){
691 set(v);
692 return obj->value;
693}
694
695template<typename ParameterType>
697 setMethod(v);
698 return *this;
699}
700
701template<typename ParameterType>
702ofParameter<ParameterType> & ofParameter<ParameterType>::set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max){
703 setName(name);
704 set(value);
705 setMin(min);
706 setMax(max);
707 setInit(value);
708 return *this;
709}
710
711template<typename ParameterType>
712ofParameter<ParameterType> & ofParameter<ParameterType>::set(const std::string& name, const ParameterType & value){
713 setName(name);
714 set(value);
715 return *this;
716}
717
718template<typename ParameterType>
720 noEventsSetValue(v);
721 return *this;
722}
723
724template<typename ParameterType>
725inline const ParameterType & ofParameter<ParameterType>::get() const{
726 return obj->value;
727}
728template<typename ParameterType>
729inline const ParameterType * ofParameter<ParameterType>::operator->() const{
730 return &obj->value;
731}
732
733template<typename ParameterType>
734inline void ofParameter<ParameterType>::eventsSetValue(const ParameterType & v){
735
736 // If the object is notifying its parents, just set the value without triggering an event.
737 if(obj->bInNotify)
738 {
739 noEventsSetValue(v);
740 }
741 else
742 {
743 // Mark the object as in its notification loop.
744 obj->bInNotify = true;
745
746 // Set the value.
747 obj->value = v;
748
749 // Notify any local subscribers.
750 ofNotifyEvent(obj->changedE,obj->value,this);
751
752 // Notify all parents, if there are any.
753 if(!obj->parents.empty())
754 {
755 // Erase each invalid parent
756 obj->parents.erase(std::remove_if(obj->parents.begin(),
757 obj->parents.end(),
758 [](const std::weak_ptr<ofParameterGroup::Value> & p){ return p.expired(); }),
759 obj->parents.end());
760
761 // notify all leftover (valid) parents of this object's changed value.
762 // this can't happen in the same iterator as above, because a notified listener
763 // might perform similar cleanups that would corrupt our iterator
764 // (which appens for example if the listener calls getFirstParent on us)
765 for(auto & parent: obj->parents){
766 auto p = parent.lock();
767 if(p){
768 p->notifyParameterChanged(*this);
769 }
770 }
771 }
772 obj->bInNotify = false;
773 }
774}
775
776template<typename ParameterType>
777inline void ofParameter<ParameterType>::noEventsSetValue(const ParameterType & v){
778 obj->value = v;
779}
780
781
782template<typename ParameterType>
784 obj->serializable = serializable;
785}
786
787template<typename ParameterType>
789 return of::priv::has_stream_operators<ParameterType>::value && obj->serializable;
790}
791
792template<typename ParameterType>
794 return false;
795}
796
797template<typename ParameterType>
799 return typeid(ParameterType).name();
800}
801
802template<typename ParameterType>
803void ofParameter<ParameterType>::setMin(const ParameterType & min){
804 obj->min = min;
805}
806
807template<typename ParameterType>
809 return obj->min;
810}
811
812template<typename ParameterType>
813void ofParameter<ParameterType>::setMax(const ParameterType & max){
814 obj->max = max;
815}
816
817template<typename ParameterType>
819 return obj->max;
820}
821
822template<typename ParameterType>
823void ofParameter<ParameterType>::setInit(const ParameterType & init){
824 obj->init = init;
825}
826
827template<typename ParameterType>
829 return obj->init;
830}
831
832template<typename ParameterType>
834 setMethod(obj->init);
835}
836
837template<typename ParameterType>
838inline ofParameter<ParameterType>::operator const ParameterType & () const{
839 return obj->value;
840}
841
842template<typename ParameterType>
843void ofParameter<ParameterType>::setName(const std::string & name){
844 obj->name = name;
845}
846
847template<typename ParameterType>
849 return obj->name;
850}
851
852template<typename ParameterType>
853inline std::string ofParameter<ParameterType>::toString() const{
854 try{
855 return of::priv::toStringImpl(obj->value);
856 }catch(...){
857 ofLogError("ofParameter") << "Trying to serialize non-serializable parameter";
858 return "";
859 }
860}
861
862template<typename ParameterType>
863inline void ofParameter<ParameterType>::fromString(const std::string & str){
864 try{
865 set(of::priv::fromStringImpl<ParameterType>(str));
866 }catch(...){
867 ofLogError("ofParameter") << "Trying to de-serialize non-serializable parameter";
868 }
869}
870
871template<typename ParameterType>
873 setMethod = std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1);
874}
875
876template<typename ParameterType>
878 setMethod = std::bind(&ofParameter<ParameterType>::noEventsSetValue, this, std::placeholders::_1);
879}
880
881template<typename ParameterType>
883 ParameterType r = obj->value;
884 obj->value++;
885 set(obj->value);
886 return r;
887}
888
889template<typename ParameterType>
891 ++obj->value;
892 set(obj->value);
893 return *this;
894}
895
896template<typename ParameterType>
898 ParameterType r = obj->value;
899 obj->value--;
900 set(obj->value);
901 return r;
902}
903
904template<typename ParameterType>
906 --obj->value;
907 set(obj->value);
908 return *this;
909}
910
911template<typename ParameterType>
912template<typename OtherType>
914 obj->value+=v;
915 set(obj->value);
916 return *this;
917}
918
919template<typename ParameterType>
920template<typename OtherType>
922 obj->value-=v;
923 set(obj->value);
924 return *this;
925}
926
927template<typename ParameterType>
928template<typename OtherType>
930 obj->value*=v;
931 set(obj->value);
932 return *this;
933}
934
935template<typename ParameterType>
936template<typename OtherType>
938 obj->value/=v;
939 set(obj->value);
940 return *this;
941}
942
943template<typename ParameterType>
944template<typename OtherType>
946 obj->value%=v;
947 set(obj->value);
948 return *this;
949}
950
951template<typename ParameterType>
952template<typename OtherType>
954 obj->value&=v;
955 set(obj->value);
956 return *this;
957}
958
959template<typename ParameterType>
960template<typename OtherType>
962 obj->value|=v;
963 set(obj->value);
964 return *this;
965}
966
967template<typename ParameterType>
968template<typename OtherType>
970 obj->value^=v;
971 set(obj->value);
972 return *this;
973}
974
975template<typename ParameterType>
976template<typename OtherType>
978 obj->value<<=v;
979 set(obj->value);
980 return *this;
981}
982
983template<typename ParameterType>
984template<typename OtherType>
986 obj->value>>=v;
987 set(obj->value);
988 return *this;
989}
990
991template<typename ParameterType>
995
996template<typename ParameterType>
997std::shared_ptr<ofAbstractParameter> ofParameter<ParameterType>::newReference() const{
998 return std::make_shared<ofParameter<ParameterType>>(*this);
999}
1000
1001template<typename ParameterType>
1003 obj->parents.emplace_back(parent.obj);
1004}
1005
1006template<typename ParameterType>
1008 return obj->changedE.size();
1009}
1010
1011template<typename ParameterType>
1013 return obj.get();
1014}
1015
1016template<>
1018public:
1019 ofParameter();
1020 ofParameter(const std::string& name);
1021
1022 ofParameter<void>& set(const std::string & name);
1023
1024 void setName(const std::string & name);
1025 std::string getName() const;
1026
1027 std::string toString() const;
1028 void fromString(const std::string & name);
1029
1030 template<class ListenerClass, typename ListenerMethod>
1031 void addListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){
1032 ofAddListener(obj->changedE,listener,method,prio);
1033 }
1034
1035 template<class ListenerClass, typename ListenerMethod>
1036 void removeListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP){
1037 ofRemoveListener(obj->changedE,listener,method,prio);
1038 }
1039
1040 template<typename... Args>
1041 std::unique_ptr<of::priv::AbstractEventToken> newListener(Args...args) {
1042 return obj->changedE.newListener(args...);
1043 }
1044
1045 void trigger();
1046 void trigger(const void * sender);
1047
1048 void enableEvents();
1049 void disableEvents();
1050 bool isSerializable() const;
1051 bool isReadOnly() const;
1052 std::string valueType() const;
1053
1055
1056 void setSerializable(bool serializable);
1057 std::shared_ptr<ofAbstractParameter> newReference() const;
1058
1059 void setParent(ofParameterGroup & _parent);
1060
1062 auto first = std::find_if(obj->parents.begin(),obj->parents.end(),[](std::weak_ptr<ofParameterGroup::Value> p){return p.lock()!=nullptr;});
1063 if(first!=obj->parents.end()){
1064 return first->lock();
1065 }else{
1066 return std::shared_ptr<ofParameterGroup::Value>(nullptr);
1067 }
1068 }
1069 size_t getNumListeners() const;
1070
1071 const void* getInternalObject() const{
1072 return obj.get();
1073 }
1074protected:
1075
1076private:
1077 class Value{
1078 public:
1079 Value()
1080 :serializable(false){}
1081
1082 Value(std::string name)
1083 :name(name)
1084 ,serializable(false){}
1085
1086 std::string name;
1087 ofEvent<void> changedE;
1088 bool serializable;
1089 std::vector<std::weak_ptr<ofParameterGroup::Value>> parents;
1090 };
1091 std::shared_ptr<Value> obj;
1092};
1093
1094
1095
1106template<typename ParameterType,typename Friend>
1108public:
1110// ofReadOnlyParameter(ofParameter<ParameterType> & p);
1111// ofReadOnlyParameter(ofReadOnlyParameter<ParameterType,Friend> & p);
1112 ofReadOnlyParameter(const ParameterType & v);
1113 ofReadOnlyParameter(const std::string& name, const ParameterType & v);
1114 ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max);
1115
1116 const ParameterType & get() const;
1117 const ParameterType * operator->() const;
1118 operator const ParameterType & () const;
1119
1120 std::string getName() const;
1121
1122 ParameterType getMin() const;
1123
1124 ParameterType getMax() const;
1125
1126 std::string toString() const;
1127
1128 template<class ListenerClass, typename ListenerMethod>
1129 void addListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP);
1130
1131 template<class ListenerClass, typename ListenerMethod>
1132 void removeListener(ListenerClass * listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP);
1133
1134 std::shared_ptr<ofAbstractParameter> newReference() const;
1135
1136 template<typename... Args>
1137 std::unique_ptr<of::priv::AbstractEventToken> newListener(Args...args);
1138
1139 bool isSerializable() const;
1140 bool isReadOnly() const;
1141 std::string valueType() const;
1142
1143protected:
1144 void setName(const std::string & name);
1145 void enableEvents();
1146 void disableEvents();
1147 void setSerializable(bool s);
1148
1149 template<typename OtherFriend>
1152
1155 const ParameterType & operator=(const ParameterType & v);
1156
1157 ParameterType operator++(int v);
1159
1160 ParameterType operator--(int v);
1162
1163 template<typename OtherType>
1165 template<typename OtherType>
1167 template<typename OtherType>
1169 template<typename OtherType>
1171 template<typename OtherType>
1173 template<typename OtherType>
1175 template<typename OtherType>
1177 template<typename OtherType>
1179 template<typename OtherType>
1181 template<typename OtherType>
1183
1184
1185 ofReadOnlyParameter<ParameterType,Friend>& set(const ParameterType & v);
1186
1187 ofReadOnlyParameter<ParameterType,Friend>& set(const std::string& name, const ParameterType & value);
1188 ofReadOnlyParameter<ParameterType,Friend>& set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max);
1189
1190 void setMin(const ParameterType & min);
1191 void setMax(const ParameterType & max);
1192 void setInit(const ParameterType & init);
1193
1194 void fromString(const std::string & str);
1195
1196 void setParent(ofParameterGroup & _parent);
1197
1199 return parameter.getFirstParent();
1200 }
1201
1202 const void* getInternalObject() const{
1203 return parameter.getInternalObject();
1204 }
1205
1207
1208 template<typename T>
1209 friend class ofParameter;
1210 friend class ofParameterGroup;
1211 friend Friend;
1212 template<typename T, typename OtherFriend>
1214};
1215
1216
1217template<typename ParameterType,typename Friend>
1219
1220//template<typename ParameterType,typename Friend>
1221//inline ofReadOnlyParameter<ParameterType,Friend>::ofReadOnlyParameter(ofParameter<ParameterType> & p)
1222//:parameter(p){}
1223
1224//template<typename ParameterType,typename Friend>
1225//inline ofReadOnlyParameter<ParameterType,Friend>::ofReadOnlyParameter(ofReadOnlyParameter<ParameterType,Friend> & p)
1226//:parameter(p){}
1227
1228template<typename ParameterType,typename Friend>
1231
1232template<typename ParameterType,typename Friend>
1233inline ofReadOnlyParameter<ParameterType,Friend>::ofReadOnlyParameter(const std::string& name, const ParameterType & v)
1234:parameter(name,v){}
1235
1236template<typename ParameterType,typename Friend>
1237inline ofReadOnlyParameter<ParameterType,Friend>::ofReadOnlyParameter(const std::string& name, const ParameterType & v, const ParameterType & min, const ParameterType & max)
1238:parameter(name,v,min,max){}
1239
1240
1241template<typename ParameterType,typename Friend>
1242inline const ParameterType & ofReadOnlyParameter<ParameterType,Friend>::get() const{
1243 return parameter.get();
1244}
1245
1246template<typename ParameterType,typename Friend>
1248 return &parameter.get();
1249}
1250
1251template<typename ParameterType,typename Friend>
1252inline ofReadOnlyParameter<ParameterType,Friend>::operator const ParameterType & () const{
1253 return parameter.get();
1254}
1255
1256
1257template<typename ParameterType,typename Friend>
1259 return parameter.getName();
1260}
1261
1262
1263template<typename ParameterType,typename Friend>
1265 return parameter.getMin();
1266}
1267
1268
1269template<typename ParameterType,typename Friend>
1271 return parameter.getMax();
1272}
1273
1274
1275template<typename ParameterType,typename Friend>
1277 return parameter.toString();
1278}
1279
1280template<typename ParameterType,typename Friend>
1282 return typeid(ParameterType).name();
1283}
1284
1285
1286template<typename ParameterType,typename Friend>
1287template<class ListenerClass, typename ListenerMethod>
1288inline void ofReadOnlyParameter<ParameterType,Friend>::addListener(ListenerClass * listener, ListenerMethod method, int prio){
1289 parameter.addListener(listener,method,prio);
1290}
1291
1292
1293template<typename ParameterType,typename Friend>
1294template<class ListenerClass, typename ListenerMethod>
1295inline void ofReadOnlyParameter<ParameterType,Friend>::removeListener(ListenerClass * listener, ListenerMethod method, int prio){
1296 parameter.removeListener(listener,method,prio);
1297}
1298
1299
1300template<typename ParameterType,typename Friend>
1301template<typename... Args>
1302inline std::unique_ptr<of::priv::AbstractEventToken> ofReadOnlyParameter<ParameterType,Friend>::newListener(Args...args) {
1303 return parameter.newListener(args...);
1304}
1305
1306template<typename ParameterType,typename Friend>
1307inline void ofReadOnlyParameter<ParameterType,Friend>::setName(const std::string & name){
1308 parameter.setName(name);
1309}
1310
1311template<typename ParameterType,typename Friend>
1315
1316template<typename ParameterType,typename Friend>
1320
1321template<typename ParameterType,typename Friend>
1323 return parameter.isSerializable();
1324}
1325
1326template<typename ParameterType,typename Friend>
1328 return true;
1329}
1330
1331template<typename ParameterType,typename Friend>
1333 parameter.setSerializable(s);
1334}
1335
1336template<typename ParameterType,typename Friend>
1337template<typename OtherFriend>
1341
1342template<typename ParameterType,typename Friend>
1346
1347template<typename ParameterType,typename Friend>
1352
1353template<typename ParameterType,typename Friend>
1358
1359template<typename ParameterType,typename Friend>
1360inline const ParameterType & ofReadOnlyParameter<ParameterType,Friend>::operator=(const ParameterType & v){
1361 parameter = v;
1362 return v;
1363}
1364
1365
1366template<typename ParameterType,typename Friend>
1368 return parameter++;
1369}
1370
1371template<typename ParameterType,typename Friend>
1375
1376
1377template<typename ParameterType,typename Friend>
1379 return parameter--;
1380}
1381
1382template<typename ParameterType,typename Friend>
1386
1387
1388template<typename ParameterType,typename Friend>
1389template<typename OtherType>
1394
1395template<typename ParameterType,typename Friend>
1396template<typename OtherType>
1401
1402template<typename ParameterType,typename Friend>
1403template<typename OtherType>
1408
1409template<typename ParameterType,typename Friend>
1410template<typename OtherType>
1415
1416template<typename ParameterType,typename Friend>
1417template<typename OtherType>
1422
1423template<typename ParameterType,typename Friend>
1424template<typename OtherType>
1429
1430template<typename ParameterType,typename Friend>
1431template<typename OtherType>
1436
1437template<typename ParameterType,typename Friend>
1438template<typename OtherType>
1440 parameter^=v;
1441 return *this;
1442}
1443
1444template<typename ParameterType,typename Friend>
1445template<typename OtherType>
1447 parameter<<=v;
1448 return *this;
1449}
1450
1451template<typename ParameterType,typename Friend>
1452template<typename OtherType>
1457
1458
1459
1460template<typename ParameterType,typename Friend>
1462 parameter.set(v);
1463 return *this;
1464}
1465
1466template<typename ParameterType,typename Friend>
1467inline ofReadOnlyParameter<ParameterType,Friend> & ofReadOnlyParameter<ParameterType,Friend>::set(const std::string& name, const ParameterType & value){
1468 parameter.set(name,value);
1469 return *this;
1470}
1471
1472template<typename ParameterType,typename Friend>
1473inline ofReadOnlyParameter<ParameterType,Friend> & ofReadOnlyParameter<ParameterType,Friend>::set(const std::string& name, const ParameterType & value, const ParameterType & min, const ParameterType & max){
1474 parameter.set(name,value,min,max);
1475 return *this;
1476}
1477
1478
1479template<typename ParameterType,typename Friend>
1480inline void ofReadOnlyParameter<ParameterType,Friend>::setMin(const ParameterType & min){
1481 parameter.setMin(min);
1482}
1483
1484template<typename ParameterType,typename Friend>
1485inline void ofReadOnlyParameter<ParameterType,Friend>::setMax(const ParameterType & max){
1486 parameter.setMax(max);
1487}
1488
1489template<typename ParameterType,typename Friend>
1490inline void ofReadOnlyParameter<ParameterType,Friend>::setInit(const ParameterType & init){
1491 parameter.setInit(init);
1492}
1493
1494template<typename ParameterType,typename Friend>
1496 parameter.fromString(str);
1497}
1498
1499template<typename ParameterType,typename Friend>
1500std::shared_ptr<ofAbstractParameter> ofReadOnlyParameter<ParameterType,Friend>::newReference() const{
1501 return std::make_shared<ofReadOnlyParameter<ParameterType,Friend>>(*this);
1502}
1503
1504template<typename ParameterType,typename Friend>
Base class for ofParameter, ofReadOnlyParameter and ofParameterGroup.
Definition ofParameter.h:24
virtual std::string valueType() const =0
ofParameterGroup & castGroup()
Definition ofParameter.cpp:64
virtual std::string toString() const =0
virtual const ofParameterGroup getFirstParent() const =0
virtual void setName(const std::string &name)=0
const ofReadOnlyParameter< ParameterType, Friend > & castReadOnly() const
Definition ofParameter.h:55
virtual std::string type() const
Definition ofParameter.cpp:34
virtual void setParent(ofParameterGroup &_parent)=0
ofReadOnlyParameter< ParameterType, Friend > & castReadOnly()
Definition ofParameter.h:50
virtual std::string escape(const std::string &str) const
Definition ofParameter.cpp:11
virtual std::string getEscapedName() const
Definition ofParameter.cpp:6
virtual std::shared_ptr< ofAbstractParameter > newReference() const =0
virtual void setSerializable(bool serializable)=0
virtual std::string getName() const =0
const ofParameter< ParameterType > & cast() const
Definition ofParameter.h:45
virtual bool isReferenceTo(const ofAbstractParameter &other) const
Definition ofParameter.cpp:48
virtual const void * getInternalObject() const =0
friend std::istream & operator>>(std::istream &is, ofAbstractParameter &p)
Definition ofParameter.cpp:57
virtual bool isSerializable() const =0
virtual ~ofAbstractParameter()
Definition ofParameter.h:26
virtual bool isReadOnly() const =0
friend std::ostream & operator<<(std::ostream &os, const ofAbstractParameter &p)
Definition ofParameter.cpp:52
virtual void fromString(const std::string &str)=0
ofParameter< ParameterType > & cast()
Definition ofParameter.h:40
std::vector< std::string > getGroupHierarchyNames() const
Definition ofParameter.cpp:38
ofColor represents a color in openFrameworks.
Definition ofColor.h:20
Definition ofEvent.h:444
Derived log class for easy error logging.
Definition ofLog.h:606
const ofParameterGroup getFirstParent() const
Definition ofParameter.h:1061
const void * getInternalObject() const
Definition ofParameter.h:1071
std::unique_ptr< of::priv::AbstractEventToken > newListener(Args...args)
Definition ofParameter.h:1041
void addListener(ListenerClass *listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofParameter.h:1031
ofParameter(const std::string &name)
void removeListener(ListenerClass *listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofParameter.h:1036
Definition ofParameter.h:84
void remove(std::size_t index)
ofParameter< ofDefaultVec2 > & getVec2f(const std::string &name)
bool isSerializable() const
Definition ofParameterGroup.cpp:476
ofParameter< ofDefaultVec4 > & getVec4f(const std::string &name)
const ofParameter< ofPoint > & getPoint(const std::string &name) const
std::vector< std::shared_ptr< ofAbstractParameter > >::iterator end()
Definition ofParameterGroup.cpp:504
const ofParameter< void > & getVoid(const std::string &name) const
const ofAbstractParameter & get(const std::string &name) const
std::size_t size() const
Definition ofParameterGroup.cpp:326
const ofParameter< bool > & getBool(const std::string &name) const
ofAbstractParameter & back()
Definition ofParameterGroup.cpp:456
ofParameter< bool > & getBool(const std::string &name)
void setParent(ofParameterGroup &parent)
Definition ofParameterGroup.cpp:492
ofParameterGroup & getGroup(const std::string &name)
std::shared_ptr< ofAbstractParameter > newReference() const
Definition ofParameterGroup.cpp:488
const ofParameter< float > & getFloat(const std::string &name) const
std::string valueType() const
Definition ofParameterGroup.cpp:66
ofParameter< ofRectangle > & getRectangle(const std::string &name)
void clear()
Definition ofParameterGroup.cpp:60
ofParameter< ofDefaultVec3 > & getVec3f(const std::string &name)
const ofParameter< ofDefaultVec4 > & getVec4f(const std::string &name) const
std::vector< std::shared_ptr< ofAbstractParameter > >::reverse_iterator rend()
Definition ofParameterGroup.cpp:520
ofEvent< ofAbstractParameter > & parameterChangedE()
Definition ofParameterGroup.cpp:452
friend std::ostream & operator<<(std::ostream &os, const ofParameterGroup &group)
ofParameter< float > & getFloat(const std::string &name)
void setSerializable(bool serializable)
Definition ofParameterGroup.cpp:472
bool getIsReadOnly(int position) const
const ofParameter< ofShortColor > & getShortColor(const std::string &name) const
ofAbstractParameter & operator[](const std::string &name)
ofParameter< int > & getInt(const std::string &name)
const ofParameter< std::string > & getString(const std::string &name) const
std::string getEscapedName() const
Definition ofParameterGroup.cpp:358
ofAbstractParameter & get(const std::string &name)
ofParameter< ofColor > & getColor(const std::string &name)
int getPosition(const std::string &name) const
Definition ofParameterGroup.cpp:344
ofParameter< ofFloatColor > & getFloatColor(const std::string &name)
void setName(const std::string &name)
Definition ofParameterGroup.cpp:354
const ofParameter< ofRectangle > & getRectangle(const std::string &name) const
const ofParameterGroup & getGroup(const std::string &name) const
void add(ofAbstractParameter &p, Args &... parameters)
Definition ofParameter.h:102
void remove(const std::string &name)
ofParameter< char > & getChar(const std::string &name)
const ofParameter< ofDefaultVec2 > & getVec2f(const std::string &name) const
ofParameterGroup()
Definition ofParameterGroup.cpp:14
const ofParameter< char > & getChar(const std::string &name) const
bool contains(const std::string &name) const
Definition ofParameterGroup.cpp:430
const ofParameter< ofFloatColor > & getFloatColor(const std::string &name) const
void fromString(const std::string &name)
Definition ofParameterGroup.cpp:372
ofAbstractParameter & front()
Definition ofParameterGroup.cpp:460
const ofAbstractParameter & operator[](const std::string &name) const
bool isReadOnly() const
Definition ofParameterGroup.cpp:480
const ofParameter< ofDefaultVec3 > & getVec3f(const std::string &name) const
ofParameter< std::string > & getString(const std::string &name)
std::vector< std::shared_ptr< ofAbstractParameter > >::iterator begin()
Definition ofParameterGroup.cpp:500
const ofParameter< int > & getInt(const std::string &name) const
ofParameter< ofShortColor > & getShortColor(const std::string &name)
const void * getInternalObject() const
Definition ofParameterGroup.cpp:484
const ofParameter< ofColor > & getColor(const std::string &name) const
void remove(ofAbstractParameter &param)
Definition ofParameterGroup.cpp:31
std::string getName() const
Definition ofParameterGroup.cpp:350
ofParameterGroup(const std::string &name, Args &... p)
Definition ofParameter.h:95
std::string getType(std::size_t position) const
Definition ofParameterGroup.cpp:338
ofParameter< ofPoint > & getPoint(const std::string &name)
const ofReadOnlyParameter< ParameterType, Friend > & getReadOnly(const std::string &name) const
Definition ofParameter.h:312
ofParameter< void > & getVoid(const std::string &name)
std::string toString() const
Definition ofParameterGroup.cpp:366
std::vector< std::shared_ptr< ofAbstractParameter > >::reverse_iterator rbegin()
Definition ofParameterGroup.cpp:516
ofParameterGroup(const std::string &name)
Definition ofParameter.h:89
ofParameter holds a value and notifies its listeners when it changes.
Definition ofParameter.h:492
ofParameter< ParameterType > & operator/=(const OtherType &v)
Definition ofParameter.h:937
bool isReadOnly() const
Definition ofParameter.h:793
std::string getName() const
Definition ofParameter.h:848
void fromString(const std::string &name)
Definition ofParameter.h:863
void disableEvents()
Definition ofParameter.h:877
void setMin(const ParameterType &min)
Definition ofParameter.h:803
void enableEvents()
Definition ofParameter.h:872
ofParameter< ParameterType > & operator=(const ofParameter< ParameterType > &v)
Definition ofParameter.h:684
ParameterType operator--(int v)
Definition ofParameter.h:897
ofParameter< ParameterType > & set(const ParameterType &v)
Definition ofParameter.h:696
ofParameter< ParameterType > & operator>>=(const OtherType &v)
Definition ofParameter.h:985
const ParameterType & get() const
Definition ofParameter.h:725
void makeReferenceTo(ofParameter< ParameterType > &mom)
Definition ofParameter.h:992
void setSerializable(bool serializable)
Definition ofParameter.h:783
void setInit(const ParameterType &init)
Definition ofParameter.h:823
ofParameter< ParameterType > & set(const std::string &name, const ParameterType &v)
Definition ofParameter.h:712
ofParameter()
Definition ofParameter.h:658
ofParameter(const ParameterType &v)
Definition ofParameter.h:668
const ofParameterGroup getFirstParent() const
Definition ofParameter.h:586
void setMax(const ParameterType &max)
Definition ofParameter.h:813
ofParameter< ParameterType > & operator-=(const OtherType &v)
Definition ofParameter.h:921
ParameterType operator++(int v)
Definition ofParameter.h:882
ofParameter< ParameterType > & operator%=(const OtherType &v)
Definition ofParameter.h:945
const ParameterType & operator=(const ParameterType &v)
Definition ofParameter.h:690
ofParameter< ParameterType > & setWithoutEventNotifications(const ParameterType &v)
Definition ofParameter.h:719
void reInit()
Definition ofParameter.h:833
ofParameter(const ofParameter< ParameterType > &v)
Definition ofParameter.h:663
ofParameter< ParameterType > & operator<<=(const OtherType &v)
Definition ofParameter.h:977
ofParameter(const std::string &name, const ParameterType &v, const ParameterType &min, const ParameterType &max)
Definition ofParameter.h:678
ofParameter(const std::string &name, const ParameterType &v)
Definition ofParameter.h:673
ofParameter< ParameterType > & operator--()
Definition ofParameter.h:905
ofParameter< ParameterType > & operator^=(const OtherType &v)
Definition ofParameter.h:969
ofParameter< ParameterType > & set(const std::string &name, const ParameterType &v, const ParameterType &min, const ParameterType &max)
Definition ofParameter.h:702
ofParameter< ParameterType > & operator+=(const OtherType &v)
Definition ofParameter.h:913
std::string valueType() const
Definition ofParameter.h:798
const void * getInternalObject() const
Definition ofParameter.h:1012
std::shared_ptr< ofAbstractParameter > newReference() const
Definition ofParameter.h:997
ofParameter< ParameterType > & operator|=(const OtherType &v)
Definition ofParameter.h:961
const ParameterType * operator->() const
Definition ofParameter.h:729
std::string toString() const
Definition ofParameter.h:853
size_t getNumListeners() const
Definition ofParameter.h:1007
void setParent(ofParameterGroup &_parent)
Definition ofParameter.h:1002
void addListener(ListenerClass *listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofParameter.h:518
ofParameter< ParameterType > & operator&=(const OtherType &v)
Definition ofParameter.h:953
std::unique_ptr< of::priv::AbstractEventToken > newListener(Args...args)
Definition ofParameter.h:528
void setName(const std::string &name)
Definition ofParameter.h:843
ofParameter< ParameterType > & operator*=(const OtherType &v)
Definition ofParameter.h:929
ParameterType getInit() const
Definition ofParameter.h:828
ParameterType getMax() const
Definition ofParameter.h:818
void removeListener(ListenerClass *listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofParameter.h:523
ofParameter< ParameterType > & operator++()
Definition ofParameter.h:890
bool isSerializable() const
Definition ofParameter.h:788
ParameterType getMin() const
Definition ofParameter.h:808
ofReadOnlyParameter holds a value and notifies its listeners when it changes.
Definition ofParameter.h:1107
bool isSerializable() const
Definition ofParameter.h:1322
void setMax(const ParameterType &max)
Definition ofParameter.h:1485
ParameterType getMax() const
Definition ofParameter.h:1270
const ParameterType * operator->() const
Definition ofParameter.h:1247
ofReadOnlyParameter< ParameterType, Friend > & operator%=(const OtherType &v)
Definition ofParameter.h:1418
ofReadOnlyParameter< ParameterType, Friend > & operator|=(const OtherType &v)
Definition ofParameter.h:1432
void setName(const std::string &name)
Definition ofParameter.h:1307
void makeReferenceTo(ofReadOnlyParameter< ParameterType, OtherFriend > mom)
Definition ofParameter.h:1338
friend class ofReadOnlyParameter
Definition ofParameter.h:1213
std::string valueType() const
Definition ofParameter.h:1281
ofReadOnlyParameter< ParameterType, Friend > & operator--()
Definition ofParameter.h:1383
void setInit(const ParameterType &init)
Definition ofParameter.h:1490
const ParameterType & get() const
Definition ofParameter.h:1242
void removeListener(ListenerClass *listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofParameter.h:1295
std::unique_ptr< of::priv::AbstractEventToken > newListener(Args...args)
Definition ofParameter.h:1302
ofReadOnlyParameter< ParameterType, Friend > & operator-=(const OtherType &v)
Definition ofParameter.h:1397
ofReadOnlyParameter< ParameterType, Friend > & operator=(const ofReadOnlyParameter< ParameterType, Friend > &v)
Definition ofParameter.h:1348
void setParent(ofParameterGroup &_parent)
Definition ofParameter.h:1505
ofReadOnlyParameter< ParameterType, Friend > & operator<<=(const OtherType &v)
Definition ofParameter.h:1446
ofReadOnlyParameter< ParameterType, Friend > & operator*=(const OtherType &v)
Definition ofParameter.h:1404
friend Friend
Definition ofParameter.h:1211
void setMin(const ParameterType &min)
Definition ofParameter.h:1480
const ofParameterGroup getFirstParent() const
Definition ofParameter.h:1198
ofReadOnlyParameter< ParameterType, Friend > & operator>>=(const OtherType &v)
Definition ofParameter.h:1453
std::string getName() const
Definition ofParameter.h:1258
void addListener(ListenerClass *listener, ListenerMethod method, int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofParameter.h:1288
ParameterType getMin() const
Definition ofParameter.h:1264
bool isReadOnly() const
Definition ofParameter.h:1327
ofReadOnlyParameter< ParameterType, Friend > & operator++()
Definition ofParameter.h:1372
std::string toString() const
Definition ofParameter.h:1276
void disableEvents()
Definition ofParameter.h:1317
std::shared_ptr< ofAbstractParameter > newReference() const
Definition ofParameter.h:1500
ofReadOnlyParameter< ParameterType, Friend > & set(const ParameterType &v)
Definition ofParameter.h:1461
ofReadOnlyParameter< ParameterType, Friend > & operator/=(const OtherType &v)
Definition ofParameter.h:1411
const void * getInternalObject() const
Definition ofParameter.h:1202
void enableEvents()
Definition ofParameter.h:1312
ofReadOnlyParameter< ParameterType, Friend > & operator^=(const OtherType &v)
Definition ofParameter.h:1439
ofReadOnlyParameter< ParameterType, Friend > & operator&=(const OtherType &v)
Definition ofParameter.h:1425
ofParameter< ParameterType > parameter
Definition ofParameter.h:1206
ofReadOnlyParameter< ParameterType, Friend > & operator+=(const OtherType &v)
Definition ofParameter.h:1390
void fromString(const std::string &str)
Definition ofParameter.h:1495
void setSerializable(bool s)
Definition ofParameter.h:1332
A class representing a 2D rectangle.
Definition ofRectangle.h:87
ofVec2f is a class for storing a two dimensional vector.
Definition ofVec2f.h:72
ofVec3f is a class for storing a three dimensional vector.
Definition ofVec3f.h:79
Definition ofVec4f.h:11
Definition ofVectorMath.h:121
auto yes(Args &&... args) -> decltype(bernoulli(std::forward< Args >(args)...))
Definition ofRandomDistributions.h:500
Definition ofEvents.cpp:625
Definition ofPixels.h:1522
@ OF_EVENT_ORDER_AFTER_APP
Definition ofEvent.h:381
void ofRemoveListener(EventType &event, ListenerClass *listener, void(ListenerClass::*listenerMethod)(const void *, ArgumentsType &), int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofEventUtils.h:120
bool ofNotifyEvent(EventType &event, ArgumentsType &args, SenderType *sender)
Definition ofEventUtils.h:207
void ofAddListener(EventType &event, ListenerClass *listener, void(ListenerClass::*listenerMethod)(const void *, ArgumentsType &), int prio=OF_EVENT_ORDER_AFTER_APP)
Definition ofEventUtils.h:19
std::string ofToString(const T &)
Convert a value to a string.
Definition ofUtils.h:657
std::ostream & operator<<(std::ostream &os, const ofMatrix3x3 &M)
Definition ofMatrix3x3.cpp:304
std::istream & operator>>(std::istream &is, ofMatrix3x3 &M)
Definition ofMatrix3x3.cpp:323