|
8 | 8 |
|
9 | 9 | #include "ofColor.h" |
10 | 10 | #include "ofLog.h" |
11 | | -#include "ofRectangle.h" |
12 | 11 | #include "ofMathConstants.h" |
| 12 | +#include "ofRectangle.h" |
13 | 13 | #include "ofUtils.h" // ofToString |
14 | 14 |
|
15 | 15 | template <typename ParameterType> |
@@ -498,10 +498,46 @@ typename std::enable_if<!of::priv::has_loading_support<ParameterType>::value, Pa |
498 | 498 | template <typename ParameterType> |
499 | 499 | class ofParameter : public ofAbstractParameter { |
500 | 500 | public: |
| 501 | + |
| 502 | + /// \brief constructs a default ofParameter of type ParameterType |
| 503 | + /// \tparam ParameterType the type of the Value held by the ofParameter |
501 | 504 | ofParameter(); |
| 505 | + |
| 506 | + /// \brief constructs an ofParameter of type ParameterType as an alias of the Value of another ofParameter |
| 507 | + /// \tparam ParameterType the type of the value held by the ofParameter |
| 508 | + /// \param v the ofParameter to link to it's value |
502 | 509 | ofParameter(const ofParameter<ParameterType> & v); |
| 510 | + |
| 511 | + /// \brief constructs an ofParameter of type ParameterType initialized to value of same-type v |
| 512 | + /// \tparam ParameterType the type of the value held by the ofParameter |
| 513 | + /// \param v the value to initialize to |
503 | 514 | ofParameter(const ParameterType & v); |
| 515 | + |
| 516 | + /// \brief constructs an ofParameter of type ParameterType initialized to value of v |
| 517 | + /// where v is convertible to ParameterType, with an exception for bool which can cause |
| 518 | + /// unexpected behavious (as string and char arrays are convertible to bool) |
| 519 | + /// \tparam ParameterType the type of the value held by the ofParameter |
| 520 | + /// \tparam Arg a type convertible to ParameterType |
| 521 | + /// \param v the value to initialize to |
| 522 | + template < |
| 523 | + typename Arg, |
| 524 | + typename = std::enable_if_t<(std::is_convertible_v<Arg, ParameterType> and |
| 525 | + !((std::is_same_v<ParameterType, bool>)and!(std::is_arithmetic_v<Arg>)))>> |
| 526 | + ofParameter(const Arg & v); |
| 527 | + |
| 528 | + /// \brief constructs a named ofParameter of type ParameterType initialized to value of v |
| 529 | + /// \tparam ParameterType the type of the value held by the ofParameter |
| 530 | + /// \param name name of the parameter |
| 531 | + /// \param v the value to initialize to |
504 | 532 | ofParameter(const std::string & name, const ParameterType & v); |
| 533 | + |
| 534 | + /// \brief constructs a named ofParameter of type ParameterType initialized to value of v, |
| 535 | + /// with non-enforced constraints on the range of possible values |
| 536 | + /// \tparam ParameterType the type of the value held by the ofParameter |
| 537 | + /// \param name name of the parameter |
| 538 | + /// \param v the value to initialize to |
| 539 | + /// \param min the minimum value to be held |
| 540 | + /// \param max the maximum value to be held |
505 | 541 | ofParameter(const std::string & name, const ParameterType & v, const ParameterType & min, const ParameterType & max); |
506 | 542 |
|
507 | 543 | const ParameterType & get() const; |
@@ -677,7 +713,8 @@ ofParameter<ParameterType>::ofParameter(const ofParameter<ParameterType> & v) |
677 | 713 | , setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)) { } |
678 | 714 |
|
679 | 715 | template <typename ParameterType> |
680 | | -ofParameter<ParameterType>::ofParameter(const ParameterType & v) |
| 716 | +template <typename Arg, typename> |
| 717 | +ofParameter<ParameterType>::ofParameter(const Arg & v) |
681 | 718 | : obj(std::make_shared<Value>(v)) |
682 | 719 | , setMethod(std::bind(&ofParameter<ParameterType>::eventsSetValue, this, std::placeholders::_1)) { } |
683 | 720 |
|
|
0 commit comments