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>
13 namespace ossia
14 {
15 class graph_node;
16 class graph_interface;
17 struct execution_state;
18 
19 #if __cplusplus > 201703L
20 // TODO moveme
21 static const constexpr struct disable_init_key_t
22 {
23 } disable_init;
24 struct 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 
35 namespace net
36 {
37 class node_base;
38 }
39 }
40 namespace score
41 {
42 struct DocumentContext;
43 template <typename T, typename U, typename V>
44 class GenericComponentFactoryList;
45 }
46 namespace State
47 {
48 struct Address;
49 }
50 namespace Process
51 {
52 class ProcessModel;
53 }
54 namespace Execution
55 {
56 struct Transaction;
57 class ProcessComponent;
58 class ProcessComponentFactory;
59 class ProcessComponentFactoryList;
60 struct SetupContext;
61 namespace Settings
62 {
63 class Model;
64 }
65 
66 using time_function = smallfun::function<ossia::time_value(const TimeVal&)>;
67 using reverse_time_function = smallfun::function<TimeVal(const ossia::time_value&)>;
68 
69 using ExecutionCommandQueue = ossia::spsc_queue<ExecutionCommand, 1024>;
70 using EditionCommandQueue = moodycamel::ConcurrentQueue<ExecutionCommand>;
71 using GCCommandQueue = moodycamel::ConcurrentQueue<GCCommand>;
72 
75 struct 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