10 static_assert(std::is_arithmetic<T>::value);
13 using property_changed_delegate = MulticastDelegate<T, T>;
15 property() : m_value(T()), m_min(0), m_max(1) {}
16 property(T value) : m_value(value), m_min(value), m_max(value + 1) {}
17 property(T value, T min, T max) : m_value(value), m_min(min), m_max(max)
19 BOOST_ASSERT(value >= min);
20 BOOST_ASSERT(value <= max);
21 BOOST_ASSERT(min < max);
25 : m_value(other.m_value), m_min(other.m_min), m_max(other.m_max), m_delegate(other.m_delegate)
32 property& operator=(
const property& other)
36 m_value = other.m_value;
39 m_delegate = other.m_delegate;
45 property& operator=(
property&& other) =
default;
47 auto set(T value) ->
bool
51 if (value >= m_min && value <= m_max)
53 m_delegate.Broadcast(m_value, value);
61 [[nodiscard]]
auto get()
const -> T {
return m_value; }
62 [[nodiscard]]
auto get_min()
const -> T {
return m_min; }
63 [[nodiscard]]
auto get_max()
const -> T {
return m_max; }
64 [[nodiscard]]
auto get_min_max_pair()
const -> std::pair<T, T> {
return std::pair<T, T>(m_min, m_max); }
65 [[nodiscard]]
auto get_delegate() -> property_changed_delegate& {
return m_delegate; }
71 property_changed_delegate m_delegate;