diff options
Diffstat (limited to 'src/crepe/ValueBroker.hpp')
-rw-r--r-- | src/crepe/ValueBroker.hpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/crepe/ValueBroker.hpp b/src/crepe/ValueBroker.hpp new file mode 100644 index 0000000..61f7f6c --- /dev/null +++ b/src/crepe/ValueBroker.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include <memory> + +#include "ValueBroker.h" + +namespace crepe { + +template <typename T> +ValueBroker<T>::ValueBroker(T & value) : + setter([&value] (const T & target) { + value = std::move(target); + }), + getter([&value] () -> const int & { + return value; + }) + { +} + +template <typename T> +ValueBroker<T>::ValueBroker(const setter_t & setter, const getter_t & getter) : + setter(setter), + getter(getter) + { +} + +template <typename T> +const T & ValueBroker<T>::get() { + return this->getter(); +} + +template <typename T> +void ValueBroker<T>::set(const T & value) { + this->setter(value); +} + +} + |