OSSIA
Open Scenario System for Interactive Application
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
time_process.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <ossia/detail/config.hpp>
4
5#include <ossia/dataflow/token_request.hpp>
7
8#include <memory>
9#include <string>
10
14namespace ossia
15{
16class graph_node;
17class time_interval;
23class OSSIA_EXPORT time_process
24{
25public:
26#if defined(OSSIA_SCENARIO_DATAFLOW)
27 std::shared_ptr<ossia::graph_node> node;
28#endif
30 virtual ~time_process();
31
37 void offset(ossia::time_value date);
38
39 void transport(ossia::time_value date);
40
45 virtual void state(const ossia::token_request&) = 0;
46
53 virtual void start();
54
61 virtual void stop();
62
69 virtual void pause();
70
77 virtual void resume();
78
85 void mute(bool m);
86
90 [[nodiscard]] bool unmuted() const;
91
97 void enable(bool m);
98
102 [[nodiscard]] bool enabled() const;
103
107 void set_loops(bool b);
108
112 void set_start_offset(time_value v);
113
119 void set_loop_duration(time_value v);
120
121protected:
123 virtual void mute_impl(bool);
124 virtual void offset_impl(ossia::time_value date) = 0;
125
126 virtual void transport_impl(ossia::time_value date) = 0;
127
128 time_value m_loop_duration{};
129 time_value m_start_offset{};
130 bool m_loops = false; // TODO bitfields ?
131 bool m_unmuted = true;
132 bool m_enabled = true;
133};
134
135template <typename T>
136class looping_process : public time_process
137{
138public:
139 using time_process::time_process;
140 void state(const ossia::token_request& tok) override
141 {
142 if(!this->m_loops)
143 {
144 if(this->m_start_offset == 0_tv)
145 static_cast<T*>(this)->state_impl(tok);
146 else
147 static_cast<T*>(this)->state_impl(tok.add_offset(this->m_start_offset));
148 }
149 else
150 {
151 tok.loop(
152 this->m_start_offset, this->m_loop_duration,
153 [this](const token_request& tr) { static_cast<T*>(this)->state_impl(tr); },
154 [this](const time_value& t) { static_cast<T*>(this)->transport_impl(t); });
155 }
156 }
157};
158
159enum class sync_status
160{
161 NOT_READY,
162 RETRY,
163 DONE
164};
165
166}
The time_process class.
Definition time_process.hpp:24
virtual void state(const ossia::token_request &)=0
get a #StateElement from the process depending on its parent #time_interval date
virtual ~time_process()
destructor
Definition git_info.h:7
The time_value class.
Definition ossia/editor/scenario/time_value.hpp:30