summaryrefslogtreecommitdiffstats
path: root/src/server/events/CreateGraph.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events/CreateGraph.cpp')
-rw-r--r--src/server/events/CreateGraph.cpp148
1 files changed, 87 insertions, 61 deletions
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 3e847bdd..5df28afa 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -14,40 +14,53 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/CreateGraph.hpp"
+#include "CreateGraph.hpp"
+#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
+#include "CompiledGraph.hpp"
+#include "CreatePort.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "PreProcessContext.hpp"
-#include "events/CreatePort.hpp"
-
-#include "ingen/Forge.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-
+#include "types.hpp"
+
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+
+#include <boost/intrusive/slist.hpp>
+
+#include <map>
+#include <memory>
+#include <string>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
-
-CreateGraph::CreateGraph(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- const Properties& properties)
- : Event(engine, client, id, timestamp)
- , _path(path)
- , _properties(properties)
- , _graph(nullptr)
- , _parent(nullptr)
+namespace ingen::server::events {
+
+CreateGraph::CreateGraph(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ raul::Path path,
+ Properties properties)
+ : Event(engine, client, id, timestamp)
+ , _path(std::move(path))
+ , _properties(std::move(properties))
{}
+CreateGraph::~CreateGraph() = default;
+
void
CreateGraph::build_child_events()
{
@@ -67,30 +80,40 @@ CreateGraph::build_child_events()
in_properties.put(uris.lv2_index, uris.forge.make(0));
in_properties.put(uris.lv2_name, uris.forge.alloc("Control"));
in_properties.put(uris.rdf_type, uris.lv2_InputPort);
- in_properties.put(uris.ingen_canvasX, uris.forge.make(32.0f),
+ in_properties.put(uris.ingen_canvasX,
+ uris.forge.make(32.0f),
Resource::Graph::EXTERNAL);
- in_properties.put(uris.ingen_canvasY, uris.forge.make(32.0f),
+ in_properties.put(uris.ingen_canvasY,
+ uris.forge.make(32.0f),
Resource::Graph::EXTERNAL);
- _child_events.push_back(
- make_unique<events::CreatePort>(_engine, _request_client, -1, _time,
- _path.child(Raul::Symbol("control")),
- in_properties));
+ _child_events.push_back(std::make_unique<events::CreatePort>(
+ _engine,
+ _request_client,
+ -1,
+ _time,
+ _path.child(raul::Symbol("control")),
+ in_properties));
// Add notify port (message respond)
Properties out_properties(control_properties);
out_properties.put(uris.lv2_index, uris.forge.make(1));
out_properties.put(uris.lv2_name, uris.forge.alloc("Notify"));
out_properties.put(uris.rdf_type, uris.lv2_OutputPort);
- out_properties.put(uris.ingen_canvasX, uris.forge.make(128.0f),
+ out_properties.put(uris.ingen_canvasX,
+ uris.forge.make(128.0f),
Resource::Graph::EXTERNAL);
- out_properties.put(uris.ingen_canvasY, uris.forge.make(32.0f),
+ out_properties.put(uris.ingen_canvasY,
+ uris.forge.make(32.0f),
Resource::Graph::EXTERNAL);
_child_events.push_back(
- make_unique<events::CreatePort>(_engine, _request_client, -1, _time,
- _path.child(Raul::Symbol("notify")),
- out_properties));
+ std::make_unique<events::CreatePort>(_engine,
+ _request_client,
+ -1,
+ _time,
+ _path.child(raul::Symbol("notify")),
+ out_properties));
}
bool
@@ -101,7 +124,7 @@ CreateGraph::pre_process(PreProcessContext& ctx)
}
if (!_path.is_root()) {
- const Raul::Path up(_path.parent());
+ const raul::Path up(_path.parent());
if (!(_parent = dynamic_cast<GraphImpl*>(_engine.store()->get(up)))) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, up);
}
@@ -109,11 +132,9 @@ CreateGraph::pre_process(PreProcessContext& ctx)
const ingen::URIs& uris = _engine.world().uris();
- using iterator = Properties::const_iterator;
-
- uint32_t ext_poly = 1;
- uint32_t int_poly = 1;
- iterator p = _properties.find(uris.ingen_polyphony);
+ uint32_t ext_poly = 1;
+ uint32_t int_poly = 1;
+ const auto p = _properties.find(uris.ingen_polyphony);
if (p != _properties.end() && p->second.type() == uris.forge.Int) {
int_poly = p->second.get<int32_t>();
}
@@ -126,33 +147,39 @@ CreateGraph::pre_process(PreProcessContext& ctx)
ext_poly = int_poly;
}
- const Raul::Symbol symbol(_path.is_root() ? "graph" : _path.symbol());
+ const raul::Symbol symbol(_path.is_root() ? "graph" : _path.symbol());
// Get graph prototype
- iterator t = _properties.find(uris.lv2_prototype);
+ auto t = _properties.find(uris.lv2_prototype);
if (t == _properties.end()) {
t = _properties.find(uris.lv2_prototype);
}
- if (t != _properties.end() &&
- uris.forge.is_uri(t->second) &&
+ if (t != _properties.end() && uris.forge.is_uri(t->second) &&
URI::is_valid(uris.forge.str(t->second, false)) &&
uri_is_path(URI(uris.forge.str(t->second, false)))) {
// Create a duplicate of an existing graph
const URI prototype(uris.forge.str(t->second, false));
GraphImpl* ancestor = dynamic_cast<GraphImpl*>(
- _engine.store()->get(uri_to_path(prototype)));
+ _engine.store()->get(uri_to_path(prototype)));
if (!ancestor) {
- return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(
- ancestor->duplicate(_engine, symbol, _parent)))) {
+ return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND,
+ prototype);
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(
+ ancestor->duplicate(_engine, symbol, _parent)))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
} else {
// Create a new graph
- _graph = new GraphImpl(_engine, symbol, ext_poly, _parent,
- _engine.sample_rate(), int_poly);
- _graph->add_property(uris.rdf_type, uris.ingen_Graph.urid);
+ _graph = new GraphImpl(_engine,
+ symbol,
+ ext_poly,
+ _parent,
+ _engine.sample_rate(),
+ int_poly);
+ _graph->add_property(uris.rdf_type, uris.ingen_Graph.urid_atom());
_graph->add_property(uris.rdf_type,
Property(uris.ingen_Block,
Resource::Graph::EXTERNAL));
@@ -166,7 +193,7 @@ CreateGraph::pre_process(PreProcessContext& ctx)
if (_parent->enabled()) {
_graph->enable();
}
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent);
+ _compiled_graph = ctx.maybe_compile(*_parent);
}
_graph->activate(*_engine.buffer_factory());
@@ -188,12 +215,13 @@ CreateGraph::pre_process(PreProcessContext& ctx)
}
void
-CreateGraph::execute(RunContext& context)
+CreateGraph::execute(RunContext& ctx)
{
if (_graph) {
if (_parent) {
if (_compiled_graph) {
- _parent->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph =
+ _parent->swap_compiled_graph(std::move(_compiled_graph));
}
} else {
_engine.set_root_graph(_graph);
@@ -201,7 +229,7 @@ CreateGraph::execute(RunContext& context)
}
for (const auto& ev : _child_events) {
- ev->execute(context);
+ ev->execute(ctx);
}
}
}
@@ -209,7 +237,7 @@ CreateGraph::execute(RunContext& context)
void
CreateGraph::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_update.send(*_engine.broadcaster());
}
@@ -227,6 +255,4 @@ CreateGraph::undo(Interface& target)
target.del(_graph->uri());
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events