OSSIA
Open Scenario System for Interactive Application
editor/state/state.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ossia/detail/config.hpp>
4 
7 
8 #include <memory>
12 namespace ossia
13 {
24 class OSSIA_EXPORT state
25 {
26 public:
27  OSSIA_EXPORT friend bool operator==(const state& lhs, const state& rhs);
28  OSSIA_EXPORT friend bool operator!=(const state& lhs, const state& rhs);
29 
30  auto begin() { return m_children.begin(); }
31  auto end() { return m_children.end(); }
32  auto begin() const { return m_children.begin(); }
33  auto end() const { return m_children.end(); }
34  auto cbegin() const { return m_children.cbegin(); }
35  auto cend() const { return m_children.cend(); }
36 
37  auto& children() const { return m_children; }
38 
39  std::size_t size() const;
40  bool empty() const;
41 
42  void launch();
43 
44  void add(const state_element& e);
45  void add(state_element&& e);
46 
47  template <class Optional_T>
48  auto add(Optional_T&& opt)
49  -> decltype(std::declval<typename std::remove_reference_t<Optional_T>::value_type>(), void())
50  {
51  if(opt)
52  add(*std::forward<Optional_T>(opt));
53  }
54 
55  void remove(const state_element& e);
56  void remove(std::vector<state_element>::iterator e);
57  void remove(std::vector<state_element>::const_iterator e);
58 
59  void reserve(std::size_t);
60  void clear();
61 
62 private:
63  std::vector<state_element> m_children;
64 };
65 
66 inline auto begin(state& s)
67 {
68  return s.begin();
69 }
70 inline auto begin(const state& s)
71 {
72  return s.begin();
73 }
74 inline auto end(state& s)
75 {
76  return s.end();
77 }
78 inline auto end(const state& s)
79 {
80  return s.end();
81 }
82 
87 OSSIA_EXPORT void flatten_and_filter(state&, const state_element& element);
88 OSSIA_EXPORT void flatten_and_filter(state&, state_element&& element);
89 
91 OSSIA_EXPORT void merge_flatten_and_filter(state&, const state_element& element);
92 OSSIA_EXPORT void merge_flatten_and_filter(state&, state_element&& element);
93 
94 inline ossia::state_element& get_state_element(ossia::state_element* iterator)
95 {
96  return *iterator;
97 }
98 }
The state class.
Definition: editor/state/state.hpp:25
Definition: git_info.h:7
void launch(state_element &e)
launch Launch a state_element
Definition: state_element.cpp:18
void flatten_and_filter(ossia::state &state, const state_element &element)
append each message of the state to the current state in order to eliminate address redundancy
Definition: editor/state/state.cpp:77
ossia::nullable_variant< message, state, piecewise_message, piecewise_vec_message< 2 >, piecewise_vec_message< 3 >, piecewise_vec_message< 4 > > state_element
Definition: state_element_fwd.hpp:28
void merge_flatten_and_filter(ossia::state &state, const state_element &element)
These will also merge single addresses.
Definition: editor/state/state.cpp:87