Observable Reference
Generic observable objects for C++
|
Expression nodes can form a tree to evaluate arbitrary expressions.
Expressions are formed from n-ary, user-supplied operators and operands.
Operands can be constants, observable values or other expression nodes.
The tree will propagate change notifications upwards, so any change to any value<ValueType, EqualityComparator> contained in the tree will be propagated upward, to the root node.
When evaluating the root node, only nodes that have been changed will be evaluated.
Public Member Functions | |
template<typename ValueType , typename E = std::enable_if_t< !is_value<ValueType>::value && !is_expression_node<ValueType>::value>> | |
expression_node (ValueType &&constant) | |
Create a new node from a constant value. More... | |
template<typename ValueType , typename ... Rest> | |
expression_node (value< ValueType, Rest ... > &value) | |
Create a new node from an observable value. More... | |
template<typename OpType , typename ... ValueType> | |
expression_node (OpType &&op, expression_node< ValueType > &&... nodes) | |
Create a new node from a number of nodes and an n-ary operation. More... | |
void | eval () const |
Execute the stored operation and update the node's result value. More... | |
auto | get () const |
Retrieve the expression node's result value. More... | |
template<typename Observer > | |
auto | subscribe (Observer &&callable) |
Subscribe to change notifications from this node. More... | |
expression_node ()=default | |
Expression nodes are not default-constructible. More... | |
expression_node (expression_node const &)=default | |
Expression nodes are copy-constructible. More... | |
auto | operator= (expression_node const &) -> expression_node &=default |
Expression nodes are copy-assignable. More... | |
expression_node (expression_node &&other) noexcept=default | |
Expression nodes are move-constructible. More... | |
auto | operator= (expression_node &&other) noexcept -> expression_node &=default |
Expression nodes are move-assignable. More... | |
|
inlineexplicit |
Create a new node from a constant value.
Nodes created with this constructor are called constant nodes. These nodes never notify their subscribers of value changes.
[in] | constant | A constant value that will become the node's evaluated value. |
|
inlineexplicit |
Create a new node from an observable value.
Nodes created with this constructor are called value nodes. These nodes notify their subscribers of value changes as long as the value is alive.
[in] | value | An observable value who will become the node's evaluated value. This value needs to be kept alive for at least the duration of this constructor call. |
|
inlineexplicit |
Create a new node from a number of nodes and an n-ary operation.
Nodes created with this constructor are called n-ary nodes. These nodes notify their subscribers of changes to the child nodes provided to this constructor.
[in] | op | An n-ary operation with the signature below: ResultType (ValueType const & ...) |
[in] | nodes | ... Expression nodes who's valuewWW will be the operand to the operation. |
|
default |
Expression nodes are not default-constructible.
|
default |
Expression nodes are copy-constructible.
|
defaultnoexcept |
Expression nodes are move-constructible.
|
inline |
Execute the stored operation and update the node's result value.
|
inline |
Retrieve the expression node's result value.
This call will not evaluate the node, so this value might be stale. You can call eval() to make sure that the expression has an updated result value.
|
inline |
Subscribe to change notifications from this node.
|
default |
Expression nodes are copy-assignable.
|
defaultnoexcept |
Expression nodes are move-assignable.