Loading...
Searching...
No Matches
ExecutionContext.hpp
1#pragma once
2#include <Process/ExecutionCommand.hpp>
3#include <Process/TimeValue.hpp>
4
5#include <ossia/detail/lockfree_queue.hpp>
6#include <ossia/editor/scenario/time_value.hpp>
7
8#include <score_lib_process_export.h>
9
10#include <atomic>
11#include <functional>
12#include <memory>
13namespace ossia
14{
15class graph_node;
16class graph_interface;
17struct execution_state;
18
19#if __cplusplus > 201703L
20// TODO moveme
21static const constexpr struct disable_init_key_t
22{
23} disable_init;
24struct disable_init_t
25{
26 disable_init_t(disable_init_key_t) { }
27 disable_init_t() = delete;
28 disable_init_t(const disable_init_t&) = delete;
29 disable_init_t(disable_init_t&&) = delete;
30 disable_init_t& operator=(const disable_init_t&) = delete;
31 disable_init_t& operator=(disable_init_t&&) = delete;
32};
33#endif
34
35namespace net
36{
37class node_base;
38}
39}
40namespace score
41{
42struct DocumentContext;
43template <typename T, typename U, typename V>
44class GenericComponentFactoryList;
45}
46namespace State
47{
48struct Address;
49}
50namespace Process
51{
52class ProcessModel;
53}
54namespace Execution
55{
56struct Transaction;
57class ProcessComponent;
58class ProcessComponentFactory;
59class ProcessComponentFactoryList;
60struct SetupContext;
61namespace Settings
62{
63class Model;
64}
65
66using time_function = smallfun::function<ossia::time_value(const TimeVal&)>;
67using reverse_time_function = smallfun::function<TimeVal(const ossia::time_value&)>;
68
69using ExecutionCommandQueue = ossia::spsc_queue<ExecutionCommand, 1024>;
70using EditionCommandQueue = moodycamel::ConcurrentQueue<ExecutionCommand>;
71using GCCommandQueue = moodycamel::ConcurrentQueue<GCCommand>;
72
75struct SCORE_LIB_PROCESS_EXPORT Context
76{
77 std::weak_ptr<void> alias;
78
79 const score::DocumentContext& doc;
80 const std::atomic_bool& created;
81
88 Execution::reverse_time_function reverseTime;
89
91 ExecutionCommandQueue& executionQueue;
92 EditionCommandQueue& editionQueue;
93 GCCommandQueue& gcQueue;
94 SetupContext& setup;
95
96 const std::shared_ptr<ossia::graph_interface>& execGraph;
97 const std::shared_ptr<ossia::execution_state>& execState;
98
99 auto& context() const { return *this; }
100
101#if !defined(_MSC_VER)
102#if __cplusplus > 201703L
103#pragma clang diagnostic push
104#pragma clang diagnostic ignored "-Wunknown-attributes"
105 [[no_unique_address]] ossia::disable_init_t disable_copy;
106#pragma clang diagnostic pop
107#else
108 Context() = delete;
109 Context(const Context&) = delete;
110 Context& operator=(const Context&) = delete;
111 Context(Context&&) = delete;
112 Context& operator=(Context&&) = delete;
113#endif
114#endif
115};
116
117}
118
119#define in_exec system().executionQueue.enqueue
120#define in_edit system().editionQueue.enqueue
Components used for the execution of a score.
Definition ProcessComponent.cpp:12
smallfun::function< ossia::time_value(const TimeVal &)> time_function
Sets-up and manages the main execution clock.
Definition ExecutionContext.hpp:66
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:33
Base toolkit upon which the software is built.
Definition Application.cpp:90
Definition ExecutionContext.hpp:76
ExecutionCommandQueue & executionQueue
Definition ExecutionContext.hpp:91
Execution::time_function time
Definition ExecutionContext.hpp:87
Definition ExecutionSetup.hpp:38
Definition TimeValue.hpp:21
Definition DocumentContext.hpp:18