18#ifndef CORE_PROPERTY_H_
19#define CORE_PROPERTY_H_
100 inline operator const T&()
const
121 return lhs.
get() == rhs;
132 return lhs.
get() == rhs.
get();
140 inline virtual void set(
const T& new_value)
142 if (value != new_value)
149 signal_changed(value);
157 inline virtual const T&
get()
const
171 return signal_changed;
183 inline virtual bool update(
const std::function<
bool(T& t)>& update_functor)
187 signal_changed(value);
200 this->setter = setter;
209 this->getter = getter;
214 rhs.connections.emplace(
219 std::placeholders::_1)));
234 std::set<ScopedConnection> connections;
A very simple, templated class that allows for uniform declaration of get-able/set-able/observable me...
Property(const Property< T > &rhs)
Copy c'tor, only copies the contained value, not the changed signal and its connections.
Property & operator=(const Property< T > &rhs)
Assignment operator, only assigns to the contained value, not the changed signal and its connections.
friend const Property< T > & operator|(const Property< T > &lhs, Property< T > &rhs)
void install(const Getter &getter)
install takes the provided functor and installs it for dispatching all get operations.
Property & operator=(const T &rhs)
Assignment operator, only assigns to the contained value.
virtual T & mutable_get() const
virtual ~Property()=default
void install(const Setter &setter)
install takes the provided functor and installs it for dispatching all set operations.
virtual void set(const T &new_value)
Set the contained value to the provided value. Notify observers of the change.
Property(const T &t=T{})
Property creates a new instance of property and initializes the contained value.
friend bool operator==(const Property< T > &lhs, const Property< T > &rhs)
operator == checks if the value of two properties are equal.
const Signal< T > & changed() const
Access to the changed signal, allows observers to subscribe to change notifications.
const T * operator->() const
Provides access to a pointer to the contained value.
virtual const T & get() const
Access the value contained within this property.
T ValueType
ValueType refers to the type of the contained value.
friend bool operator==(const Property< T > &lhs, const T &rhs)
operator == checks if the value of a property and a raw value are equal.
std::function< ValueType()> Getter
Getter refers to the function type for dispatching get operations to.
virtual bool update(const std::function< bool(T &t)> &update_functor)
Provides in-place update facilities.
std::function< void(const ValueType &) Setter)
Setter refers to the function type for dispatching set operations to.
A signal class that observers can subscribe to.
Connection connect(const Slot &slot) const
Connects the provided slot to this signal instance.