diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-27 16:50:20 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-27 16:50:20 +0100 |
commit | ecc5761fa78ccb57db958467c3fc999aceadd409 (patch) | |
tree | 8e5f24133473de3f122d59262727a9f0a3a806c9 /src/crepe/ValueBroker.hpp | |
parent | e0b1ddae296037376948a4c6f200d89e6d1ba81e (diff) |
fix valuebroker/proxy system
Diffstat (limited to 'src/crepe/ValueBroker.hpp')
-rw-r--r-- | src/crepe/ValueBroker.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/crepe/ValueBroker.hpp b/src/crepe/ValueBroker.hpp new file mode 100644 index 0000000..ef31c17 --- /dev/null +++ b/src/crepe/ValueBroker.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include <memory> + +#include "ValueBroker.h" + +namespace crepe { + +template <typename T> +ValueBroker<T>::ValueBroker(T & value) : + value(value), + setter([] (T & value, const T & target) { + value = std::move(target); + }), + getter([] (T & value) -> const int & { + return value; + }) + { +} + +template <typename T> +ValueBroker<T>::ValueBroker(T & value, const setter_t & setter, const getter_t & getter) : + value(value), + setter(setter), + getter(getter) + { +} + +template <typename T> +const T & ValueBroker<T>::get() { + return this->getter(this->value); +} + +template <typename T> +void ValueBroker<T>::set(const T & value) { + this->setter(this->value, value); +} + +} + |