diff --git a/src/lib/par/disposition.hpp b/src/lib/par/disposition.hpp index d870c8bd4..14b47c839 100644 --- a/src/lib/par/disposition.hpp +++ b/src/lib/par/disposition.hpp @@ -44,6 +44,15 @@ namespace par { : public Domain { public: + template + X extract() const; + + template + void setVal (X); + + private: + template + bool isBaseDomainMatch() const; }; @@ -66,6 +75,58 @@ namespace par { { } }; + template + using FullDomain = BaseDomain; + + + + template + X + Disposition::extract() const + { + X result; // RVO + + if (isBaseDomainMatch()) + { // short-circuit by direct force-cast + retrieveInto (asValBuff (result)); + } + else + { // run full type-conversion double-dispatch + uint64_t valueBuffer; /////////////////////////////////////////////////OOO need a way to get a suitably sized intermediary buffer (without heap-allocation) + this->retrieveInto (asValBuff(valueBuffer)); + + FullDomain targetDomain; + this->transferTo (asValBuff(valueBuffer), targetDomain, asValBuff(result)); + } + return result; + } + + + template + void + Disposition::setVal (X changedVal) + { + if (isBaseDomainMatch()) + { // short-circuit by direct force-cast + setValFrom (asValBuff (changedVal)); + } + else + { // run full type-conversion double-dispatch + uint64_t valueBuffer; /////////////////////////////////////////////////OOO need a way to get a suitably sized intermediary buffer (without heap-allocation) + FullDomain targetDomain; + + targetDomain.transferTo (asValBuff(changedVal), *this, asValBuff(valueBuffer)); + this->setValFrom (asValBuff(valueBuffer)); + } + } + + + template + bool + Disposition::isBaseDomainMatch() const + { + return false; /////////////////////////OOO running into a dead end here? how can we possibly access a type tag marker without indirection?? + } }} // namespace lib::par diff --git a/src/lib/par/domain.hpp b/src/lib/par/domain.hpp index f3622132f..2cdbdc5f5 100644 --- a/src/lib/par/domain.hpp +++ b/src/lib/par/domain.hpp @@ -108,7 +108,7 @@ namespace par { virtual ~Domain(); ///< this is an interface virtual void applyLimit (ValBuff&) =0; - virtual void transferTo (ValBuff const& source, Domain& targetDomain, ValBuff& target) =0; + virtual void transferTo (ValBuff const& source, Domain& targetDomain, ValBuff& target) const =0; protected: }; diff --git a/src/lib/par/param-type.hpp b/src/lib/par/param-type.hpp index 333dc3ede..36ce49df0 100644 --- a/src/lib/par/param-type.hpp +++ b/src/lib/par/param-type.hpp @@ -74,7 +74,7 @@ _Pragma("GCC diagnostic ignored \"-Woverloaded-virtual\"") { public: void applyLimit (ValBuff&) override; - void transferTo (ValBuff const& source, Domain& targetDomain, ValBuff& target) override; + void transferTo (ValBuff const& source, Domain& targetDomain, ValBuff& target) const override; }; @@ -207,7 +207,7 @@ _Pragma("GCC diagnostic pop") template inline void - BaseDomain::transferTo (ValBuff const& source, Domain& targetDomain, ValBuff& target) + BaseDomain::transferTo (ValBuff const& source, Domain& targetDomain, ValBuff& target) const { targetDomain.conform (target, asValue (source)); targetDomain.applyLimit (target); diff --git a/src/lib/par/parameter.hpp b/src/lib/par/parameter.hpp index ae2cdb507..c2e7b5a24 100644 --- a/src/lib/par/parameter.hpp +++ b/src/lib/par/parameter.hpp @@ -32,6 +32,7 @@ #include "lib/par/disposition.hpp" #include "lib/polymorphic-value.hpp" #include "lib/meta/typelist-util.hpp" +#include "lib/util.hpp" #include @@ -46,6 +47,8 @@ namespace par { using ParamContainer = PolymorphicValue; } + using util::unConst; + /** @@ -60,7 +63,7 @@ namespace par { class Builder; template - VAL getVal(); + VAL getVal() const; template void setVal (VAL&&); @@ -119,9 +122,9 @@ namespace par { template VAL - Parameter::getVal() + Parameter::getVal() const { - UNIMPLEMENTED ("extract the »value«, possibly applying suitable type conversions"); + return unConst(this)->getPayload().extract(); } @@ -129,7 +132,7 @@ namespace par { void Parameter::setVal (VAL&& changedVal) { - UNIMPLEMENTED ("apply suitable type conversions and clamping, then transfer the new value into the Provision interface"); + getPayload().setVal (changedVal); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 6d582230e..6a32c8eae 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -82955,7 +82955,7 @@ - + @@ -82987,8 +82987,17 @@ - - + + + + + + + + + + + @@ -84487,7 +84496,8 @@ - + + @@ -84512,6 +84522,33 @@ + + + + + + + + + + + + + + + + +

+ auch im Hinblick darauf, daß ich später mal (möglichst mit dem gleichen generischen Code) auch komplexe Parameter-Typen handhaben möchte, wie Vektoren, Farb-Tripel und ganze Masken-Parametersätze... +

+ + +
+ +
+
+
+
@@ -84590,10 +84627,11 @@
- + + - +