summaryrefslogtreecommitdiffstats
path: root/src/server/CompiledGraph.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/CompiledGraph.cpp')
-rw-r--r--src/server/CompiledGraph.cpp60
1 files changed, 28 insertions, 32 deletions
diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp
index e644d982..89fc8843 100644
--- a/src/server/CompiledGraph.cpp
+++ b/src/server/CompiledGraph.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2015-2017 David Robillard <http://drobilla.net/>
+ Copyright 2015-2024 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -21,13 +21,12 @@
#include "GraphImpl.hpp"
#include "ThreadManager.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/ColorContext.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/World.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/ColorContext.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/World.hpp>
+#include <raul/Path.hpp>
#include <boost/intrusive/slist.hpp>
@@ -36,14 +35,16 @@
#include <cstdint>
#include <cstdio>
#include <exception>
+#include <functional>
#include <limits>
+#include <memory>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** Graph contains ambiguous feedback with no delay nodes. */
-class FeedbackException : public std::exception {
+class FeedbackException : public std::exception
+{
public:
explicit FeedbackException(const BlockImpl* n)
: node(n)
@@ -60,26 +61,24 @@ public:
static bool
has_provider_with_many_dependants(const BlockImpl* n)
{
- for (const auto* p : n->providers()) {
- if (p->dependants().size() > 1) {
- return true;
- }
- }
-
- return false;
+ return std::any_of(n->providers().begin(),
+ n->providers().end(),
+ [](const auto* p) {
+ return p->dependants().size() > 1;
+ });
}
CompiledGraph::CompiledGraph(GraphImpl* graph)
- : _master(std::unique_ptr<Task>(new Task(Task::Mode::SEQUENTIAL)))
+ : _master{std::make_unique<Task>(Task::Mode::SEQUENTIAL)}
{
compile_graph(graph);
}
-raul::managed_ptr<CompiledGraph>
-CompiledGraph::compile(raul::Maid& maid, GraphImpl& graph)
+std::unique_ptr<CompiledGraph>
+CompiledGraph::compile(GraphImpl& graph)
{
try {
- return maid.make_managed<CompiledGraph>(&graph);
+ return std::unique_ptr<CompiledGraph>(new CompiledGraph(&graph));
} catch (const FeedbackException& e) {
Log& log = graph.engine().log();
if (e.node && e.root) {
@@ -95,13 +94,11 @@ CompiledGraph::compile(raul::Maid& maid, GraphImpl& graph)
static size_t
num_unvisited_dependants(const BlockImpl* block)
{
- size_t count = 0;
- for (const BlockImpl* b : block->dependants()) {
- if (b->get_mark() == BlockImpl::Mark::UNVISITED) {
- ++count;
- }
- }
- return count;
+ return std::count_if(block->dependants().begin(),
+ block->dependants().end(),
+ [](const auto* b) {
+ return b->get_mark() == BlockImpl::Mark::UNVISITED;
+ });
}
static size_t
@@ -160,7 +157,7 @@ CompiledGraph::compile_graph(GraphImpl* graph)
_master = Task::simplify(std::move(_master));
if (graph->engine().world().conf().option("trace").get<int32_t>()) {
- ColorContext ctx(stderr, ColorContext::Color::YELLOW);
+ const ColorContext ctx{stderr, ColorContext::Color::YELLOW};
dump(graph->path());
}
}
@@ -285,5 +282,4 @@ CompiledGraph::dump(const std::string& name) const
sink(")\n");
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server