Loading...
Searching...
No Matches
AvndJit.hpp
1#pragma once
2#include <Process/Execution/ProcessComponent.hpp>
3#include <Process/GenericProcessFactory.hpp>
4#include <Process/Process.hpp>
5#include <Process/ProcessMetadata.hpp>
6#include <Process/Script/ScriptEditor.hpp>
7
8#include <Scenario/Commands/ScriptEditCommand.hpp>
9
10#include <Control/DefaultEffectItem.hpp>
11#include <Effect/EffectFactory.hpp>
12#include <JitCpp/EditScript.hpp>
13
14#include <ossia/dataflow/execution_state.hpp>
15#include <ossia/dataflow/graph_node.hpp>
16#include <ossia/dataflow/node_process.hpp>
17
18#include <score_plugin_jit_export.h>
19namespace AvndJit
20{
21class Model;
22}
23
24namespace Jit
25{
26struct Driver;
27}
28PROCESS_METADATA(
29 , AvndJit::Model, "193686f2-1f3b-45ce-9251-2e79ca06933b", "Jit", "Avendish",
30 Process::ProcessCategory::Script, "Script", "Avendish compilation process",
31 "ossia score", QStringList{}, {}, {},
32 QUrl("https://ossia.io/score-docs/development/plugins/plugins-with-avendish.html#avendish-documentation"),
33 Process::ProcessFlags::SupportsAll)
34namespace AvndJit
35{
36using NodeCompiler = Jit::Driver;
37using NodeFunction = ossia::graph_node*(int, double);
38using NodeFactory = std::function<NodeFunction>;
39class Model : public Process::ProcessModel
40{
41 friend class JitUI;
42 friend class JitUpdateUI;
43 SCORE_SERIALIZE_FRIENDS
44 PROCESS_METADATA_IMPL(Model)
45
46 W_OBJECT(Model)
47public:
48 Model(
49 TimeVal t, const QString& jitProgram, const Id<Process::ProcessModel>&,
50 QObject* parent);
51 ~Model() override;
52
53 Model(DataStream::Deserializer& vis, QObject* parent);
54 Model(JSONObject::Deserializer& vis, QObject* parent);
55 Model(DataStream::Deserializer&& vis, QObject* parent);
56 Model(JSONObject::Deserializer&& vis, QObject* parent);
57
58 bool validate(const QString& txt) const noexcept;
59
60 const QString& script() const { return m_text; }
61 [[nodiscard]] Process::ScriptChangeResult setScript(const QString& txt);
62 void scriptChanged(const QString& txt) W_SIGNAL(scriptChanged, txt);
63 void programChanged() W_SIGNAL(programChanged);
64
65 static constexpr bool hasExternalUI() noexcept { return true; }
66
67 QString prettyName() const noexcept override;
68
69 std::shared_ptr<NodeFactory> factory;
70
71 void errorMessage(int line, const QString& e) W_SIGNAL(errorMessage, line, e);
72 PROPERTY(QString, script READ script WRITE setScript NOTIFY scriptChanged)
73private:
74 std::shared_ptr<NodeFactory> getJitFactory();
75
76 QString effect() const noexcept override;
77 void loadPreset(const Process::Preset& preset) override;
78 Process::Preset savePreset() const noexcept override;
79
80 void init();
81 [[nodiscard]] Process::ScriptChangeResult reload();
82 QString m_text;
83 std::unique_ptr<NodeCompiler> m_compiler;
84};
85
86struct LanguageSpec
87{
88 static constexpr const char* language = "C++";
89};
90
92using LayerFactory = Process::EffectLayerFactory_T<
95}
96
97namespace Process
98{
99template <>
100QString EffectProcessFactory_T<AvndJit::Model>::customConstructionData() const noexcept;
101
102template <>
103Process::Descriptor
104EffectProcessFactory_T<AvndJit::Model>::descriptor(QString d) const noexcept;
105
106template <>
107Process::Descriptor EffectProcessFactory_T<AvndJit::Model>::descriptor(
108 const Process::ProcessModel& d) const noexcept;
109}
110
111namespace AvndJit
112{
113class Executor final
114 : public Execution::ProcessComponent_T<AvndJit::Model, ossia::node_process>
115{
116 COMPONENT_METADATA("086fbfcf-44e9-4ea6-baad-b4f76e938d69")
117
118public:
119 static constexpr bool is_unique = true;
120
121 Executor(AvndJit::Model& proc, const Execution::Context& ctx, QObject* parent);
122 ~Executor() override;
123};
125}
126
127namespace AvndJit
128{
129class EditAvndScript : public Scenario::EditScript<Model, Model::p_script>
130{
131 SCORE_COMMAND_DECL(Jit::CommandFactoryName(), EditAvndScript, "Edit a C++ program")
132public:
133 using Scenario::EditScript<Model, Model::p_script>::EditScript;
134};
135
136}
137
138namespace score
139{
140template <>
141struct StaticPropertyCommand<AvndJit::Model::p_script> : AvndJit::EditAvndScript
142{
143 using AvndJit::EditAvndScript::EditAvndScript;
144};
145}
Definition AvndJit.hpp:130
Definition AvndJit.hpp:115
Definition DataStreamVisitor.hpp:202
Definition Process/Execution/ProcessComponent.hpp:119
Definition JSONVisitor.hpp:423
Definition DefaultEffectItem.hpp:26
Definition EffectFactory.hpp:67
Definition EffectFactory.hpp:14
The Process class.
Definition score-lib-process/Process/Process.hpp:61
Definition ScriptEditor.hpp:42
Definition ScriptEditCommand.hpp:18
The id_base_t class.
Definition Identifier.hpp:57
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Base toolkit upon which the software is built.
Definition Application.cpp:90
STL namespace.
Definition ExecutionContext.hpp:76
Definition Process/Execution/ProcessComponent.hpp:89
Definition Driver.hpp:11
Definition ScriptProcess.hpp:14
Definition TimeValue.hpp:21
Definition PropertyCommand.hpp:112