OSSIA
Open Scenario System for Interactive Application
expression.hpp File Reference

Detailed Description

This file defines the expression API. An expression is a logical construct such as :

(a:/b == 1) && (c:/d <= 2.)

pulse(a:/b)

!(c:/d == e:/f/g)

etc...

The basic logical operators are expression_not (!) and expression_composition (and, or, xor).

expression_atom is used for numeric comparison : <=, ==, >, etc.

expression_bool is a simple boolean value.

expression_pulse is an expression that will become true if a particular message happened since the last time it has been updated.

The expressions are organised as a tree. The expression results are passed by cascading callbacks to allow notification when an expression is listened to.

See also
expression_bool expression_atom expression_pulse expression_composition expression_not expression_generic

Go to the source code of this file.

Namespaces

 ossia
 

Functions

bool ossia::expressions::evaluate (const expression_base &e)
 evaluate More...
 
bool ossia::expressions::evaluate (const expression_ptr &e)
 
void ossia::expressions::update (const expression_base &e)
 update More...
 
void ossia::expressions::update (const expression_ptr &e)
 
void ossia::expressions::reset (expression_base &e)
 reset More...
 
void ossia::expressions::reset (const expression_ptr &e)
 
bool ossia::expressions::operator== (const expression_base &lhs, const expression_base &rhs)
 operator==(const expression_base& lhs, const expression_base& rhs) Compares two expressions. More...
 
bool ossia::expressions::operator!= (const expression_base &lhs, const expression_base &rhs)
 
expression_callback_iterator ossia::expressions::add_callback (expression_base &, expression_result_callback)
 add_callback Add a callback to an expression.
 
void ossia::expressions::remove_callback (expression_base &, expression_callback_iterator)
 remove_callback Remove a callback to an expression.
 
std::size_t ossia::expressions::callback_count (expression_base &)
 callback_count More...
 
const expression_base & ossia::expressions::expression_true ()
 expression_true Convenience constant expression always evaluating to true.
 
const expression_base & ossia::expressions::expression_false ()
 false Convenience constant expression always evaluating to false.
 
expression_ptr ossia::expressions::make_expression_true ()
 make_expression_true More...
 
bool ossia::expressions::is_expression_true (ossia::expression &e) noexcept
 
expression_ptr ossia::expressions::make_expression_false ()
 make_expression_false More...
 
template<typename... Args>
expression_ptr ossia::expressions::make_expression_atom (Args &&... args)
 make_expression_atom More...
 
expression_ptr ossia::expressions::make_expression_atom (const expression_atom::val_t &lhs, comparator c, const expression_atom::val_t &rhs)
 
expression_ptr ossia::expressions::make_expression_atom (expression_atom::val_t &&lhs, comparator c, expression_atom::val_t &&rhs)
 
template<typename... Args>
expression_ptr ossia::expressions::make_expression_bool (Args &&... args)
 make_expression_bool More...
 
template<typename... Args>
expression_ptr ossia::expressions::make_expression_composition (Args &&... args)
 make_expression_composition More...
 
template<typename... Args>
expression_ptr ossia::expressions::make_expression_not (Args &&... args)
 make_expression_not More...
 
template<typename... Args>
expression_ptr ossia::expressions::make_expression_pulse (Args &&... args)
 make_expression_pulse More...
 
template<typename T , typename... Args>
expression_ptr ossia::expressions::make_expression_generic (Args &&... args)
 

Function Documentation

◆ evaluate()

OSSIA_EXPORT bool ossia::expressions::evaluate ( const expression_base &  e)

evaluate

Parameters
eAn expression
Returns
The truth value of the expression

◆ update()

OSSIA_EXPORT void ossia::expressions::update ( const expression_base &  e)

update

Parameters
eAn expression

Recursively asks an expression to query the addresses that it refers, in order to check if the value has changed.

◆ reset()

OSSIA_EXPORT void ossia::expressions::reset ( expression_base &  e)

reset

Parameters
eAn expression

◆ operator==()

OSSIA_EXPORT bool ossia::expressions::operator== ( const expression_base &  lhs,
const expression_base &  rhs 
)

operator==(const expression_base& lhs, const expression_base& rhs) Compares two expressions.

Two expressions are comparable if they have all the same terms.

◆ callback_count()

OSSIA_EXPORT std::size_t ossia::expressions::callback_count ( expression_base &  )

callback_count

Returns
Number of callbacks in an expression.

◆ make_expression_true()

expression_ptr ossia::expressions::make_expression_true ( )
inline

make_expression_true

The following functions are factories used to create expressions.

Returns
A "true" expression_bool.
See also
expression_bool

◆ make_expression_false()

expression_ptr ossia::expressions::make_expression_false ( )
inline

make_expression_false

Returns
A "false" expression_bool.
See also
expression_bool

◆ make_expression_atom()

template<typename... Args>
expression_ptr ossia::expressions::make_expression_atom ( Args &&...  args)

make_expression_atom

Returns
An expression_atom
See also
expression_atom

◆ make_expression_bool()

template<typename... Args>
expression_ptr ossia::expressions::make_expression_bool ( Args &&...  args)

make_expression_bool

Returns
An expression_bool
See also
expression_bool

◆ make_expression_composition()

template<typename... Args>
expression_ptr ossia::expressions::make_expression_composition ( Args &&...  args)

make_expression_composition

Returns
An expression_composition
See also
expression_composition

◆ make_expression_not()

template<typename... Args>
expression_ptr ossia::expressions::make_expression_not ( Args &&...  args)

make_expression_not

Returns
An expression_not
See also
expression_not

◆ make_expression_pulse()

template<typename... Args>
expression_ptr ossia::expressions::make_expression_pulse ( Args &&...  args)

make_expression_pulse

Returns
An expression_pulse
See also
expression_pulse