OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
expression_generic.hpp
1#pragma once
2#include <ossia/detail/config.hpp>
3
5
6#include <memory>
7
8namespace ossia::expressions
9{
12struct OSSIA_EXPORT expression_generic_base
13{
15 virtual void update() = 0;
16 [[nodiscard]] virtual bool evaluate() const = 0;
17 virtual void on_first_callback_added(expression_generic&) = 0;
18 virtual void on_removing_last_callback(expression_generic&) = 0;
19};
20
21class OSSIA_EXPORT expression_generic final : public expression_callback_container
22{
23public:
24 expression_generic(std::unique_ptr<expression_generic_base> ptr)
25 : expr{std::move(ptr)}
26 {
27 }
28 expression_generic(expression_generic_base* ptr)
29 : expr{ptr}
30 {
31 }
32 ~expression_generic() override;
33 std::unique_ptr<expression_generic_base> expr;
34
35 void update() const { expr->update(); }
36 bool evaluate() const { return expr->evaluate(); }
37
38 void reset() const { }
39
40private:
41 void on_first_callback_added() override { expr->on_first_callback_added(*this); }
42 void on_removing_last_callback() override { expr->on_removing_last_callback(*this); }
43};
44}
Definition expression_generic.hpp:13