4#include <unordered_map>
6#define XCAL_PROPERTY_TYPE(type) \
7 Type type_() const override { return Type::type; }
25 virtual Type type_()
const = 0;
28 mutable bool_t is_changed_{
true};
35 static std::unordered_map<void *, MProperty *> proxy_to_self_;
38 template <
typename... Args>
39 requires(std::is_constructible_v<T, Args...>)
41 : value_(std::forward<Args>(args)...) {
42 proxy_to_self_[
this] = self;
46 proxy_to_self_[
this] = self;
49 proxy_to_self_[
this] = self;
51 ~Proxy() { proxy_to_self_.erase(
this); }
53 if (
auto it = proxy_to_self_.find(
this);
54 it != proxy_to_self_.end()) {
55 it->second->set_changed();
64 value_ = std::move(value);
70 proxy_to_self_[
this] = proxy_to_self_[&other];
73 value_ = other.value_;
78 value_ = std::move(other.value_);
89 operator const T &()
const {
return value_; }
91 template <
typename... Args>
94 return value_[std::forward<Args>(args)...];
96 template <
typename... Args>
98 return value_[std::forward<Args>(args)...];
100 template <
typename... Args>
103 return value_(std::forward<Args>(args)...);
105 template <
typename... Args>
107 return value_(std::forward<Args>(args)...);
109#define XCAL_PROPERTY_PROXY_OPERATOR(op) \
110 template <typename Arg> \
111 auto &operator op(const Arg & arg) { \
126#undef XCAL_PROPERTY_PROXY_OPERATOR
Proxy(MProperty *self, T &&value)
Proxy & operator=(Proxy &&other)
Proxy(MProperty *self, const T &value)
const auto & operator()(Args &&...args) const
Proxy & operator=(const Proxy &other)
auto & operator[](Args &&...args) const
auto & operator()(Args &&...args)
Proxy(const Proxy &other)=delete
auto & operator[](Args &&...args)
Proxy & operator=(T &&value)
Proxy & operator=(const T &value)
Proxy(MProperty *self, Args &&...args)
MProperty(MProperty &&)=delete
bool_t is_changed() const
virtual ~MProperty()=default
MProperty(const MProperty &)=delete
MProperty & operator=(MProperty &&)=delete
void reset_changed() const
MProperty & operator=(const MProperty &)=delete
_PositionList< xcmath::vec< float_t, 2 >, Type::PositionList > PositionList
_PositionList< xcmath::vec< float_t, 3 >, Type::ThreeDPositionList > ThreeDPositionList
#define XCAL_PROPERTY_PROXY_OPERATOR(op)