From ecc5761fa78ccb57db958467c3fc999aceadd409 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 27 Oct 2024 16:50:20 +0100 Subject: fix valuebroker/proxy system --- src/crepe/ValueBroker.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/crepe/ValueBroker.hpp (limited to 'src/crepe/ValueBroker.hpp') 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 + +#include "ValueBroker.h" + +namespace crepe { + +template +ValueBroker::ValueBroker(T & value) : + value(value), + setter([] (T & value, const T & target) { + value = std::move(target); + }), + getter([] (T & value) -> const int & { + return value; + }) + { +} + +template +ValueBroker::ValueBroker(T & value, const setter_t & setter, const getter_t & getter) : + value(value), + setter(setter), + getter(getter) + { +} + +template +const T & ValueBroker::get() { + return this->getter(this->value); +} + +template +void ValueBroker::set(const T & value) { + this->setter(this->value, value); +} + +} + -- cgit v1.2.3