summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/.clang-tidy9
-rw-r--r--src/AtomForge.cpp130
-rw-r--r--src/AtomReader.cpp64
-rw-r--r--src/AtomWriter.cpp44
-rw-r--r--src/ClashAvoider.cpp37
-rw-r--r--src/ColorContext.cpp3
-rw-r--r--src/Configuration.cpp77
-rw-r--r--src/FilePath.cpp247
-rw-r--r--src/Forge.cpp13
-rw-r--r--src/LV2Features.cpp24
-rw-r--r--src/Library.cpp3
-rw-r--r--src/Log.cpp66
-rw-r--r--src/Parser.cpp501
-rw-r--r--src/Resource.cpp26
-rw-r--r--src/Serialiser.cpp81
-rw-r--r--src/SocketReader.cpp33
-rw-r--r--src/SocketWriter.cpp16
-rw-r--r--src/Store.cpp8
-rw-r--r--src/StreamWriter.cpp9
-rw-r--r--src/TurtleWriter.cpp14
-rw-r--r--src/URI.cpp65
-rw-r--r--src/URIMap.cpp18
-rw-r--r--src/URIs.cpp38
-rw-r--r--src/World.cpp48
-rw-r--r--src/client/BlockModel.cpp72
-rw-r--r--src/client/ClientStore.cpp77
-rw-r--r--src/client/GraphModel.cpp42
-rw-r--r--src/client/ObjectModel.cpp25
-rw-r--r--src/client/PluginModel.cpp44
-rw-r--r--src/client/PluginUI.cpp54
-rw-r--r--src/client/PortModel.cpp50
-rw-r--r--src/client/ingen_client.cpp11
-rw-r--r--src/gui/.clang-tidy4
-rw-r--r--src/gui/App.cpp75
-rw-r--r--src/gui/App.hpp24
-rw-r--r--src/gui/Arc.cpp25
-rw-r--r--src/gui/Arc.hpp2
-rw-r--r--src/gui/BreadCrumbs.cpp69
-rw-r--r--src/gui/BreadCrumbs.hpp21
-rw-r--r--src/gui/ConnectWindow.cpp88
-rw-r--r--src/gui/ConnectWindow.hpp8
-rw-r--r--src/gui/GraphBox.cpp91
-rw-r--r--src/gui/GraphBox.hpp2
-rw-r--r--src/gui/GraphCanvas.cpp117
-rw-r--r--src/gui/GraphCanvas.hpp12
-rw-r--r--src/gui/GraphPortModule.cpp30
-rw-r--r--src/gui/GraphPortModule.hpp6
-rw-r--r--src/gui/GraphTreeWindow.cpp36
-rw-r--r--src/gui/GraphTreeWindow.hpp5
-rw-r--r--src/gui/GraphView.cpp22
-rw-r--r--src/gui/GraphView.hpp2
-rw-r--r--src/gui/GraphWindow.cpp7
-rw-r--r--src/gui/GraphWindow.hpp3
-rw-r--r--src/gui/LoadGraphWindow.cpp39
-rw-r--r--src/gui/LoadGraphWindow.hpp4
-rw-r--r--src/gui/LoadPluginWindow.cpp38
-rw-r--r--src/gui/LoadPluginWindow.hpp7
-rw-r--r--src/gui/MessagesWindow.cpp23
-rw-r--r--src/gui/MessagesWindow.hpp11
-rw-r--r--src/gui/NewSubgraphWindow.cpp35
-rw-r--r--src/gui/NewSubgraphWindow.hpp4
-rw-r--r--src/gui/NodeMenu.cpp58
-rw-r--r--src/gui/NodeMenu.hpp8
-rw-r--r--src/gui/NodeModule.cpp47
-rw-r--r--src/gui/NodeModule.hpp10
-rw-r--r--src/gui/ObjectMenu.cpp22
-rw-r--r--src/gui/ObjectMenu.hpp2
-rw-r--r--src/gui/PluginMenu.cpp28
-rw-r--r--src/gui/PluginMenu.hpp4
-rw-r--r--src/gui/Port.cpp53
-rw-r--r--src/gui/Port.hpp2
-rw-r--r--src/gui/PortMenu.cpp29
-rw-r--r--src/gui/PortMenu.hpp3
-rw-r--r--src/gui/PropertiesWindow.cpp56
-rw-r--r--src/gui/PropertiesWindow.hpp7
-rw-r--r--src/gui/RDFS.cpp31
-rw-r--r--src/gui/RDFS.hpp11
-rw-r--r--src/gui/RenameWindow.cpp20
-rw-r--r--src/gui/RenameWindow.hpp2
-rw-r--r--src/gui/Style.cpp10
-rw-r--r--src/gui/SubgraphModule.cpp15
-rw-r--r--src/gui/ThreadedLoader.cpp61
-rw-r--r--src/gui/ThreadedLoader.hpp31
-rw-r--r--src/gui/URIEntry.cpp14
-rw-r--r--src/gui/URIEntry.hpp10
-rw-r--r--src/gui/WidgetFactory.cpp9
-rw-r--r--src/gui/WidgetFactory.hpp12
-rw-r--r--src/gui/Window.hpp7
-rw-r--r--src/gui/WindowFactory.cpp28
-rw-r--r--src/gui/WindowFactory.hpp5
-rw-r--r--src/gui/ingen_gui.cpp25
-rw-r--r--src/gui/ingen_gui_lv2.cpp50
-rw-r--r--src/gui/meson.build96
-rw-r--r--src/gui/rgba.hpp8
-rw-r--r--src/ingen/ingen.cpp44
-rw-r--r--src/meson.build14
-rw-r--r--src/runtime_paths.cpp13
-rw-r--r--src/server/.clang-tidy3
-rw-r--r--src/server/ArcImpl.cpp48
-rw-r--r--src/server/ArcImpl.hpp16
-rw-r--r--src/server/BlockFactory.cpp50
-rw-r--r--src/server/BlockFactory.hpp4
-rw-r--r--src/server/BlockImpl.cpp28
-rw-r--r--src/server/BlockImpl.hpp31
-rw-r--r--src/server/Broadcaster.cpp16
-rw-r--r--src/server/Broadcaster.hpp16
-rw-r--r--src/server/Buffer.cpp41
-rw-r--r--src/server/Buffer.hpp9
-rw-r--r--src/server/BufferFactory.cpp18
-rw-r--r--src/server/BufferFactory.hpp10
-rw-r--r--src/server/BufferRef.hpp6
-rw-r--r--src/server/ClientUpdate.cpp19
-rw-r--r--src/server/ClientUpdate.hpp8
-rw-r--r--src/server/CompiledGraph.cpp54
-rw-r--r--src/server/CompiledGraph.hpp24
-rw-r--r--src/server/ControlBindings.cpp52
-rw-r--r--src/server/ControlBindings.hpp21
-rw-r--r--src/server/DirectDriver.hpp17
-rw-r--r--src/server/Driver.hpp6
-rw-r--r--src/server/DuplexPort.cpp28
-rw-r--r--src/server/DuplexPort.hpp10
-rw-r--r--src/server/Engine.cpp81
-rw-r--r--src/server/Engine.hpp12
-rw-r--r--src/server/EnginePort.hpp10
-rw-r--r--src/server/Event.hpp18
-rw-r--r--src/server/EventWriter.cpp35
-rw-r--r--src/server/EventWriter.hpp12
-rw-r--r--src/server/FrameTimer.hpp12
-rw-r--r--src/server/GraphImpl.cpp35
-rw-r--r--src/server/GraphImpl.hpp36
-rw-r--r--src/server/GraphPlugin.hpp14
-rw-r--r--src/server/InputPort.cpp26
-rw-r--r--src/server/InputPort.hpp20
-rw-r--r--src/server/InternalBlock.cpp5
-rw-r--r--src/server/InternalBlock.hpp8
-rw-r--r--src/server/InternalPlugin.cpp11
-rw-r--r--src/server/InternalPlugin.hpp11
-rw-r--r--src/server/JackDriver.cpp63
-rw-r--r--src/server/JackDriver.hpp75
-rw-r--r--src/server/LV2Block.cpp90
-rw-r--r--src/server/LV2Block.hpp46
-rw-r--r--src/server/LV2Options.hpp8
-rw-r--r--src/server/LV2Plugin.cpp25
-rw-r--r--src/server/LV2Plugin.hpp10
-rw-r--r--src/server/LV2ResizeFeature.hpp10
-rw-r--r--src/server/Load.hpp10
-rw-r--r--src/server/NodeImpl.cpp13
-rw-r--r--src/server/NodeImpl.hpp10
-rw-r--r--src/server/OutputPort.hpp2
-rw-r--r--src/server/PluginImpl.hpp10
-rw-r--r--src/server/PortAudioDriver.cpp17
-rw-r--r--src/server/PortAudioDriver.hpp43
-rw-r--r--src/server/PortImpl.cpp56
-rw-r--r--src/server/PortImpl.hpp14
-rw-r--r--src/server/PortType.hpp113
-rw-r--r--src/server/PostProcessor.cpp8
-rw-r--r--src/server/PostProcessor.hpp6
-rw-r--r--src/server/PreProcessContext.hpp17
-rw-r--r--src/server/PreProcessor.cpp26
-rw-r--r--src/server/PreProcessor.hpp8
-rw-r--r--src/server/RunContext.cpp30
-rw-r--r--src/server/RunContext.hpp10
-rw-r--r--src/server/SocketListener.cpp19
-rw-r--r--src/server/SocketListener.hpp10
-rw-r--r--src/server/SocketServer.hpp28
-rw-r--r--src/server/State.hpp8
-rw-r--r--src/server/Task.cpp8
-rw-r--r--src/server/Task.hpp13
-rw-r--r--src/server/ThreadManager.hpp10
-rw-r--r--src/server/UndoStack.cpp33
-rw-r--r--src/server/UndoStack.hpp18
-rw-r--r--src/server/Worker.cpp29
-rw-r--r--src/server/Worker.hpp14
-rw-r--r--src/server/events.hpp28
-rw-r--r--src/server/events/Connect.cpp32
-rw-r--r--src/server/events/Connect.hpp10
-rw-r--r--src/server/events/Copy.cpp60
-rw-r--r--src/server/events/Copy.hpp6
-rw-r--r--src/server/events/CreateBlock.cpp48
-rw-r--r--src/server/events/CreateBlock.hpp7
-rw-r--r--src/server/events/CreateGraph.cpp50
-rw-r--r--src/server/events/CreateGraph.hpp11
-rw-r--r--src/server/events/CreatePort.cpp48
-rw-r--r--src/server/events/CreatePort.hpp17
-rw-r--r--src/server/events/Delete.cpp48
-rw-r--r--src/server/events/Delete.hpp17
-rw-r--r--src/server/events/Delta.cpp59
-rw-r--r--src/server/events/Delta.hpp20
-rw-r--r--src/server/events/Disconnect.cpp36
-rw-r--r--src/server/events/Disconnect.hpp7
-rw-r--r--src/server/events/DisconnectAll.cpp70
-rw-r--r--src/server/events/DisconnectAll.hpp7
-rw-r--r--src/server/events/Get.cpp40
-rw-r--r--src/server/events/Get.hpp4
-rw-r--r--src/server/events/Mark.cpp20
-rw-r--r--src/server/events/Mark.hpp9
-rw-r--r--src/server/events/Move.cpp21
-rw-r--r--src/server/events/Move.hpp4
-rw-r--r--src/server/events/SetPortValue.cpp27
-rw-r--r--src/server/events/SetPortValue.hpp3
-rw-r--r--src/server/events/Undo.cpp18
-rw-r--r--src/server/events/Undo.hpp2
-rw-r--r--src/server/ingen_engine.cpp6
-rw-r--r--src/server/ingen_jack.cpp16
-rw-r--r--src/server/ingen_lv2.cpp184
-rw-r--r--src/server/ingen_portaudio.cpp14
-rw-r--r--src/server/internals/BlockDelay.cpp25
-rw-r--r--src/server/internals/BlockDelay.hpp1
-rw-r--r--src/server/internals/Controller.cpp32
-rw-r--r--src/server/internals/Note.cpp29
-rw-r--r--src/server/internals/Note.hpp4
-rw-r--r--src/server/internals/Time.cpp29
-rw-r--r--src/server/internals/Time.hpp1
-rw-r--r--src/server/internals/Trigger.cpp29
-rw-r--r--src/server/meson.build38
-rw-r--r--src/server/mix.cpp10
-rw-r--r--src/server/mix.hpp6
-rw-r--r--src/server/util.hpp10
218 files changed, 3128 insertions, 3430 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy
index 8b9aa445..83a09b52 100644
--- a/src/.clang-tidy
+++ b/src/.clang-tidy
@@ -1,12 +1,16 @@
Checks: >
-*-avoid-c-arrays,
- -*-uppercase-literal-suffix,
+ -*-macro-to-enum,
-*-vararg,
-android-cloexec-*,
+ -boost-use-ranges,
-bugprone-easily-swappable-parameters,
+ -bugprone-multi-level-implicit-pointer-conversion,
+ -bugprone-unchecked-optional-access,
-cert-dcl50-cpp,
-cert-err33-c,
-cert-err34-c,
+ -clang-analyzer-optin.core.EnumCastOutOfRange,
-clang-analyzer-optin.cplusplus.VirtualCall,
-clang-analyzer-valist.Uninitialized,
-concurrency-mt-unsafe,
@@ -19,11 +23,10 @@ Checks: >
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-fuchsia-statically-constructed-objects,
- -google-readability-casting,
-hicpp-no-array-decay,
-hicpp-no-malloc,
-misc-no-recursion,
-misc-unused-parameters,
-readability-function-cognitive-complexity,
- -readability-use-anyofallof,
+ -readability-static-accessed-through-instance,
InheritParentConfig: true
diff --git a/src/AtomForge.cpp b/src/AtomForge.cpp
new file mode 100644
index 00000000..727bd64e
--- /dev/null
+++ b/src/AtomForge.cpp
@@ -0,0 +1,130 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-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
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <ingen/AtomForge.hpp>
+#include <ingen/memory.hpp>
+
+#include <lv2/atom/atom.h>
+#include <lv2/atom/forge.h>
+#include <lv2/atom/util.h>
+#include <lv2/urid/urid.h>
+#include <sord/sord.h>
+#include <sord/sordmm.hpp>
+#include <sratom/sratom.h>
+
+#include <cassert>
+#include <cstring>
+#include <utility>
+
+namespace ingen {
+
+AtomForge::AtomForge(LV2_URID_Map& map)
+ : LV2_Atom_Forge{}
+ , _sratom{sratom_new(&map)}
+ , _buf{static_cast<LV2_Atom*>(calloc(8, sizeof(LV2_Atom)))}
+{
+ lv2_atom_forge_init(this, &map);
+ lv2_atom_forge_set_sink(this, c_append, c_deref, this);
+}
+
+void
+AtomForge::read(Sord::World& world,
+ SordModel* const model,
+ const SordNode* const node)
+{
+ sratom_read(_sratom.get(), this, world.c_obj(), model, node);
+}
+
+const LV2_Atom*
+AtomForge::atom() const
+{
+ return _buf.get();
+}
+
+void
+AtomForge::clear()
+{
+ lv2_atom_forge_set_sink(this, c_append, c_deref, this);
+ _size = 0;
+ *_buf = {0U, 0U};
+}
+
+Sratom&
+AtomForge::sratom()
+{
+ return *_sratom;
+}
+
+intptr_t
+AtomForge::append(const void* const data, const uint32_t len)
+{
+ // Record offset of the start of this write (+1 to avoid null)
+ const auto ref = static_cast<intptr_t>(_size + 1U);
+
+ // Update size and reallocate if necessary
+ if (lv2_atom_pad_size(_size + len) > _capacity) {
+ const size_t new_size = lv2_atom_pad_size(_size + len);
+
+ // Release buffer and try to realloc it
+ auto* const old = _buf.release();
+ auto* const new_buf = static_cast<LV2_Atom*>(realloc(old, new_size));
+ if (!new_buf) {
+ // Failure, reclaim old buffer and signal error to caller
+ _buf = AtomPtr{old, FreeDeleter<LV2_Atom>{}};
+ return 0;
+ }
+
+ // Adopt new buffer and update capacity to make room for the new data
+ std::unique_ptr<LV2_Atom, FreeDeleter<LV2_Atom>> ptr{new_buf};
+ _capacity = new_size;
+ _buf = std::move(ptr);
+ }
+
+ // Append new data
+ memcpy(reinterpret_cast<uint8_t*>(_buf.get()) + _size, data, len);
+ _size += len;
+ return ref;
+}
+
+LV2_Atom*
+AtomForge::deref(const intptr_t ref)
+{
+ /* Make some assumptions and do unnecessary math to appease
+ -Wcast-align. This is questionable at best, though the forge should
+ only dereference references to aligned atoms. */
+ LV2_Atom* const ptr = _buf.get();
+ assert((ref - 1) % sizeof(LV2_Atom) == 0);
+ return static_cast<LV2_Atom*>(ptr + ((ref - 1) / sizeof(LV2_Atom)));
+
+ // Alternatively:
+ // return (LV2_Atom*)((uint8_t*)_buf.get() + ref - 1);
+}
+
+LV2_Atom_Forge_Ref
+AtomForge::c_append(void* const self,
+ const void* const data,
+ const uint32_t len)
+{
+ return static_cast<AtomForge*>(self)->append(data, len);
+}
+
+LV2_Atom*
+AtomForge::c_deref(void* const self, const LV2_Atom_Forge_Ref ref)
+{
+ return static_cast<AtomForge*>(self)->deref(ref);
+}
+
+} // namespace ingen
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp
index ac52082f..21cb9e40 100644
--- a/src/AtomReader.cpp
+++ b/src/AtomReader.cpp
@@ -14,31 +14,31 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/AtomReader.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/paths.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "raul/Path.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/AtomReader.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/paths.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <raul/Path.hpp>
#include <cstdint>
#include <cstring>
+#include <optional>
#include <string>
namespace ingen {
+enum class Status;
+
AtomReader::AtomReader(URIMap& map, URIs& uris, Log& log, Interface& iface)
: _map(map)
, _uris(uris)
@@ -79,7 +79,7 @@ AtomReader::get_props(const LV2_Atom_Object* obj,
}
}
-boost::optional<URI>
+std::optional<URI>
AtomReader::atom_to_uri(const LV2_Atom* atom)
{
if (!atom) {
@@ -115,10 +115,10 @@ AtomReader::atom_to_uri(const LV2_Atom* atom)
return {};
}
-boost::optional<raul::Path>
+std::optional<raul::Path>
AtomReader::atom_to_path(const LV2_Atom* atom)
{
- boost::optional<URI> uri = atom_to_uri(atom);
+ std::optional<URI> uri = atom_to_uri(atom);
if (uri && uri_is_path(*uri)) {
return uri_to_path(*uri);
}
@@ -130,7 +130,7 @@ AtomReader::atom_to_context(const LV2_Atom* atom)
{
Resource::Graph ctx = Resource::Graph::DEFAULT;
if (atom) {
- boost::optional<URI> maybe_uri = atom_to_uri(atom);
+ std::optional<URI> maybe_uri = atom_to_uri(atom);
if (maybe_uri) {
ctx = Resource::uri_to_graph(*maybe_uri);
} else {
@@ -174,7 +174,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
_uris.patch_sequenceNumber.urid(), &number,
nullptr);
- const boost::optional<URI> subject_uri = atom_to_uri(subject);
+ const std::optional<URI> subject_uri = atom_to_uri(subject);
const int32_t seq = ((number && number->type == _uris.atom_Int)
? reinterpret_cast<const LV2_Atom_Int*>(number)->body
@@ -213,10 +213,10 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
_uris.ingen_incidentTo.urid(), &incidentTo,
nullptr);
- boost::optional<raul::Path> subject_path(atom_to_path(subject));
- boost::optional<raul::Path> tail_path(atom_to_path(tail));
- boost::optional<raul::Path> head_path(atom_to_path(head));
- boost::optional<raul::Path> other_path(atom_to_path(incidentTo));
+ std::optional<raul::Path> subject_path(atom_to_path(subject));
+ std::optional<raul::Path> tail_path(atom_to_path(tail));
+ std::optional<raul::Path> head_path(atom_to_path(head));
+ std::optional<raul::Path> other_path(atom_to_path(incidentTo));
if (tail_path && head_path) {
_iface(Disconnect{seq, *tail_path, *head_path});
} else if (subject_path && other_path) {
@@ -255,8 +255,8 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
return false;
}
- boost::optional<raul::Path> tail_path(atom_to_path(tail));
- boost::optional<raul::Path> head_path(atom_to_path(head));
+ std::optional<raul::Path> tail_path(atom_to_path(tail));
+ std::optional<raul::Path> head_path(atom_to_path(head));
if (tail_path && head_path) {
_iface(Connect{seq, *tail_path, *head_path});
} else {
@@ -350,7 +350,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
}
- boost::optional<URI> dest_uri(atom_to_uri(dest));
+ std::optional<URI> dest_uri(atom_to_uri(dest));
if (!dest_uri) {
_log.warn("Copy message has non-URI destination\n");
return false;
@@ -370,13 +370,13 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
return false;
}
- boost::optional<raul::Path> subject_path(atom_to_path(subject));
+ std::optional<raul::Path> subject_path(atom_to_path(subject));
if (!subject_path) {
_log.warn("Move message has non-path subject\n");
return false;
}
- boost::optional<raul::Path> dest_path(atom_to_path(dest));
+ std::optional<raul::Path> dest_path(atom_to_path(dest));
if (!dest_path) {
_log.warn("Move message has non-path destination\n");
return false;
diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp
index e8418de1..5200cfde 100644
--- a/src/AtomWriter.cpp
+++ b/src/AtomWriter.cpp
@@ -47,30 +47,29 @@
* manipulating data in this model which resemble HTTP methods.
*/
-#include "ingen/AtomWriter.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/AtomForge.hpp"
-#include "ingen/AtomSink.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/paths.hpp"
-#include "lv2/atom/forge.h"
-#include "lv2/urid/urid.h"
-#include "raul/Path.hpp"
-#include "serd/serd.h"
-
-#include <boost/variant/apply_visitor.hpp>
+#include <ingen/AtomWriter.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/AtomForge.hpp>
+#include <ingen/AtomSink.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/paths.hpp>
+#include <lv2/atom/forge.h>
+#include <lv2/urid/urid.h>
+#include <raul/Path.hpp>
+#include <serd/serd.h>
#include <cassert>
#include <cstdint>
#include <map>
#include <string>
#include <utility>
+#include <variant>
namespace ingen {
@@ -92,7 +91,7 @@ AtomWriter::finish_msg()
void
AtomWriter::message(const Message& message)
{
- boost::apply_visitor(*this, message);
+ std::visit(*this, message);
}
/** @page protocol
@@ -295,8 +294,8 @@ AtomWriter::operator()(const Delta& message)
* Send a [Copy](http://lv2plug.in/ns/ext/copy#Copy) to copy an object from
* its current location (subject) to another (destination).
*
- * If both the subject and destination are inside Ingen, like block paths, then the old object
- * is copied by, for example, creating a new plugin instance.
+ * If both the subject and destination are inside Ingen, like block paths, then
+ * the old object is copied by, for example, creating a new plugin instance.
*
* If the subject is a filename (file URI or atom:Path) and the destination is
* inside Ingen, then the subject must be an Ingen graph file or bundle, which
@@ -436,7 +435,8 @@ AtomWriter::operator()(const Undo& message)
/** @page protocol
* @subsection Undo
*
- * Use [ingen:Redo](http://drobilla.net/ns/ingen#Redo) to redo the last undone change.
+ * Use [ingen:Redo](http://drobilla.net/ns/ingen#Redo) to redo the last undone
+ * change.
*
* @code{.ttl}
* [] a ingen:Redo .
diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp
index 428dd8ba..ed4dc91a 100644
--- a/src/ClashAvoider.cpp
+++ b/src/ClashAvoider.cpp
@@ -14,19 +14,18 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/ClashAvoider.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/ClashAvoider.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
+#include <optional>
#include <sstream>
#include <string>
#include <utility>
@@ -63,7 +62,7 @@ ClashAvoider::map_path(const raul::Path& in)
// Path without _n suffix
std::string base_path_str = in;
if (has_offset) {
- base_path_str = base_path_str.substr(0, base_path_str.find_last_of('_'));
+ base_path_str.resize(base_path_str.find_last_of('_'));
}
raul::Path base_path(base_path_str);
@@ -99,12 +98,6 @@ ClashAvoider::map_path(const raul::Path& in)
auto o = _offsets.find(base_path);
if (o != _offsets.end()) {
offset = ++o->second;
- } else {
- std::string parent_str = in.parent().base();
- parent_str = parent_str.substr(0, parent_str.find_last_of('/'));
- if (parent_str.empty()) {
- parent_str = "/";
- }
}
if (offset == 0) {
@@ -119,8 +112,8 @@ ClashAvoider::map_path(const raul::Path& in)
name = "_";
}
- raul::Symbol sym(name);
- std::string str = ss.str();
+ const raul::Symbol sym{name};
+ const std::string str{ss.str()};
auto i = _symbol_map.emplace(in, raul::Path(str));
@@ -143,7 +136,7 @@ ClashAvoider::exists(const raul::Path& path) const
return _store.find(path) != _store.end();
}
-static boost::optional<size_t>
+static std::optional<size_t>
numeric_suffix_start(const std::string& str)
{
if (!isdigit(str[str.length() - 1])) {
@@ -159,13 +152,13 @@ numeric_suffix_start(const std::string& str)
}
std::string
-ClashAvoider::adjust_name(const raul::Path& old_path,
- const raul::Path& new_path,
- std::string name)
+ClashAvoider::adjust_name(const raul::Path& old_path,
+ const raul::Path& new_path,
+ const std::string& name)
{
const auto name_suffix_start = numeric_suffix_start(name);
if (!name_suffix_start) {
- return name; // No numeric suffix, just re-use old label
+ return name; // No numeric suffix, just reuse old label
}
const auto name_suffix = atoi(name.c_str() + *name_suffix_start);
diff --git a/src/ColorContext.cpp b/src/ColorContext.cpp
index a4e60ca5..9706cb81 100644
--- a/src/ColorContext.cpp
+++ b/src/ColorContext.cpp
@@ -14,7 +14,8 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/ColorContext.hpp"
+#include <ingen/ColorContext.hpp>
+
#include "ingen_config.h"
#if USE_ISATTY
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 5af9fea1..9abdc288 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -14,26 +14,34 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Configuration.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/filesystem.hpp"
-#include "ingen/fmt.hpp"
-#include "ingen/ingen.h"
-#include "ingen/runtime_paths.hpp"
-#include "lv2/urid/urid.h"
-#include "serd/serd.h"
-#include "sord/sord.h"
-#include "sord/sordmm.hpp"
-#include "sratom/sratom.h"
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/fmt.hpp>
+#include <ingen/ingen.h>
+#include <ingen/runtime_paths.hpp>
+#include <lv2/urid/urid.h>
+#include <serd/serd.h>
+#include <sord/sord.h>
+#include <sord/sordmm.hpp>
+#include <sratom/sratom.h>
#include <algorithm>
#include <cassert>
#include <cerrno>
#include <cstdint>
+#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <filesystem>
+#include <list>
+#include <map>
#include <memory>
+#include <ostream>
+#include <string>
+#include <system_error>
#include <thread>
#include <utility>
#include <vector>
@@ -55,6 +63,8 @@ Configuration::Configuration(Forge& forge)
" ingen -eg # Run engine and GUI in one process\n"
" ingen -eg foo.ingen # Run engine and GUI and load a graph")
{
+ static const auto default_n_threads = static_cast<int32_t>(std::max(std::thread::hardware_concurrency(), 1U));
+
add("atomicBundles", "atomic-bundles", 'a', "Execute bundles atomically", GLOBAL, forge.Bool, forge.make(false));
add("bufferSize", "buffer-size", 'b', "Buffer size in samples", GLOBAL, forge.Int, forge.make(1024));
add("clientPort", "client-port", 'C', "Client port", GLOBAL, forge.Int, Atom());
@@ -77,7 +87,7 @@ Configuration::Configuration(Forge& forge)
add("flushLog", "flush-log", 'f', "Flush logs after every entry", GLOBAL, forge.Bool, forge.make(false));
add("dump", "dump", 'd', "Print debug output", SESSION, forge.Bool, forge.make(false));
add("trace", "trace", 't', "Show LV2 plugin trace messages", SESSION, forge.Bool, forge.make(false));
- add("threads", "threads", 'p', "Number of processing threads", GLOBAL, forge.Int, forge.make(int32_t(std::max(std::thread::hardware_concurrency(), 1U))));
+ add("threads", "threads", 'p', "Number of processing threads", GLOBAL, forge.Int, forge.make(default_n_threads));
add("humanNames", "human-names", 0, "Show human names in GUI", GUI, forge.Bool, forge.make(true));
add("portLabels", "port-labels", 0, "Show port labels in GUI", GUI, forge.Bool, forge.make(true));
add("graphDirectory", "graph-directory", 0, "Default directory for opening graphs", GUI, forge.String, Atom());
@@ -121,10 +131,10 @@ Configuration::variable_string(LV2_URID type) const
void
Configuration::print_usage(const std::string& program, std::ostream& os)
{
- os << "Usage: " << program << " [OPTION]... [GRAPH]" << std::endl;
- os << _shortdesc << std::endl << std::endl;
- os << _desc << std::endl << std::endl;
- os << "Options:" << std::endl;
+ os << "Usage: " << program << " [OPTION]... [GRAPH]\n";
+ os << _shortdesc << "\n\n";
+ os << _desc << "\n\n";
+ os << "Options:\n";
for (const auto& o : _options) {
const Option& option = o.second;
os << " ";
@@ -133,10 +143,10 @@ Configuration::print_usage(const std::string& program, std::ostream& os)
} else {
os << " ";
}
- os.width(_max_name_length + 11);
+ os.width(static_cast<std::streamsize>(_max_name_length + 11));
os << std::left;
os << (std::string("--") + o.first + variable_string(option.type));
- os << option.desc << std::endl;
+ os << option.desc << "\n";
}
}
@@ -145,8 +155,8 @@ Configuration::set_value_from_string(Configuration::Option& option,
const std::string& value)
{
if (option.type == _forge.Int) {
- char* endptr = nullptr;
- int intval = static_cast<int>(strtol(value.c_str(), &endptr, 10));
+ char* endptr = nullptr;
+ const int intval = static_cast<int>(strtol(value.c_str(), &endptr, 10));
if (endptr && *endptr == '\0') {
option.value = _forge.make(intval);
} else {
@@ -157,7 +167,7 @@ Configuration::set_value_from_string(Configuration::Option& option,
option.value = _forge.alloc(value.c_str());
assert(option.value.type() == _forge.String);
} else if (option.type == _forge.Bool) {
- option.value = _forge.make(bool(!strcmp(value.c_str(), "true")));
+ option.value = _forge.make(!strcmp(value.c_str(), "true"));
assert(option.value.type() == _forge.Bool);
} else {
throw OptionError(fmt("Bad option type `%1%'", option.name));
@@ -183,7 +193,7 @@ Configuration::parse(int argc, char** argv)
std::string name = std::string(argv[i]).substr(2);
const char* equals = strchr(argv[i], '=');
if (equals) {
- name = name.substr(0, name.find('='));
+ name.resize(name.find('='));
}
const auto o = _options.find(name);
@@ -232,7 +242,7 @@ Configuration::parse(int argc, char** argv)
bool
Configuration::load(const FilePath& path)
{
- if (!filesystem::exists(path)) {
+ if (!std::filesystem::exists(path)) {
return false;
}
@@ -246,8 +256,11 @@ Configuration::load(const FilePath& path)
SerdEnv* env = serd_env_new(&node);
model.load_file(env, SERD_TURTLE, uri, uri);
- Sord::Node nodemm(world, Sord::Node::URI, reinterpret_cast<const char*>(node.buf));
- Sord::Node nil;
+ const Sord::Node nodemm{world,
+ Sord::Node::URI,
+ reinterpret_cast<const char*>(node.buf)};
+
+ const Sord::Node nil;
for (auto i = model.find(nodemm, nil, nil); !i.end(); ++i) {
const auto& pred = i.get_predicate();
const auto& obj = i.get_object();
@@ -279,15 +292,17 @@ Configuration::save(URIMap& uri_map,
}
// Create parent directories if necessary
- const FilePath dir = path.parent_path();
- if (!filesystem::create_directories(dir)) {
+ const FilePath dir = path.parent_path();
+ std::error_code ec;
+ std::filesystem::create_directories(dir, ec);
+ if (ec) {
throw FileError(fmt("Error creating directory %1% (%2%)",
dir, strerror(errno)));
}
// Attempt to open file for writing
- std::unique_ptr<FILE, decltype(&fclose)> file{fopen(path.c_str(), "w"),
- &fclose};
+ const std::unique_ptr<FILE, int (*)(FILE*)> file{
+ fopen(path.c_str(), "w"), &fclose};
if (!file) {
throw FileError(fmt("Failed to open file %1% (%2%)",
path, strerror(errno)));
@@ -342,7 +357,7 @@ Configuration::save(URIMap& uri_map,
}
const std::string key(std::string("ingen:") + o.second.key);
- SerdNode pred = serd_node_from_string(
+ const SerdNode pred = serd_node_from_string(
SERD_CURIE, reinterpret_cast<const uint8_t*>(key.c_str()));
sratom_write(sratom, &uri_map.urid_unmap(), 0,
&base, &pred, value.type(), value.size(), value.get_body());
diff --git a/src/FilePath.cpp b/src/FilePath.cpp
deleted file mode 100644
index 8cbd3a9e..00000000
--- a/src/FilePath.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2018 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
- Software Foundation, either version 3 of the License, or any later version.
-
- Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ingen/FilePath.hpp"
-
-#include <algorithm>
-#include <string>
-#include <utility>
-
-namespace ingen {
-
-template <typename Char>
-static bool
-is_sep(const Char chr)
-{
-#if USE_WINDOWS_FILE_PATHS
- return chr == L'/' || chr == preferred_separator;
-#else
- return chr == '/';
-#endif
-}
-
-FilePath&
-FilePath::operator=(FilePath&& path) noexcept
-{
- _str = std::move(path._str);
- path.clear();
- return *this;
-}
-
-FilePath&
-FilePath::operator=(string_type&& str)
-{
- _str = std::move(str);
- return *this;
-}
-
-FilePath&
-FilePath::operator/=(const FilePath& path)
-{
- const FilePath::string_type& str = path.string();
- if (!_str.empty() && !is_sep(_str.back()) && !str.empty() &&
- !is_sep(str.front())) {
- _str += preferred_separator;
- }
-
- _str += str;
- return *this;
-}
-
-FilePath&
-FilePath::operator+=(const FilePath& path)
-{
- return operator+=(path.native());
-}
-
-FilePath&
-FilePath::operator+=(const string_type& str)
-{
- _str += str;
- return *this;
-}
-
-FilePath&
-FilePath::operator+=(const value_type* str)
-{
- _str += str;
- return *this;
-}
-
-FilePath&
-FilePath::operator+=(value_type chr)
-{
- _str += chr;
- return *this;
-}
-
-FilePath&
-FilePath::operator+=(boost::basic_string_view<value_type> sv)
-{
- _str.append(sv.data(), sv.size());
- return *this;
-}
-
-FilePath
-FilePath::root_name()
-{
-#if USE_WINDOWS_FILE_PATHS
- if (_str.length() >= 2 && _str[0] >= 'A' && _str[0] <= 'Z' &&
- _str[1] == ':') {
- return FilePath(_str.substr(0, 2));
- }
-#endif
-
- return {};
-}
-
-FilePath
-FilePath::root_directory() const
-{
-#if USE_WINDOWS_FILE_PATHS
- const auto name = root_name().string();
- return name.empty() ? Path() : Path(name + preferred_separator);
-#endif
-
- return _str[0] == '/' ? FilePath("/") : FilePath();
-}
-
-FilePath
-FilePath::root_path() const
-{
-#if USE_WINDOWS_FILE_PATHS
- const auto name = root_name();
- return name.empty() ? FilePath() : name / root_directory();
-#endif
- return root_directory();
-}
-
-FilePath
-FilePath::relative_path() const
-{
- const auto root = root_path();
- return root.empty() ? FilePath()
- : FilePath(_str.substr(root.string().length()));
-}
-
-FilePath
-FilePath::parent_path() const
-{
- if (empty() || *this == root_path()) {
- return *this;
- }
-
- const auto first_sep = find_first_sep();
- const auto last_sep = find_last_sep();
- return ((last_sep == std::string::npos || last_sep == first_sep)
- ? root_path()
- : FilePath(_str.substr(0, last_sep)));
-}
-
-FilePath
-FilePath::filename() const
-{
- return ((empty() || *this == root_path())
- ? FilePath()
- : FilePath(_str.substr(find_last_sep() + 1)));
-}
-
-FilePath
-FilePath::stem() const
-{
- const auto name = filename();
- const auto dot = name.string().find('.');
- return ((dot == std::string::npos) ? name
- : FilePath(name.string().substr(0, dot)));
-}
-
-FilePath
-FilePath::extension() const
-{
- const auto name = filename().string();
- const auto dot = name.find('.');
- return ((dot == std::string::npos) ? FilePath()
- : FilePath(name.substr(dot, dot)));
-}
-
-bool
-FilePath::is_absolute() const
-{
-#if USE_WINDOWS_FILE_PATHS
- return !root_name().empty();
-#else
- return !root_directory().empty();
-#endif
-}
-
-std::size_t
-FilePath::find_first_sep() const
-{
- const auto i = std::find_if(_str.begin(), _str.end(), is_sep<value_type>);
- return i == _str.end() ? std::string::npos : (i - _str.begin());
-}
-
-std::size_t
-FilePath::find_last_sep() const
-{
- const auto i = std::find_if(_str.rbegin(), _str.rend(), is_sep<value_type>);
- return (i == _str.rend() ? std::string::npos
- : (_str.length() - 1 - (i - _str.rbegin())));
-}
-
-bool
-operator==(const FilePath& lhs, const FilePath& rhs) noexcept
-{
- return lhs.string() == rhs.string();
-}
-
-bool
-operator!=(const FilePath& lhs, const FilePath& rhs) noexcept
-{
- return !(lhs == rhs);
-}
-
-bool
-operator<(const FilePath& lhs, const FilePath& rhs) noexcept
-{
- return lhs.string().compare(rhs.string()) < 0;
-}
-
-bool
-operator<=(const FilePath& lhs, const FilePath& rhs) noexcept
-{
- return !(rhs < lhs);
-}
-
-bool
-operator>(const FilePath& lhs, const FilePath& rhs) noexcept
-{
- return rhs < lhs;
-}
-
-bool
-operator>=(const FilePath& lhs, const FilePath& rhs) noexcept
-{
- return !(lhs < rhs);
-}
-
-FilePath
-operator/(const FilePath& lhs, const FilePath& rhs)
-{
- return FilePath(lhs) /= rhs;
-}
-
-} // namespace ingen
diff --git a/src/Forge.cpp b/src/Forge.cpp
index abce74f2..8b222c64 100644
--- a/src/Forge.cpp
+++ b/src/Forge.cpp
@@ -14,13 +14,16 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Forge.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "lv2/atom/forge.h"
-#include "lv2/urid/urid.h"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <lv2/atom/forge.h>
+#include <lv2/urid/urid.h>
+#include <cstdint>
#include <sstream>
+#include <string>
namespace ingen {
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp
index 65fe6f6b..73cc9382 100644
--- a/src/LV2Features.cpp
+++ b/src/LV2Features.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -14,10 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/LV2Features.hpp"
+#include <ingen/LV2Features.hpp>
-#include "lv2/core/lv2.h"
+#include <lv2/core/lv2.h>
+#include <algorithm>
#include <cstdlib>
#include <memory>
@@ -30,6 +31,12 @@ LV2Features::Feature::free_feature(LV2_Feature* feature)
free(feature);
}
+std::shared_ptr<LV2_Feature>
+LV2Features::EmptyFeature::feature(World& world, Node* block)
+{
+ return std::make_shared<LV2_Feature>(LV2_Feature{_uri, nullptr});
+}
+
void
LV2Features::add_feature(const std::shared_ptr<Feature>& feature)
{
@@ -58,12 +65,9 @@ LV2Features::is_supported(const std::string& uri) const
return true;
}
- for (const auto& f : _features) {
- if (f->uri() == uri) {
- return true;
- }
- }
- return false;
+ return std::any_of(_features.begin(),
+ _features.end(),
+ [&uri](const auto& f) { return f->uri() == uri; });
}
std::shared_ptr<LV2Features::FeatureArray>
@@ -71,7 +75,7 @@ LV2Features::lv2_features(World& world, Node* node) const
{
FeatureArray::FeatureVector vec;
for (const auto& f : _features) {
- std::shared_ptr<LV2_Feature> fptr = f->feature(world, node);
+ const std::shared_ptr<LV2_Feature> fptr = f->feature(world, node);
if (fptr) {
vec.push_back(fptr);
}
diff --git a/src/Library.cpp b/src/Library.cpp
index a8a7107e..4add6577 100644
--- a/src/Library.cpp
+++ b/src/Library.cpp
@@ -14,7 +14,8 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Library.hpp"
+#include <ingen/FilePath.hpp>
+#include <ingen/Library.hpp>
#ifdef _WIN32
# include <windows.h>
diff --git a/src/Log.cpp b/src/Log.cpp
index e05caa21..fbcaeca1 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2016 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -14,19 +14,20 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Log.hpp"
+#include <ingen/Log.hpp>
-#include "ingen/ColorContext.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/core/lv2.h"
-#include "lv2/log/log.h"
-#include "lv2/urid/urid.h"
-#include "raul/Path.hpp"
+#include <ingen/ColorContext.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/core/lv2.h>
+#include <lv2/log/log.h>
+#include <lv2/urid/urid.h>
+#include <raul/Path.hpp>
#include <cstdio>
#include <cstdlib>
+#include <memory>
namespace ingen {
@@ -39,46 +40,44 @@ void
Log::rt_error(const char* msg)
{
#ifndef NDEBUG
- va_list args;
- vtprintf(_uris.log_Error, msg, args);
+ tprintf(_uris.log_Error, msg);
#endif
}
void
Log::error(const std::string& msg)
{
- va_list args;
- vtprintf(_uris.log_Error, msg.c_str(), args);
+ tprintf(_uris.log_Error, msg.c_str());
}
void
Log::warn(const std::string& msg)
{
- va_list args;
- vtprintf(_uris.log_Warning, msg.c_str(), args);
+ tprintf(_uris.log_Warning, msg.c_str());
}
void
Log::info(const std::string& msg)
{
- va_list args;
- vtprintf(_uris.log_Note, msg.c_str(), args);
+ tprintf(_uris.log_Note, msg.c_str());
}
void
Log::trace(const std::string& msg)
{
- va_list args;
- vtprintf(_uris.log_Trace, msg.c_str(), args);
+ tprintf(_uris.log_Trace, msg.c_str());
}
-void
-Log::print(FILE* stream, const std::string& msg) const
+int
+Log::tprintf(LV2_URID type, const char* fmt, ...)
{
- fprintf(stream, "%s", msg.c_str());
- if (_flush) {
- fflush(stdout);
- }
+ va_list args;
+ va_start(args, fmt);
+
+ const int ret = vtprintf(type, fmt, args);
+
+ va_end(args);
+ return ret;
}
int
@@ -96,16 +95,16 @@ Log::vtprintf(LV2_URID type, const char* fmt, va_list args)
if (_log) {
ret = _log->vprintf(_log->handle, type, fmt, args);
} else if (type == _uris.log_Error) {
- ColorContext ctx(stderr, ColorContext::Color::RED);
+ const ColorContext ctx{stderr, ColorContext::Color::RED};
ret = vfprintf(stderr, fmt, args);
} else if (type == _uris.log_Warning) {
- ColorContext ctx(stderr, ColorContext::Color::YELLOW);
+ const ColorContext ctx{stderr, ColorContext::Color::YELLOW};
ret = vfprintf(stderr, fmt, args);
} else if (type == _uris.log_Note) {
- ColorContext ctx(stderr, ColorContext::Color::GREEN);
+ const ColorContext ctx{stderr, ColorContext::Color::GREEN};
ret = vfprintf(stdout, fmt, args);
} else if (_trace && type == _uris.log_Trace) {
- ColorContext ctx(stderr, ColorContext::Color::GREEN);
+ const ColorContext ctx{stderr, ColorContext::Color::GREEN};
ret = vfprintf(stderr, fmt, args);
} else {
fprintf(stderr, "Unknown log type %u\n", type);
@@ -120,11 +119,10 @@ Log::vtprintf(LV2_URID type, const char* fmt, va_list args)
static int
log_vprintf(LV2_Log_Handle handle, LV2_URID type, const char* fmt, va_list args)
{
- auto* f = static_cast<Log::Feature::Handle*>(handle);
- va_list noargs = {};
+ auto* const f = static_cast<Log::Feature::Handle*>(handle);
- int ret = f->log->vtprintf(type, f->node->path().c_str(), noargs);
- ret += f->log->vtprintf(type, ": ", noargs);
+ int ret = f->log->tprintf(type, f->node->path().c_str());
+ ret += f->log->tprintf(type, ": ");
ret += f->log->vtprintf(type, fmt, args);
return ret;
diff --git a/src/Parser.cpp b/src/Parser.cpp
index 7b25031c..c03f0abf 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -14,39 +14,43 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Parser.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/AtomForge.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/filesystem.hpp"
-#include "ingen/paths.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/core/lv2.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-#include "serd/serd.h"
-#include "sord/sord.h"
-#include "sord/sordmm.hpp"
-
+#include <ingen/Parser.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/AtomForge.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/ingen.h>
+#include <ingen/paths.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/core/lv2.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+#include <serd/serd.h>
+#include <sord/sord.h>
+#include <sord/sordmm.hpp>
+
+#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
+#include <filesystem>
#include <map>
#include <set>
#include <string>
+#include <string_view>
#include <utility>
-#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
+#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
namespace ingen {
@@ -55,24 +59,25 @@ Parser::find_resources(Sord::World& world,
const URI& manifest_uri,
const URI& type_uri)
{
- const Sord::URI base (world, manifest_uri.string());
- const Sord::URI type (world, type_uri.string());
- const Sord::URI rdf_type (world, NS_RDF "type");
+ const Sord::URI base(world, manifest_uri.string());
+ const Sord::URI type(world, type_uri.string());
+ const Sord::URI rdf_type(world, NS_RDF "type");
const Sord::URI rdfs_seeAlso(world, NS_RDFS "seeAlso");
const Sord::Node nil;
- SerdEnv* env = serd_env_new(sord_node_to_serd_node(base.c_obj()));
+ SerdEnv* env = serd_env_new(sord_node_to_serd_node(base.c_obj()));
Sord::Model model(world, manifest_uri.string());
model.load_file(env, SERD_TURTLE, manifest_uri.string());
std::set<ResourceRecord> resources;
for (auto i = model.find(nil, rdf_type, type); !i.end(); ++i) {
- const auto resource = i.get_subject();
- auto f = model.find(resource, rdfs_seeAlso, nil);
+ const auto resource = i.get_subject();
+ auto f = model.find(resource, rdfs_seeAlso, nil);
std::string file_path;
if (!f.end()) {
- uint8_t* p = serd_file_uri_parse(f.get_object().to_u_string(), nullptr);
+ uint8_t* p =
+ serd_file_uri_parse(f.get_object().to_u_string(), nullptr);
file_path = reinterpret_cast<const char*>(p);
serd_free(p);
}
@@ -84,30 +89,28 @@ Parser::find_resources(Sord::World& world,
return resources;
}
-static boost::optional<raul::Path>
+static std::optional<raul::Path>
get_path(const URI& base, const URI& uri)
{
- const URI relative = uri.make_relative(base);
+ const URI relative = uri.make_relative(base, base);
const std::string uri_str = "/" + relative.string();
return raul::Path::is_valid(uri_str) ? raul::Path(uri_str)
- : boost::optional<raul::Path>();
+ : std::optional<raul::Path>();
}
static bool
skip_property(ingen::URIs& uris, const Sord::Node& predicate)
{
- return (predicate == INGEN__file ||
- predicate == uris.ingen_arc ||
- predicate == uris.ingen_block ||
- predicate == uris.lv2_port);
+ return (predicate == INGEN__file || predicate == uris.ingen_arc ||
+ predicate == uris.ingen_block || predicate == uris.lv2_port);
}
static Properties
-get_properties(ingen::World& world,
- Sord::Model& model,
- const Sord::Node& subject,
- Resource::Graph ctx,
- const boost::optional<Properties>& data = {})
+get_properties(ingen::World& world,
+ Sord::Model& model,
+ const Sord::Node& subject,
+ Resource::Graph ctx,
+ const std::optional<Properties>& data = {})
{
AtomForge forge(world.uri_map().urid_map());
@@ -116,12 +119,13 @@ get_properties(ingen::World& world,
for (auto i = model.find(subject, nil, nil); !i.end(); ++i) {
if (!skip_property(world.uris(), i.get_predicate())) {
forge.clear();
- forge.read(
- *world.rdf_world(), model.c_obj(), i.get_object().c_obj());
+ forge.read(*world.rdf_world(),
+ model.c_obj(),
+ i.get_object().c_obj());
const LV2_Atom* atom = forge.atom();
Atom atomm;
- atomm = Forge::alloc(
- atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));
+ atomm =
+ Forge::alloc(atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));
props.emplace(i.get_predicate(), Property(atomm, ctx));
}
}
@@ -148,7 +152,7 @@ get_properties(ingen::World& world,
using PortRecord = std::pair<raul::Path, Properties>;
-static boost::optional<PortRecord>
+static std::optional<PortRecord>
get_port(ingen::World& world,
Sord::Model& model,
const Sord::Node& subject,
@@ -164,9 +168,8 @@ get_port(ingen::World& world,
// Get index if requested (for Graphs)
if (index) {
const auto i = props.find(uris.lv2_index);
- if (i == props.end()
- || i->second.type() != world.forge().Int
- || i->second.get<int32_t>() < 0) {
+ if (i == props.end() || i->second.type() != world.forge().Int ||
+ i->second.get<int32_t>() < 0) {
world.log().error("Port %1% has no valid index\n", subject);
return {};
}
@@ -183,8 +186,8 @@ get_port(ingen::World& world,
const size_t last_slash = subject_str.find_last_of('/');
sym = ((last_slash == std::string::npos)
- ? subject_str
- : subject_str.substr(last_slash + 1));
+ ? subject_str
+ : subject_str.substr(last_slash + 1));
}
if (!raul::Symbol::is_valid(sym)) {
@@ -199,64 +202,62 @@ get_port(ingen::World& world,
return make_pair(port_path, props);
}
-static boost::optional<raul::Path>
-parse(
- World& world,
- Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- Sord::Node& subject,
- const boost::optional<raul::Path>& parent = boost::optional<raul::Path>(),
- const boost::optional<raul::Symbol>& symbol = boost::optional<raul::Symbol>(),
- const boost::optional<Properties>& data = boost::optional<Properties>());
-
-static boost::optional<raul::Path>
+static std::optional<raul::Path>
+parse(World& world,
+ Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ Sord::Node& subject,
+ const std::optional<raul::Path>& parent = std::optional<raul::Path>(),
+ const std::optional<raul::Symbol>& symbol = std::optional<raul::Symbol>(),
+ const std::optional<Properties>& data = std::optional<Properties>());
+
+static std::optional<raul::Path>
parse_graph(
- World& world,
- Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- const Sord::Node& subject,
- Resource::Graph ctx,
- const boost::optional<raul::Path>& parent = boost::optional<raul::Path>(),
- const boost::optional<raul::Symbol>& symbol = boost::optional<raul::Symbol>(),
- const boost::optional<Properties>& data = boost::optional<Properties>());
-
-static boost::optional<raul::Path>
+ World& world,
+ Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ const Sord::Node& subject,
+ Resource::Graph ctx,
+ const std::optional<raul::Path>& parent = std::optional<raul::Path>(),
+ const std::optional<raul::Symbol>& symbol = std::optional<raul::Symbol>(),
+ const std::optional<Properties>& data = std::optional<Properties>());
+
+static std::optional<raul::Path>
parse_block(
- World& world,
- Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- const Sord::Node& subject,
- const raul::Path& path,
- const boost::optional<Properties>& data = boost::optional<Properties>());
+ World& world,
+ Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ const Sord::Node& subject,
+ const raul::Path& path,
+ const std::optional<Properties>& data = std::optional<Properties>());
static bool
-parse_arcs(
- World& world,
- Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- const Sord::Node& subject,
- const raul::Path& graph);
-
-static boost::optional<raul::Path>
-parse_block(ingen::World& world,
- ingen::Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- const Sord::Node& subject,
- const raul::Path& path,
- const boost::optional<Properties>& data)
+parse_arcs(World& world,
+ Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ const Sord::Node& subject,
+ const raul::Path& graph);
+
+static std::optional<raul::Path>
+parse_block(ingen::World& world,
+ ingen::Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ const Sord::Node& subject,
+ const raul::Path& path,
+ const std::optional<Properties>& data)
{
const URIs& uris = world.uris();
// Try lv2:prototype and old ingen:prototype for backwards compatibility
- const Sord::URI prototype_predicates[] = {
- Sord::URI(*world.rdf_world(), uris.lv2_prototype),
- Sord::URI(*world.rdf_world(), uris.ingen_prototype)
- };
+ const Sord::URI prototype_predicates[] = {Sord::URI(*world.rdf_world(),
+ uris.lv2_prototype),
+ Sord::URI(*world.rdf_world(),
+ uris.ingen_prototype)};
// Get prototype
Sord::Node prototype;
@@ -269,7 +270,8 @@ parse_block(ingen::World& world,
if (!prototype.is_valid()) {
world.log().error("Block %1% (%2%) missing mandatory lv2:prototype\n",
- subject, path);
+ subject,
+ path);
return {};
}
@@ -283,56 +285,67 @@ parse_block(ingen::World& world,
serd_uri_parse(reinterpret_cast<const uint8_t*>(base_uri.c_str()),
&base_uri_parts);
- SerdURI ignored;
- SerdNode sub_uri = serd_node_new_uri_from_string(
- type_uri,
- &base_uri_parts,
- &ignored);
+ SerdURI ignored;
+ const SerdNode sub_uri =
+ serd_node_new_uri_from_string(type_uri, &base_uri_parts, &ignored);
- const std::string sub_uri_str = reinterpret_cast<const char*>(sub_uri.buf);
- const std::string sub_file = sub_uri_str + "/main.ttl";
+ const std::string sub_uri_str =
+ reinterpret_cast<const char*>(sub_uri.buf);
+ const std::string sub_file = sub_uri_str + "/main.ttl";
const SerdNode sub_base = serd_node_from_string(
SERD_URI, reinterpret_cast<const uint8_t*>(sub_file.c_str()));
Sord::Model sub_model(*world.rdf_world(), sub_file);
- SerdEnv* env = serd_env_new(&sub_base);
+ SerdEnv* env = serd_env_new(&sub_base);
sub_model.load_file(env, SERD_TURTLE, sub_file);
serd_env_free(env);
- Sord::URI sub_node(*world.rdf_world(), sub_file);
- parse_graph(world, target, sub_model, sub_base,
- sub_node, Resource::Graph::INTERNAL,
- path.parent(), raul::Symbol(path.symbol()), data);
-
- parse_graph(world, target, model, base_uri,
- subject, Resource::Graph::EXTERNAL,
- path.parent(), raul::Symbol(path.symbol()), data);
+ const Sord::URI sub_node{*world.rdf_world(), sub_file};
+ parse_graph(world,
+ target,
+ sub_model,
+ sub_base,
+ sub_node,
+ Resource::Graph::INTERNAL,
+ path.parent(),
+ raul::Symbol(path.symbol()),
+ data);
+
+ parse_graph(world,
+ target,
+ model,
+ base_uri,
+ subject,
+ Resource::Graph::EXTERNAL,
+ path.parent(),
+ raul::Symbol(path.symbol()),
+ data);
} else {
// Prototype is non-file URI, plugin
Properties props = get_properties(
- world, model, subject, Resource::Graph::DEFAULT, data);
+ world, model, subject, Resource::Graph::DEFAULT, data);
props.emplace(uris.rdf_type, uris.forge.make_urid(uris.ingen_Block));
target.put(path_to_uri(path), props);
}
return path;
}
-static boost::optional<raul::Path>
-parse_graph(ingen::World& world,
- ingen::Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- const Sord::Node& subject,
- Resource::Graph ctx,
- const boost::optional<raul::Path>& parent,
- const boost::optional<raul::Symbol>& symbol,
- const boost::optional<Properties>& data)
+static std::optional<raul::Path>
+parse_graph(ingen::World& world,
+ ingen::Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ const Sord::Node& subject,
+ Resource::Graph ctx,
+ const std::optional<raul::Path>& parent,
+ const std::optional<raul::Symbol>& symbol,
+ const std::optional<Properties>& data)
{
const URIs& uris = world.uris();
const Sord::URI ingen_block(*world.rdf_world(), uris.ingen_block);
- const Sord::URI lv2_port(*world.rdf_world(), LV2_CORE__port);
+ const Sord::URI lv2_port(*world.rdf_world(), LV2_CORE__port);
const Sord::Node& graph = subject;
const Sord::Node nil;
@@ -346,7 +359,7 @@ parse_graph(ingen::World& world,
}
// Create graph
- Properties props = get_properties(world, model, subject, ctx, data);
+ const Properties props = get_properties(world, model, subject, ctx, data);
target.put(path_to_uri(graph_path), props, ctx);
// For each port on this graph
@@ -356,9 +369,9 @@ parse_graph(ingen::World& world,
Sord::Node port = p.get_object();
// Get all properties
- uint32_t index = 0;
- boost::optional<PortRecord> port_record = get_port(
- world, model, port, ctx, graph_path, &index);
+ uint32_t index = 0;
+ std::optional<PortRecord> port_record =
+ get_port(world, model, port, ctx, graph_path, &index);
if (!port_record) {
world.log().error("Invalid port %1%\n", port);
return {};
@@ -369,15 +382,14 @@ parse_graph(ingen::World& world,
ports[index] = *port_record;
} else {
world.log().error("Ignored port %1% with duplicate index %2%\n",
- port, index);
+ port,
+ index);
}
}
// Create ports in order by index
for (const auto& p : ports) {
- target.put(path_to_uri(p.second.first),
- p.second.second,
- ctx);
+ target.put(path_to_uri(p.second.first), p.second.second, ctx);
}
if (ctx != Resource::Graph::INTERNAL) {
@@ -386,30 +398,32 @@ parse_graph(ingen::World& world,
// For each block in this graph
for (auto n = model.find(subject, ingen_block, nil); !n.end(); ++n) {
- Sord::Node node = n.get_object();
- URI node_uri = node;
+ const Sord::Node node = n.get_object();
+ const URI node_uri = node;
assert(!node_uri.path().empty() && node_uri.path() != "/");
const raul::Path block_path = graph_path.child(
- raul::Symbol(FilePath(node_uri.path()).stem().string()));
+ raul::Symbol(FilePath(node_uri.path()).stem().string()));
// Parse and create block
- parse_block(world, target, model, base_uri, node, block_path,
- boost::optional<Properties>());
+ parse_block(
+ world, target, model, base_uri, node, block_path, std::nullopt);
// For each port on this block
for (auto p = model.find(node, lv2_port, nil); !p.end(); ++p) {
Sord::Node port = p.get_object();
Resource::Graph subctx = Resource::Graph::DEFAULT;
- if (!model.find(node,
- Sord::URI(*world.rdf_world(), uris.rdf_type),
- Sord::URI(*world.rdf_world(), uris.ingen_Graph)).end()) {
+ if (!model
+ .find(node,
+ Sord::URI(*world.rdf_world(), uris.rdf_type),
+ Sord::URI(*world.rdf_world(), uris.ingen_Graph))
+ .end()) {
subctx = Resource::Graph::EXTERNAL;
}
// Get all properties
- boost::optional<PortRecord> port_record = get_port(
- world, model, port, subctx, block_path, nullptr);
+ std::optional<PortRecord> port_record =
+ get_port(world, model, port, subctx, block_path, nullptr);
if (!port_record) {
world.log().error("Invalid port %1%\n", port);
return {};
@@ -429,12 +443,12 @@ parse_graph(ingen::World& world,
}
static bool
-parse_arc(ingen::World& world,
- ingen::Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- const Sord::Node& subject,
- const raul::Path& graph)
+parse_arc(ingen::World& world,
+ ingen::Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ const Sord::Node& subject,
+ const raul::Path& graph)
{
const URIs& uris = world.uris();
@@ -455,15 +469,15 @@ parse_arc(ingen::World& world,
return false;
}
- const boost::optional<raul::Path> tail_path = get_path(
- base_uri, t.get_object());
+ const std::optional<raul::Path> tail_path =
+ get_path(base_uri, t.get_object());
if (!tail_path) {
world.log().error("Arc tail has invalid URI\n");
return false;
}
- const boost::optional<raul::Path> head_path = get_path(
- base_uri, h.get_object());
+ const std::optional<raul::Path> head_path =
+ get_path(base_uri, h.get_object());
if (!head_path) {
world.log().error("Arc head has invalid URI\n");
return false;
@@ -485,12 +499,12 @@ parse_arc(ingen::World& world,
}
static bool
-parse_arcs(ingen::World& world,
- ingen::Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- const Sord::Node& subject,
- const raul::Path& graph)
+parse_arcs(ingen::World& world,
+ ingen::Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ const Sord::Node& subject,
+ const raul::Path& graph)
{
const Sord::URI ingen_arc(*world.rdf_world(), world.uris().ingen_arc);
const Sord::Node nil;
@@ -502,37 +516,43 @@ parse_arcs(ingen::World& world,
return true;
}
-static boost::optional<raul::Path>
-parse(ingen::World& world,
- ingen::Interface& target,
- Sord::Model& model,
- const URI& base_uri,
- Sord::Node& subject,
- const boost::optional<raul::Path>& parent,
- const boost::optional<raul::Symbol>& symbol,
- const boost::optional<Properties>& data)
+static std::optional<raul::Path>
+parse(ingen::World& world,
+ ingen::Interface& target,
+ Sord::Model& model,
+ const URI& base_uri,
+ Sord::Node& subject,
+ const std::optional<raul::Path>& parent,
+ const std::optional<raul::Symbol>& symbol,
+ const std::optional<Properties>& data)
{
const URIs& uris = world.uris();
- const Sord::URI graph_class (*world.rdf_world(), uris.ingen_Graph);
- const Sord::URI block_class (*world.rdf_world(), uris.ingen_Block);
- const Sord::URI arc_class (*world.rdf_world(), uris.ingen_Arc);
+ const Sord::URI graph_class(*world.rdf_world(), uris.ingen_Graph);
+ const Sord::URI block_class(*world.rdf_world(), uris.ingen_Block);
+ const Sord::URI arc_class(*world.rdf_world(), uris.ingen_Arc);
const Sord::URI internal_class(*world.rdf_world(), uris.ingen_Internal);
- const Sord::URI in_port_class (*world.rdf_world(), LV2_CORE__InputPort);
+ const Sord::URI in_port_class(*world.rdf_world(), LV2_CORE__InputPort);
const Sord::URI out_port_class(*world.rdf_world(), LV2_CORE__OutputPort);
- const Sord::URI lv2_class (*world.rdf_world(), LV2_CORE__Plugin);
- const Sord::URI rdf_type (*world.rdf_world(), uris.rdf_type);
+ const Sord::URI lv2_class(*world.rdf_world(), LV2_CORE__Plugin);
+ const Sord::URI rdf_type(*world.rdf_world(), uris.rdf_type);
const Sord::Node nil;
// Parse explicit subject graph
if (subject.is_valid()) {
- return parse_graph(world, target, model, base_uri,
- subject, Resource::Graph::INTERNAL,
- parent, symbol, data);
+ return parse_graph(world,
+ target,
+ model,
+ base_uri,
+ subject,
+ Resource::Graph::INTERNAL,
+ parent,
+ symbol,
+ data);
}
// Get all subjects and their types (?subject a ?type)
- using Subjects = std::map< Sord::Node, std::set<Sord::Node> >;
+ using Subjects = std::map<Sord::Node, std::set<Sord::Node>>;
Subjects subjects;
for (auto i = model.find(subject, rdf_type, nil); !i.end(); ++i) {
const Sord::Node& rdf_class = i.get_object();
@@ -552,25 +572,31 @@ parse(ingen::World& world,
for (const auto& i : subjects) {
const Sord::Node& s = i.first;
const std::set<Sord::Node>& types = i.second;
- boost::optional<raul::Path> ret;
+ std::optional<raul::Path> ret;
if (types.find(graph_class) != types.end()) {
- ret = parse_graph(world, target, model, base_uri,
- s, Resource::Graph::INTERNAL,
- parent, symbol, data);
+ ret = parse_graph(world,
+ target,
+ model,
+ base_uri,
+ s,
+ Resource::Graph::INTERNAL,
+ parent,
+ symbol,
+ data);
} else if (types.find(block_class) != types.end()) {
- const raul::Path rel_path(*get_path(base_uri, s));
+ const raul::Path rel_path{*get_path(base_uri, s)};
const raul::Path path = parent ? parent->child(rel_path) : rel_path;
ret = parse_block(world, target, model, base_uri, s, path, data);
} else if (types.find(in_port_class) != types.end() ||
types.find(out_port_class) != types.end()) {
- const raul::Path rel_path(*get_path(base_uri, s));
+ const raul::Path rel_path{*get_path(base_uri, s)};
const raul::Path path = parent ? parent->child(rel_path) : rel_path;
- const Properties properties = get_properties(
- world, model, s, Resource::Graph::DEFAULT, data);
+ const Properties properties =
+ get_properties(world, model, s, Resource::Graph::DEFAULT, data);
target.put(path_to_uri(path), properties);
ret = path;
} else if (types.find(arc_class) != types.end()) {
- raul::Path parent_path(parent ? parent.get() : raul::Path("/"));
+ const raul::Path parent_path{parent ? parent.value() : raul::Path("/")};
parse_arc(world, target, model, base_uri, s, parent_path);
} else {
world.log().error("Subject has no known types\n");
@@ -581,48 +607,47 @@ parse(ingen::World& world,
}
bool
-Parser::parse_file(ingen::World& world,
- ingen::Interface& target,
- const FilePath& path,
- const boost::optional<raul::Path>& parent,
- const boost::optional<raul::Symbol>& symbol,
- const boost::optional<Properties>& data)
+Parser::parse_file(ingen::World& world,
+ ingen::Interface& target,
+ const FilePath& path,
+ const std::optional<raul::Path>& parent,
+ const std::optional<raul::Symbol>& symbol,
+ const std::optional<Properties>& data)
{
// Get absolute file path
FilePath file_path = path;
if (!file_path.is_absolute()) {
- file_path = filesystem::current_path() / file_path;
+ file_path = std::filesystem::current_path() / file_path;
}
// Find file to use as manifest
- const bool is_bundle = filesystem::is_directory(file_path);
+ const bool is_bundle = std::filesystem::is_directory(file_path);
const FilePath manifest_path =
- (is_bundle ? file_path / "manifest.ttl" : file_path);
+ (is_bundle ? file_path / "manifest.ttl" : file_path);
- URI manifest_uri(manifest_path);
+ const URI manifest_uri{manifest_path};
// Find graphs in manifest
- const std::set<ResourceRecord> resources = find_resources(
- *world.rdf_world(), manifest_uri, URI(INGEN__Graph));
+ const std::set<ResourceRecord> resources =
+ find_resources(*world.rdf_world(), manifest_uri, URI(INGEN__Graph));
if (resources.empty()) {
world.log().error("No graphs found in %1%\n", path);
return false;
}
- /* Choose the graph to load. If this is a manifest, then there should only be
- one, but if this is a graph file, subgraphs will be returned as well.
- In this case, choose the one with the file URI. */
- URI uri;
- for (const ResourceRecord& r : resources) {
- if (r.uri == URI(manifest_path)) {
- uri = r.uri;
- file_path = r.filename;
- break;
- }
- }
+ // Try to find the graph with the manifest path for a URI
+ const auto m = std::find_if(resources.begin(),
+ resources.end(),
+ [manifest_path](const auto& r) {
+ return r.uri == URI(manifest_path);
+ });
- if (uri.empty()) {
+ URI uri;
+ if (m != resources.end()) {
+ uri = m->uri;
+ file_path = m->filename;
+ } else {
// Didn't find a graph with the same URI as the file, use the first
uri = (*resources.begin()).uri;
file_path = (*resources.begin()).filename;
@@ -634,13 +659,16 @@ Parser::parse_file(ingen::World& world,
}
// Initialise parsing environment
- const URI file_uri = URI(file_path);
- const auto* uri_c_str = reinterpret_cast<const uint8_t*>(uri.c_str());
- SerdNode base_node = serd_node_from_string(SERD_URI, uri_c_str);
- SerdEnv* env = serd_env_new(&base_node);
+ const URI file_uri = URI(file_path);
+ const auto* uri_c_str = reinterpret_cast<const uint8_t*>(uri.c_str());
+ const SerdNode base_node = serd_node_from_string(SERD_URI, uri_c_str);
+ SerdEnv* env = serd_env_new(&base_node);
// Load graph into model
- Sord::Model model(*world.rdf_world(), uri.string(), SORD_SPO|SORD_PSO, false);
+ Sord::Model model(*world.rdf_world(),
+ uri.string(),
+ SORD_SPO | SORD_PSO,
+ false);
model.load_file(env, SERD_TURTLE, file_uri);
serd_env_free(env);
@@ -653,9 +681,8 @@ Parser::parse_file(ingen::World& world,
}
Sord::Node subject(*world.rdf_world(), Sord::Node::URI, uri.string());
- boost::optional<raul::Path> parsed_path
- = parse(world, target, model, model.base_uri(),
- subject, parent, symbol, data);
+ std::optional<raul::Path> parsed_path = parse(
+ world, target, model, model.base_uri(), subject, parent, symbol, data);
if (parsed_path) {
target.set_property(path_to_uri(*parsed_path),
@@ -668,22 +695,22 @@ Parser::parse_file(ingen::World& world,
return false;
}
-boost::optional<URI>
-Parser::parse_string(ingen::World& world,
- ingen::Interface& target,
- const std::string& str,
- const URI& base_uri,
- const boost::optional<raul::Path>& parent,
- const boost::optional<raul::Symbol>& symbol,
- const boost::optional<Properties>& data)
+std::optional<URI>
+Parser::parse_string(ingen::World& world,
+ ingen::Interface& target,
+ const std::string& str,
+ const URI& base_uri,
+ const std::optional<raul::Path>& parent,
+ const std::optional<raul::Symbol>& symbol,
+ const std::optional<Properties>& data)
{
// Load string into model
- Sord::Model model(*world.rdf_world(), base_uri, SORD_SPO|SORD_PSO, false);
+ Sord::Model model(*world.rdf_world(), base_uri, SORD_SPO | SORD_PSO, false);
SerdEnv* env = serd_env_new(nullptr);
if (!base_uri.empty()) {
const SerdNode base = serd_node_from_string(
- SERD_URI, reinterpret_cast<const uint8_t*>(base_uri.c_str()));
+ SERD_URI, reinterpret_cast<const uint8_t*>(base_uri.c_str()));
serd_env_set_base_uri(env, &base);
}
model.load_string(env, SERD_TURTLE, str.c_str(), str.length(), base_uri);
diff --git a/src/Resource.cpp b/src/Resource.cpp
index 2171c438..29a82772 100644
--- a/src/Resource.cpp
+++ b/src/Resource.cpp
@@ -14,11 +14,13 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Resource.hpp"
+#include <ingen/Resource.hpp>
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URIs.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
#include <map>
#include <utility>
@@ -51,6 +53,8 @@ Resource::add_property(const URI& uri, const Atom& value, Graph ctx)
const Atom&
Resource::set_property(const URI& uri, const Atom& value, Resource::Graph ctx)
{
+ assert(uri != _uris.ingen_activity); // Always ephemeral
+
// Erase existing property in this context
for (auto i = _properties.find(uri);
(i != _properties.end()) && (i->first == uri);) {
@@ -64,16 +68,10 @@ Resource::set_property(const URI& uri, const Atom& value, Resource::Graph ctx)
i = next;
}
- if (uri != _uris.ingen_activity) {
- // Insert new property
- const Atom& v = _properties.emplace(uri, Property(value, ctx))->second;
- on_property(uri, v);
- return v;
- }
-
- // Announce ephemeral activity, but do not store
- on_property(uri, value);
- return value;
+ // Insert new property
+ const Atom& v = _properties.emplace(uri, Property(value, ctx))->second;
+ on_property(uri, v);
+ return v;
}
const Atom&
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp
index 21d8286f..785e12ba 100644
--- a/src/Serialiser.cpp
+++ b/src/Serialiser.cpp
@@ -14,41 +14,42 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Serialiser.hpp"
-
-#include "ingen/Arc.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/filesystem.hpp"
-#include "ingen/runtime_paths.hpp"
-#include "lv2/core/lv2.h"
-#include "lv2/state/state.h"
-#include "lv2/ui/ui.h"
-#include "lv2/urid/urid.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-#include "serd/serd.h"
-#include "sord/sord.h"
-#include "sord/sordmm.hpp"
-#include "sratom/sratom.h"
+#include <ingen/Serialiser.hpp>
+
+#include <ingen/Arc.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/ingen.h>
+#include <lv2/core/lv2.h>
+#include <lv2/state/state.h>
+#include <lv2/ui/ui.h>
+#include <lv2/urid/urid.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+#include <serd/serd.h>
+#include <sord/sord.h>
+#include <sord/sordmm.hpp>
+#include <sratom/sratom.h>
#include <cassert>
#include <cstdint>
#include <cstring>
-#include <map>
+#include <filesystem>
#include <memory>
#include <set>
#include <stdexcept>
#include <string>
+#include <string_view>
#include <utility>
namespace ingen {
@@ -118,7 +119,6 @@ Serialiser::Impl::write_manifest(const FilePath& bundle_path,
const std::shared_ptr<const Node>&)
{
const FilePath manifest_path(bundle_path / "manifest.ttl");
- const FilePath binary_path(ingen_module_path("lv2"));
start_to_file(raul::Path("/"), manifest_path);
@@ -190,19 +190,19 @@ Serialiser::Impl::write_bundle(const std::shared_ptr<const Node>& graph,
const URI& uri)
{
FilePath path(uri.path());
- if (filesystem::exists(path) && !filesystem::is_directory(path)) {
+ if (std::filesystem::exists(path) && !std::filesystem::is_directory(path)) {
path = path.parent_path();
}
_world.log().info("Writing bundle %1%\n", path);
- filesystem::create_directories(path);
+ std::filesystem::create_directories(path);
const FilePath main_file = path / "main.ttl";
const raul::Path old_root_path = _root_path;
start_to_file(graph->path(), main_file);
- std::set<const Resource*> plugins =
+ const std::set<const Resource*> plugins =
serialise_graph(graph,
Sord::URI(_model->world(), main_file, _base_uri));
@@ -258,7 +258,7 @@ Serialiser::Impl::finish()
{
std::string ret;
if (_mode == Mode::TO_FILE) {
- SerdStatus st = _model->write_to_file(_base_uri, SERD_TURTLE);
+ const SerdStatus st = _model->write_to_file(_base_uri, SERD_TURTLE);
if (st) {
_world.log().error("Error writing file %1% (%2%)\n",
_base_uri,
@@ -354,7 +354,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr<const Node>& graph,
}
if (n->second->graph_type() == Node::GraphType::GRAPH) {
- std::shared_ptr<Node> subgraph = n->second;
+ const std::shared_ptr<Node> subgraph = n->second;
SerdURI base_uri;
serd_uri_parse(reinterpret_cast<const uint8_t*>(_base_uri.c_str()),
@@ -375,7 +375,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr<const Node>& graph,
subgraph_node.buf));
// Save our state
- URI my_base_uri = _base_uri;
+ const URI my_base_uri = _base_uri;
Sord::Model* my_model = _model;
// Write child bundle within this bundle
@@ -394,7 +394,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr<const Node>& graph,
serd_node_free(&subgraph_node);
} else if (n->second->graph_type() == Node::GraphType::BLOCK) {
- std::shared_ptr<const Node> block = n->second;
+ const std::shared_ptr<const Node> block = n->second;
const Sord::URI class_id(world, block->plugin()->uri());
const Sord::Node block_id(path_rdf_node(n->second->path()));
@@ -454,7 +454,7 @@ Serialiser::Impl::serialise_block(const std::shared_ptr<const Node>& block,
if (_base_uri.scheme() == "file") {
const FilePath base_path = _base_uri.file_path();
const FilePath graph_dir = base_path.parent_path();
- const FilePath state_dir = graph_dir / block->symbol();
+ const FilePath state_dir = graph_dir / std::string(block->symbol());
const FilePath state_file = state_dir / "state.ttl";
if (block->save_state(state_dir)) {
_model->add_statement(block_id,
@@ -478,7 +478,7 @@ Serialiser::Impl::serialise_port(const Node* port,
Resource::Graph context,
const Sord::Node& port_id)
{
- URIs& uris = _world.uris();
+ const URIs& uris = _world.uris();
Sord::World& world = _model->world();
Properties props = port->properties(context);
@@ -515,7 +515,7 @@ void
Serialiser::serialise_arc(const Sord::Node& parent,
const std::shared_ptr<const Arc>& arc)
{
- return me->serialise_arc(parent, arc);
+ me->serialise_arc(parent, arc);
}
void
@@ -556,9 +556,8 @@ void
Serialiser::Impl::serialise_properties(Sord::Node id, const Properties& props)
{
LV2_URID_Unmap* unmap = &_world.uri_map().urid_unmap();
- SerdNode base = serd_node_from_string(SERD_URI,
- reinterpret_cast<const uint8_t*>(
- _base_uri.c_str()));
+ const SerdNode base = serd_node_from_string(
+ SERD_URI, reinterpret_cast<const uint8_t*>(_base_uri.c_str()));
SerdEnv* env = serd_env_new(&base);
SordInserter* inserter = sord_inserter_new(_model->c_obj(), env);
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp
index 83854bf9..5499fb66 100644
--- a/src/SocketReader.cpp
+++ b/src/SocketReader.cpp
@@ -14,18 +14,18 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/SocketReader.hpp"
-
-#include "ingen/AtomForge.hpp"
-#include "ingen/AtomReader.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/World.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Socket.hpp"
-#include "serd/serd.h"
-#include "sord/sord.h"
-#include "sord/sordmm.hpp"
+#include <ingen/SocketReader.hpp>
+
+#include <ingen/AtomForge.hpp>
+#include <ingen/AtomReader.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/World.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/Socket.hpp>
+#include <serd/serd.h>
+#include <sord/sord.h>
+#include <sord/sordmm.hpp>
#include <cerrno>
#include <cstdint>
@@ -33,6 +33,7 @@
#include <mutex>
#include <poll.h>
#include <sys/socket.h>
+#include <sys/types.h>
#include <utility>
namespace ingen {
@@ -123,7 +124,7 @@ SocketReader::run()
AtomForge forge(map);
{
// Lock RDF world
- std::lock_guard<std::mutex> lock(_world.rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_world.rdf_mutex()};
// Use <ingen:/> as base URI, so relative URIs are like bundle paths
base_uri = sord_new_uri(world->c_obj(),
@@ -174,10 +175,10 @@ SocketReader::run()
}
// Lock RDF world
- std::lock_guard<std::mutex> lock(_world.rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_world.rdf_mutex()};
// Read until the next '.'
- SerdStatus st = serd_reader_read_chunk(reader);
+ const SerdStatus st = serd_reader_read_chunk(reader);
if (st == SERD_FAILURE || !_msg_node) {
continue; // Read nothing, e.g. just whitespace
}
@@ -200,7 +201,7 @@ SocketReader::run()
}
// Lock RDF world
- std::lock_guard<std::mutex> lock(_world.rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_world.rdf_mutex()};
// Destroy everything
sord_inserter_free(_inserter);
diff --git a/src/SocketWriter.cpp b/src/SocketWriter.cpp
index c705ed96..7512ecbd 100644
--- a/src/SocketWriter.cpp
+++ b/src/SocketWriter.cpp
@@ -14,16 +14,18 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/SocketWriter.hpp"
+#include <ingen/SocketWriter.hpp>
-#include "ingen/URI.hpp"
-#include "raul/Socket.hpp"
-
-#include <boost/variant/get.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/TurtleWriter.hpp>
+#include <ingen/URI.hpp>
+#include <raul/Socket.hpp>
#include <memory>
#include <sys/socket.h>
+#include <sys/types.h>
#include <utility>
+#include <variant>
#ifndef MSG_NOSIGNAL
# define MSG_NOSIGNAL 0
@@ -43,7 +45,7 @@ void
SocketWriter::message(const Message& message)
{
TurtleWriter::message(message);
- if (boost::get<BundleEnd>(&message)) {
+ if (std::get_if<BundleEnd>(&message)) {
// Send a null byte to indicate end of bundle
const char end[] = { 0 };
send(_socket->fd(), end, 1, MSG_NOSIGNAL);
@@ -53,7 +55,7 @@ SocketWriter::message(const Message& message)
size_t
SocketWriter::text_sink(const void* buf, size_t len)
{
- ssize_t ret = send(_socket->fd(), buf, len, MSG_NOSIGNAL);
+ const ssize_t ret = send(_socket->fd(), buf, len, MSG_NOSIGNAL);
if (ret < 0) {
return 0;
}
diff --git a/src/Store.cpp b/src/Store.cpp
index d85d5932..ab8425cb 100644
--- a/src/Store.cpp
+++ b/src/Store.cpp
@@ -14,11 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Store.hpp"
+#include <ingen/Store.hpp>
-#include "ingen/Node.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Node.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <cstdint>
diff --git a/src/StreamWriter.cpp b/src/StreamWriter.cpp
index d8a93a0b..c40389e4 100644
--- a/src/StreamWriter.cpp
+++ b/src/StreamWriter.cpp
@@ -14,10 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/StreamWriter.hpp"
+#include <ingen/StreamWriter.hpp>
-#include "ingen/ColorContext.hpp"
-#include "ingen/URI.hpp"
+#include <ingen/ColorContext.hpp>
+#include <ingen/TurtleWriter.hpp>
+#include <ingen/URI.hpp>
namespace ingen {
@@ -34,7 +35,7 @@ StreamWriter::StreamWriter(URIMap& map,
size_t
StreamWriter::text_sink(const void* buf, size_t len)
{
- ColorContext ctx(_stream, _color);
+ const ColorContext ctx{_stream, _color};
return fwrite(buf, 1, len, _stream);
}
diff --git a/src/TurtleWriter.cpp b/src/TurtleWriter.cpp
index 1f5b0529..e19c14e2 100644
--- a/src/TurtleWriter.cpp
+++ b/src/TurtleWriter.cpp
@@ -14,11 +14,15 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/TurtleWriter.hpp"
-
-#include "ingen/URIMap.hpp"
-#include "lv2/atom/atom.h"
-#include "serd/serd.h"
+#include <ingen/TurtleWriter.hpp>
+
+#include <ingen/AtomWriter.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/ingen.h>
+#include <lv2/atom/atom.h>
+#include <serd/serd.h>
+#include <sratom/sratom.h>
#include <utility>
diff --git a/src/URI.cpp b/src/URI.cpp
index cc40a9a3..3161b7d2 100644
--- a/src/URI.cpp
+++ b/src/URI.cpp
@@ -14,20 +14,17 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/URI.hpp"
+#include <ingen/URI.hpp>
-#include "ingen/FilePath.hpp"
-#include "serd/serd.h"
-#include "sord/sordmm.hpp"
+#include <ingen/FilePath.hpp>
+#include <serd/serd.h>
+#include <sord/sordmm.hpp>
#include <cassert>
namespace ingen {
-URI::URI()
- : _uri(SERD_URI_NULL)
- , _node(SERD_NODE_NULL)
-{}
+URI::URI() : _uri(SERD_URI_NULL), _node(SERD_NODE_NULL) {}
URI::URI(const std::string& str)
: _uri(SERD_URI_NULL)
@@ -35,14 +32,16 @@ URI::URI(const std::string& str)
str.c_str()),
nullptr,
&_uri))
-{}
+{
+}
URI::URI(const char* str)
: _uri(SERD_URI_NULL)
, _node(serd_node_new_uri_from_string(reinterpret_cast<const uint8_t*>(str),
nullptr,
&_uri))
-{}
+{
+}
URI::URI(const std::string& str, const URI& base)
: _uri(SERD_URI_NULL)
@@ -50,25 +49,22 @@ URI::URI(const std::string& str, const URI& base)
str.c_str()),
&base._uri,
&_uri))
-{}
+{
+}
-URI::URI(SerdNode node)
- : _uri(SERD_URI_NULL)
- , _node(serd_node_new_uri_from_node(&node, nullptr, &_uri))
+URI::URI(const SerdNode& node)
+ : _uri(SERD_URI_NULL)
+ , _node(serd_node_new_uri_from_node(&node, nullptr, &_uri))
{
assert(node.type == SERD_URI);
}
-URI::URI(SerdNode node, SerdURI uri)
- : _uri(uri)
- , _node(node)
+URI::URI(const SerdNode& node, const SerdURI& uri) : _uri(uri), _node(node)
{
assert(node.type == SERD_URI);
}
-URI::URI(const Sord::Node& node)
- : URI(*node.to_serd_node())
-{}
+URI::URI(const Sord::Node& node) : URI(*node.to_serd_node()) {}
URI::URI(const FilePath& path)
: _uri(SERD_URI_NULL)
@@ -77,12 +73,13 @@ URI::URI(const FilePath& path)
nullptr,
&_uri,
true))
-{}
+{
+}
URI::URI(const URI& uri)
- : _uri(SERD_URI_NULL)
- , _node(serd_node_new_uri(&uri._uri, nullptr, &_uri))
-{}
+ : _uri(SERD_URI_NULL), _node(serd_node_new_uri(&uri._uri, nullptr, &_uri))
+{
+}
URI&
URI::operator=(const URI& uri)
@@ -95,9 +92,7 @@ URI::operator=(const URI& uri)
return *this;
}
-URI::URI(URI&& uri) noexcept
- : _uri(uri._uri)
- , _node(uri._node)
+URI::URI(URI&& uri) noexcept : _uri(uri._uri), _node(uri._node)
{
uri._node = SERD_NODE_NULL;
uri._uri = SERD_URI_NULL;
@@ -123,8 +118,20 @@ URI::~URI()
URI
URI::make_relative(const URI& base) const
{
- SerdURI uri;
- SerdNode node = serd_node_new_relative_uri(&_uri, &base._uri, nullptr, &uri);
+ SerdURI uri;
+ const SerdNode node =
+ serd_node_new_relative_uri(&_uri, &base._uri, nullptr, &uri);
+
+ return {node, uri};
+}
+
+URI
+URI::make_relative(const URI& base, const URI& root) const
+{
+ SerdURI uri;
+ const SerdNode node =
+ serd_node_new_relative_uri(&_uri, &base._uri, &root._uri, &uri);
+
return {node, uri};
}
diff --git a/src/URIMap.cpp b/src/URIMap.cpp
index 0d6654a5..25764762 100644
--- a/src/URIMap.cpp
+++ b/src/URIMap.cpp
@@ -14,11 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/URIMap.hpp"
+#include <ingen/URIMap.hpp>
-#include "ingen/Log.hpp"
-#include "ingen/URI.hpp"
-#include "lv2/urid/urid.h"
+#include <ingen/Log.hpp>
+#include <ingen/URI.hpp>
+#include <lv2/urid/urid.h>
#include <cassert>
#include <cstdint>
@@ -50,9 +50,9 @@ LV2_URID
URIMap::URIDMapFeature::default_map(LV2_URID_Map_Handle h,
const char* c_uri)
{
- auto* const map(static_cast<URIMap*>(h));
- std::string uri(c_uri);
- std::lock_guard<std::mutex> lock(map->_mutex);
+ auto* const map{static_cast<URIMap*>(h)};
+ std::string uri{c_uri};
+ const std::lock_guard<std::mutex> lock{map->_mutex};
auto record = map->_map.emplace(uri, map->_map.size() + 1);
const auto id = record.first->second;
@@ -92,8 +92,8 @@ const char*
URIMap::URIDUnmapFeature::default_unmap(LV2_URID_Unmap_Handle h,
LV2_URID urid)
{
- auto* const map(static_cast<URIMap*>(h));
- std::lock_guard<std::mutex> lock(map->_mutex);
+ auto* const map{static_cast<URIMap*>(h)};
+ const std::lock_guard<std::mutex> lock{map->_mutex};
return (urid > 0 && urid <= map->_unmap.size()
? map->_unmap[urid - 1].c_str()
diff --git a/src/URIs.cpp b/src/URIs.cpp
index 41706868..49eb1707 100644
--- a/src/URIs.cpp
+++ b/src/URIs.cpp
@@ -14,25 +14,27 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/URIs.hpp"
+#include <ingen/URIs.hpp>
-#include "ingen/Forge.hpp"
-#include "ingen/ingen.h"
-#include "lv2/atom/atom.h"
-#include "lv2/buf-size/buf-size.h"
-#include "lv2/core/lv2.h"
-#include "lv2/log/log.h"
-#include "lv2/midi/midi.h"
-#include "lv2/morph/morph.h"
-#include "lv2/options/options.h"
-#include "lv2/parameters/parameters.h"
-#include "lv2/patch/patch.h"
-#include "lv2/port-props/port-props.h"
-#include "lv2/presets/presets.h"
-#include "lv2/resize-port/resize-port.h"
-#include "lv2/state/state.h"
-#include "lv2/time/time.h"
-#include "lv2/worker/worker.h"
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/ingen.h>
+#include <lilv/lilv.h>
+#include <lv2/atom/atom.h>
+#include <lv2/buf-size/buf-size.h>
+#include <lv2/core/lv2.h>
+#include <lv2/log/log.h>
+#include <lv2/midi/midi.h>
+#include <lv2/morph/morph.h>
+#include <lv2/options/options.h>
+#include <lv2/parameters/parameters.h>
+#include <lv2/patch/patch.h>
+#include <lv2/port-props/port-props.h>
+#include <lv2/presets/presets.h>
+#include <lv2/resize-port/resize-port.h>
+#include <lv2/state/state.h>
+#include <lv2/time/time.h>
+#include <lv2/worker/worker.h>
namespace ingen {
diff --git a/src/World.cpp b/src/World.cpp
index e2db1a57..7e643002 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -14,32 +14,32 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/World.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/DataAccess.hpp"
-#include "ingen/EngineBase.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/InstanceAccess.hpp"
-#include "ingen/LV2Features.hpp"
-#include "ingen/Library.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Module.hpp"
-#include "ingen/Parser.hpp"
-#include "ingen/Serialiser.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/ingen.h"
-#include "ingen/runtime_paths.hpp"
-#include "lilv/lilv.h"
-#include "lv2/log/log.h"
-#include "lv2/urid/urid.h"
-#include "sord/sordmm.hpp"
+#include <ingen/World.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/DataAccess.hpp>
+#include <ingen/EngineBase.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/InstanceAccess.hpp>
+#include <ingen/LV2Features.hpp>
+#include <ingen/Library.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Module.hpp>
+#include <ingen/Parser.hpp>
+#include <ingen/Serialiser.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/ingen.h>
+#include <ingen/runtime_paths.hpp>
+#include <lilv/lilv.h>
+#include <lv2/log/log.h>
+#include <lv2/urid/urid.h>
+#include <sord/sordmm.hpp>
#include <cstdint>
+#include <filesystem>
#include <list>
#include <map>
#include <memory>
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp
index aa4ef663..beef0117 100644
--- a/src/client/BlockModel.cpp
+++ b/src/client/BlockModel.cpp
@@ -14,18 +14,23 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/BlockModel.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "lilv/lilv.h"
-#include "lv2/core/lv2.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-
+#include <ingen/client/BlockModel.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <lilv/lilv.h>
+#include <lv2/core/lv2.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+
+#include <sigc++/signal.h>
+
+#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
@@ -34,8 +39,7 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace client {
+namespace ingen::client {
BlockModel::BlockModel(URIs& uris,
const std::shared_ptr<PluginModel>& plugin,
@@ -75,23 +79,26 @@ BlockModel::~BlockModel()
void
BlockModel::remove_port(const std::shared_ptr<PortModel>& port)
{
- for (auto i = _ports.begin(); i != _ports.end(); ++i) {
- if ((*i) == port) {
- _ports.erase(i);
- break;
- }
+ const auto i = std::find_if(_ports.begin(),
+ _ports.end(),
+ [&port](const auto& p) { return p == port; });
+
+ if (i != _ports.end()) {
+ _ports.erase(i);
+ _signal_removed_port.emit(port);
}
- _signal_removed_port.emit(port);
}
void
BlockModel::remove_port(const raul::Path& port_path)
{
- for (auto i = _ports.begin(); i != _ports.end(); ++i) {
- if ((*i)->path() == port_path) {
- _ports.erase(i);
- break;
- }
+ const auto i =
+ std::find_if(_ports.begin(), _ports.end(), [&port_path](const auto& p) {
+ return p->path() == port_path;
+ });
+
+ if (i != _ports.end()) {
+ _ports.erase(i);
}
}
@@ -203,8 +210,9 @@ BlockModel::default_port_value_range(
}
if (port->port_property(_uris.lv2_sampleRate)) {
- min *= srate;
- max *= srate;
+ const auto frate = static_cast<float>(srate);
+ min *= frate;
+ max *= frate;
}
}
@@ -218,7 +226,7 @@ BlockModel::port_value_range(const std::shared_ptr<const PortModel>& port,
default_port_value_range(port, min, max);
- // Possibly overriden
+ // Possibly overridden
const Atom& min_atom = port->get_property(_uris.lv2_minimum);
const Atom& max_atom = port->get_property(_uris.lv2_maximum);
if (min_atom.type() == _uris.forge.Float) {
@@ -233,8 +241,9 @@ BlockModel::port_value_range(const std::shared_ptr<const PortModel>& port,
}
if (port->port_property(_uris.lv2_sampleRate)) {
- min *= srate;
- max *= srate;
+ const auto frate = static_cast<float>(srate);
+ min *= frate;
+ max *= frate;
}
}
@@ -292,5 +301,4 @@ BlockModel::set(const std::shared_ptr<ObjectModel>& model)
ObjectModel::set(model);
}
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index 80143265..9f224db3 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -14,26 +14,28 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/ClientStore.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ArcModel.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "ingen/client/SigClientInterface.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-
-#include <boost/variant/apply_visitor.hpp>
+#include <ingen/client/ClientStore.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ArcModel.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <ingen/client/SigClientInterface.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <sigc++/signal.h>
+
#include <sigc++/functors/mem_fun.h>
#include <cassert>
@@ -41,9 +43,9 @@
#include <memory>
#include <string>
#include <utility>
+#include <variant>
-namespace ingen {
-namespace client {
+namespace ingen::client {
ClientStore::ClientStore(URIs& uris,
Log& log,
@@ -76,12 +78,12 @@ ClientStore::add_object(const std::shared_ptr<ObjectModel>& object)
std::dynamic_pointer_cast<ObjectModel>(existing->second)->set(object);
} else {
if (!object->path().is_root()) {
- std::shared_ptr<ObjectModel> parent = _object(object->path().parent());
+ const std::shared_ptr<ObjectModel> parent = _object(object->path().parent());
if (parent) {
assert(object->path().is_child_of(parent->path()));
object->set_parent(parent);
parent->add_child(object);
- assert(parent && (object->parent() == parent));
+ assert(object->parent() == parent);
(*this)[object->path()] = object;
_signal_new_object.emit(object);
@@ -201,7 +203,7 @@ ClientStore::resource(const URI& uri) const
void
ClientStore::add_plugin(const std::shared_ptr<PluginModel>& pm)
{
- std::shared_ptr<PluginModel> existing = _plugin(pm->uri());
+ const std::shared_ptr<PluginModel> existing = _plugin(pm->uri());
if (existing) {
existing->set(pm);
} else {
@@ -244,7 +246,7 @@ ClientStore::operator()(const Move& msg)
void
ClientStore::message(const Message& msg)
{
- boost::apply_visitor(*this, msg);
+ std::visit(*this, msg);
}
void
@@ -286,7 +288,7 @@ ClientStore::operator()(const Put& msg)
if (_uris.ingen_Graph == type) {
is_graph = true;
} else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) {
- std::shared_ptr<PluginModel> p(new PluginModel(uris(), uri, type, properties));
+ const std::shared_ptr<PluginModel> p{new PluginModel(uris(), uri, type, properties)};
add_plugin(p);
return;
}
@@ -310,7 +312,7 @@ ClientStore::operator()(const Put& msg)
}
if (is_graph) {
- std::shared_ptr<GraphModel> model(new GraphModel(uris(), path));
+ const std::shared_ptr<GraphModel> model{new GraphModel(uris(), path)};
model->set_properties(properties);
add_object(model);
} else if (is_block) {
@@ -331,14 +333,14 @@ ClientStore::operator()(const Put& msg)
add_plugin(plug);
}
- std::shared_ptr<BlockModel> bm(new BlockModel(uris(), plug, path));
+ const std::shared_ptr<BlockModel> bm{new BlockModel(uris(), plug, path)};
bm->set_properties(properties);
add_object(bm);
} else {
_log.warn("Block %1% has no prototype\n", path.c_str());
}
} else if (is_port) {
- PortModel::Direction pdir = (is_output)
+ const PortModel::Direction pdir = (is_output)
? PortModel::Direction::OUTPUT
: PortModel::Direction::INPUT;
uint32_t index = 0;
@@ -347,7 +349,7 @@ ClientStore::operator()(const Put& msg)
index = i->second.get<int32_t>();
}
- std::shared_ptr<PortModel> p(new PortModel(uris(), path, index, pdir));
+ const std::shared_ptr<PortModel> p{new PortModel(uris(), path, index, pdir)};
p->set_properties(properties);
add_object(p);
} else {
@@ -371,7 +373,7 @@ ClientStore::operator()(const Delta& msg)
const raul::Path path(uri_to_path(uri));
- std::shared_ptr<ObjectModel> obj = _object(path);
+ const std::shared_ptr<ObjectModel> obj = _object(path);
if (obj) {
obj->remove_properties(msg.remove);
obj->add_properties(msg.add);
@@ -392,7 +394,7 @@ ClientStore::operator()(const SetProperty& msg)
predicate.c_str(), _uris.forge.str(value, false));
return;
}
- std::shared_ptr<Resource> subject = _resource(subject_uri);
+ const std::shared_ptr<Resource> subject = _resource(subject_uri);
if (subject) {
if (predicate == _uris.ingen_activity) {
/* Activity is transient, trigger any live actions (like GUI
@@ -402,7 +404,7 @@ ClientStore::operator()(const SetProperty& msg)
subject->set_property(predicate, value, msg.ctx);
}
} else {
- std::shared_ptr<PluginModel> plugin = _plugin(subject_uri);
+ const std::shared_ptr<PluginModel> plugin = _plugin(subject_uri);
if (plugin) {
plugin->set_property(predicate, value);
} else if (predicate != _uris.ingen_activity) {
@@ -450,8 +452,8 @@ ClientStore::attempt_connection(const raul::Path& tail_path,
auto head = std::dynamic_pointer_cast<PortModel>(_object(head_path));
if (tail && head) {
- std::shared_ptr<GraphModel> graph = connection_graph(tail_path, head_path);
- std::shared_ptr<ArcModel> arc(new ArcModel(tail, head));
+ const std::shared_ptr<GraphModel> graph = connection_graph(tail_path, head_path);
+ const std::shared_ptr<ArcModel> arc(new ArcModel(tail, head));
graph->add_arc(arc);
return true;
}
@@ -501,5 +503,4 @@ ClientStore::operator()(const DisconnectAll& msg)
}
}
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp
index a8a40ec7..fe119361 100644
--- a/src/client/GraphModel.cpp
+++ b/src/client/GraphModel.cpp
@@ -14,15 +14,17 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/GraphModel.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ArcModel.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "raul/Path.hpp"
+#include <ingen/client/GraphModel.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ArcModel.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <raul/Path.hpp>
+#include <sigc++/signal.h>
#include <cassert>
#include <map>
@@ -31,7 +33,15 @@
#include <utility>
namespace ingen {
-namespace client {
+class Node;
+} // namespace ingen
+
+namespace ingen::client {
+
+GraphModel::GraphModel(URIs& uris, const raul::Path& graph_path)
+ : BlockModel{uris, static_cast<const URI&>(uris.ingen_Graph), graph_path}
+{
+}
void
GraphModel::add_child(const std::shared_ptr<ObjectModel>& c)
@@ -135,7 +145,7 @@ GraphModel::add_arc(const std::shared_ptr<ArcModel>& arc)
assert(arc->head()->parent().get() == this
|| arc->head()->parent()->parent().get() == this);
- std::shared_ptr<ArcModel> existing = get_arc(
+ const std::shared_ptr<ArcModel> existing = get_arc(
arc->tail().get(), arc->head().get());
if (existing) {
@@ -174,12 +184,4 @@ GraphModel::internal_poly() const
return poly.is_valid() ? poly.get<int32_t>() : 1;
}
-bool
-GraphModel::polyphonic() const
-{
- const Atom& poly = get_property(_uris.ingen_polyphonic);
- return poly.is_valid() && poly.get<int32_t>();
-}
-
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp
index 9db429c5..4baa895c 100644
--- a/src/client/ObjectModel.cpp
+++ b/src/client/ObjectModel.cpp
@@ -14,14 +14,17 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/ObjectModel.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/paths.hpp"
+#include <ingen/client/ObjectModel.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+#include <sigc++/signal.h>
#include <cassert>
#include <cstdint>
@@ -29,8 +32,7 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace client {
+namespace ingen::client {
ObjectModel::ObjectModel(URIs& uris, const raul::Path& path)
: Node(uris, path)
@@ -113,5 +115,4 @@ ObjectModel::set_parent(const std::shared_ptr<ObjectModel>& p)
_parent = p;
}
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index 306846ee..f4dfccd2 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -14,13 +14,19 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/PluginModel.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/client/PluginUI.hpp"
-#include "lv2/core/lv2.h"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/client/PluginModel.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/PluginUI.hpp>
+#include <lilv/lilv.h>
+#include <lv2/core/lv2.h>
+#include <raul/Symbol.hpp>
+#include <sigc++/signal.h>
#include <cctype>
#include <cstring>
@@ -30,8 +36,7 @@
using std::string;
-namespace ingen {
-namespace client {
+namespace ingen::client {
LilvWorld* PluginModel::_lilv_world = nullptr;
const LilvPlugins* PluginModel::_lilv_plugins = nullptr;
@@ -104,43 +109,43 @@ PluginModel::get_property(const URI& key) const
size_t last_delim = last_uri_delim(str);
while (last_delim != string::npos &&
!contains_alpha_after(str, last_delim)) {
- str = str.substr(0, last_delim);
+ str.resize(last_delim);
last_delim = last_uri_delim(str);
}
str = str.substr(last_delim + 1);
- std::string symbol = raul::Symbol::symbolify(str);
+ const std::string symbol = raul::Symbol::symbolify(str);
set_property(_uris.lv2_symbol, _uris.forge.alloc(symbol));
return get_property(key);
}
if (_lilv_plugin) {
- boost::optional<const Atom&> ret;
- LilvNode* lv2_pred = lilv_new_uri(_lilv_world, key.c_str());
- LilvNodes* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred);
+ const Atom* ret = nullptr;
+ LilvNode* lv2_pred = lilv_new_uri(_lilv_world, key.c_str());
+ LilvNodes* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred);
lilv_node_free(lv2_pred);
LILV_FOREACH (nodes, i, values) {
const LilvNode* value = lilv_nodes_get(values, i);
if (lilv_node_is_uri(value)) {
- ret = set_property(
+ ret = &set_property(
key, _uris.forge.make_urid(URI(lilv_node_as_uri(value))));
break;
}
if (lilv_node_is_string(value)) {
- ret = set_property(
+ ret = &set_property(
key, _uris.forge.alloc(lilv_node_as_string(value)));
break;
}
if (lilv_node_is_float(value)) {
- ret = set_property(
+ ret = &set_property(
key, _uris.forge.make(lilv_node_as_float(value)));
break;
}
if (lilv_node_is_int(value)) {
- ret = set_property(
+ ret = &set_property(
key, _uris.forge.make(lilv_node_as_int(value)));
break;
}
@@ -361,5 +366,4 @@ PluginModel::set_lilv_world(LilvWorld* world)
_lilv_plugins = lilv_world_get_all_plugins(_lilv_world);
}
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp
index 031caceb..c4aa748f 100644
--- a/src/client/PluginUI.cpp
+++ b/src/client/PluginUI.cpp
@@ -14,20 +14,24 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/PluginUI.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/core/lv2.h"
-#include "lv2/ui/ui.h"
-#include "raul/Symbol.hpp"
+#include <ingen/client/PluginUI.hpp>
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/LV2Features.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <lilv/lilv.h>
+#include <lv2/atom/atom.h>
+#include <lv2/core/lv2.h>
+#include <lv2/ui/ui.h>
+#include <raul/Symbol.hpp>
+#include <suil/suil.h>
#include <sigc++/signal.h>
@@ -36,8 +40,7 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace client {
+namespace ingen::client {
SuilHost* PluginUI::ui_host = nullptr;
@@ -89,9 +92,9 @@ lv2_ui_write(SuilController controller,
} else if (format == uris.atom_eventTransfer.urid()) {
const auto* atom = static_cast<const LV2_Atom*>(buffer);
- Atom val = Forge::alloc(atom->size,
- atom->type,
- LV2_ATOM_BODY_CONST(atom));
+ const Atom val =
+ Forge::alloc(atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));
+
ui->signal_property_changed()(port->uri(),
uris.ingen_activity,
val,
@@ -123,8 +126,8 @@ lv2_ui_subscribe(SuilController controller,
uint32_t protocol,
const LV2_Feature* const* features)
{
- auto* const ui = static_cast<PluginUI*>(controller);
- std::shared_ptr<const PortModel> port = get_port(ui, port_index);
+ auto* const ui = static_cast<PluginUI*>(controller);
+ const std::shared_ptr<const PortModel> port = get_port(ui, port_index);
if (!port) {
return 1;
}
@@ -174,7 +177,7 @@ PluginUI::PluginUI(ingen::World& world,
PluginUI::~PluginUI()
{
- for (uint32_t i : _subscribed_ports) {
+ for (const uint32_t i : _subscribed_ports) {
lv2_ui_unsubscribe(this, i, 0, nullptr);
}
suil_instance_free(_instance);
@@ -260,7 +263,7 @@ PluginUI::instantiate()
plugin_uri, lilv_node_as_string(_ui_node));
} else if (!strcmp(lilv_node_as_uri(plug), plugin_uri.c_str())) {
// Notification is valid and for this plugin
- uint32_t index = lv2_ui_port_index(this, lilv_node_as_string(sym));
+ const uint32_t index = lv2_ui_port_index(this, lilv_node_as_string(sym));
if (index != LV2UI_INVALID_PORT_INDEX) {
lv2_ui_subscribe(this, index, 0, nullptr);
_subscribed_ports.insert(index);
@@ -294,7 +297,7 @@ PluginUI::instantiate()
if (!_instance) {
_world.log().error("Failed to instantiate LV2 UI\n");
// Cancel any subscriptions
- for (uint32_t i : _subscribed_ports) {
+ for (const uint32_t i : _subscribed_ports) {
lv2_ui_unsubscribe(this, i, 0, nullptr);
}
return false;
@@ -344,5 +347,4 @@ PluginUI::is_resizable() const
return !fs_matches && !nrs_matches;
}
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp
index 0d695a54..14a5297e 100644
--- a/src/client/PortModel.cpp
+++ b/src/client/PortModel.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -14,21 +14,22 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/client/PortModel.hpp"
+#include <ingen/client/PortModel.hpp>
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "lv2/urid/urid.h"
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <lv2/urid/urid.h>
+#include <sigc++/signal.h>
+#include <algorithm>
#include <cstdint>
+#include <exception>
#include <map>
#include <memory>
-#include <utility>
-namespace ingen {
-namespace client {
+namespace ingen::client {
void
PortModel::on_property(const URI& uri, const Atom& value)
@@ -61,14 +62,24 @@ PortModel::port_property(const URIs::Quark& uri) const
bool
PortModel::is_uri() const
{
- // FIXME: Resource::has_property doesn't work, URI != URID
- for (const auto& p : properties()) {
- if (p.second.type() == _uris.atom_URID &&
- static_cast<LV2_URID>(p.second.get<int32_t>()) == _uris.atom_URID) {
- return true;
- }
- }
- return false;
+ return std::any_of(
+ properties().begin(), properties().end(), [this](const auto& p) {
+ return (p.second.type() == _uris.atom_URID &&
+ static_cast<LV2_URID>(p.second.template get<int32_t>()) ==
+ _uris.atom_URID);
+ });
+}
+
+void
+PortModel::add_child(const std::shared_ptr<ObjectModel>&)
+{
+ std::terminate();
+}
+
+bool
+PortModel::remove_child(const std::shared_ptr<ObjectModel>&)
+{
+ std::terminate();
}
void
@@ -84,5 +95,4 @@ PortModel::set(const std::shared_ptr<ObjectModel>& model)
}
}
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
diff --git a/src/client/ingen_client.cpp b/src/client/ingen_client.cpp
index 63705ebc..88619115 100644
--- a/src/client/ingen_client.cpp
+++ b/src/client/ingen_client.cpp
@@ -14,20 +14,15 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Module.hpp"
+#include <ingen/Module.hpp>
-namespace ingen {
-
-class World;
-
-namespace client {
+namespace ingen::client {
struct ClientModule : public ingen::Module {
void load(ingen::World& world) override {}
};
-} // namespace client
-} // namespace ingen
+} // namespace ingen::client
extern "C" {
diff --git a/src/gui/.clang-tidy b/src/gui/.clang-tidy
index 5f6e0c3f..99bd2aba 100644
--- a/src/gui/.clang-tidy
+++ b/src/gui/.clang-tidy
@@ -1,4 +1,5 @@
Checks: >
+ -*-narrowing-conversions,
-android-cloexec-*,
-bugprone-branch-clone,
-bugprone-exception-escape,
@@ -14,7 +15,6 @@ Checks: >
-clang-analyzer-core.CallAndMessage,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-constant-array-index,
- -cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-static-cast-downcast,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-slicing,
@@ -24,6 +24,6 @@ Checks: >
-google-runtime-references,
-hicpp-multiway-paths-covered,
-hicpp-vararg,
- -modernize-avoid-bind,
+ -llvm-header-guard,
-readability-convert-member-functions-to-static,
InheritParentConfig: true
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index ff9636b9..260afdba 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -27,31 +27,37 @@
#include "WindowFactory.hpp"
#include "rgba.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/ColorContext.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/EngineBase.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/QueuedInterface.hpp"
-#include "ingen/StreamWriter.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "ingen/client/SigClientInterface.hpp"
-#include "ingen/runtime_paths.hpp"
-#include "lilv/lilv.h"
-#include "suil/suil.h"
-
-#include <boost/variant/get.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/ColorContext.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/EngineBase.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/QueuedInterface.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/StreamWriter.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <ingen/client/SigClientInterface.hpp>
+#include <ingen/fmt.hpp>
+#include <ingen/runtime_paths.hpp>
+#include <lilv/lilv.h>
+#include <lv2/urid/urid.h>
+#include <suil/suil.h>
+
#include <glib.h>
#include <glibmm/main.h>
#include <glibmm/miscutils.h>
#include <glibmm/propertyproxy.h>
+#include <glibmm/ustring.h>
#include <gtk/gtk.h>
#include <gtkmm/aboutdialog.h>
#include <gtkmm/dialog.h>
@@ -62,20 +68,21 @@
#include <gtkmm/stock.h>
#include <gtkmm/widget.h>
#include <sigc++/functors/mem_fun.h>
+#include <sigc++/functors/slot.h>
#include <algorithm>
#include <cassert>
+#include <cstdarg>
#include <cstdio>
#include <exception>
-#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <utility>
+#include <variant>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
Gtk::Main* App::_main = nullptr;
@@ -99,11 +106,10 @@ App::App(ingen::World& world)
client::PluginModel::set_rdf_world(*world.rdf_world());
client::PluginModel::set_lilv_world(world.lilv_world());
- world.log().set_sink(std::bind(&MessagesWindow::log,
- _messages_window,
- std::placeholders::_1,
- std::placeholders::_2,
- std::placeholders::_3));
+ world.log().set_sink(
+ [this](const LV2_URID type, const char* fmt, va_list args) {
+ return _messages_window->log(type, fmt, args);
+ });
}
App::~App()
@@ -239,13 +245,13 @@ App::serialiser()
void
App::message(const Message& msg)
{
- if (const Response* const r = boost::get<Response>(&msg)) {
+ if (const Response* const r = std::get_if<Response>(&msg)) {
response(r->id, r->status, r->subject);
- } else if (const Error* const e = boost::get<Error>(&msg)) {
+ } else if (const Error* const e = std::get_if<Error>(&msg)) {
error_message(e->message);
- } else if (const Put* const p = boost::get<Put>(&msg)) {
+ } else if (const Put* const p = std::get_if<Put>(&msg)) {
put(p->uri, p->properties, p->ctx);
- } else if (const SetProperty* const s = boost::get<SetProperty>(&msg)) {
+ } else if (const SetProperty* const s = std::get_if<SetProperty>(&msg)) {
property_change(s->subject, s->predicate, s->value, s->ctx);
}
}
@@ -502,5 +508,4 @@ App::sample_rate() const
return _sample_rate;
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index bb17e126..0138f25a 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -17,14 +17,13 @@
#ifndef INGEN_GUI_APP_HPP
#define INGEN_GUI_APP_HPP
-#include "ingen/Message.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/World.hpp"
-#include "ingen/ingen.h"
-#include "lilv/lilv.h"
+#include <ingen/Message.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <ingen/ingen.h>
+#include <lilv/lilv.h>
#include <sigc++/signal.h>
@@ -42,6 +41,8 @@ class Window;
namespace ingen {
+enum class Status;
+
class Atom;
class Forge;
class Interface;
@@ -76,6 +77,11 @@ class INGEN_API App
public:
~App();
+ App(const App&) = delete;
+ App& operator=(const App&) = delete;
+ App(App&&) = delete;
+ App& operator=(App&&) = delete;
+
void error_message(const std::string& str);
void attach(const std::shared_ptr<ingen::Interface>& client);
@@ -97,7 +103,7 @@ public:
bool signal() const { return _enable_signal; }
void enable_signals(bool b) { _enable_signal = b; }
bool disable_signals() {
- bool old = _enable_signal;
+ const bool old = _enable_signal;
_enable_signal = false;
return old;
}
diff --git a/src/gui/Arc.cpp b/src/gui/Arc.cpp
index c9260d12..c13cf4a7 100644
--- a/src/gui/Arc.cpp
+++ b/src/gui/Arc.cpp
@@ -16,10 +16,12 @@
#include "Arc.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/client/ArcModel.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/PortModel.hpp"
+#include <ganv/Edge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/client/ArcModel.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PortModel.hpp>
#include <glib-object.h>
@@ -27,13 +29,7 @@
#define NS_INTERNALS "http://drobilla.net/ns/ingen-internals#"
-namespace ingen {
-
-namespace client {
-class ObjectModel;
-} // namespace client
-
-namespace gui {
+namespace ingen::gui {
Arc::Arc(Ganv::Canvas& canvas,
const std::shared_ptr<const client::ArcModel>& model,
@@ -41,8 +37,8 @@ Arc::Arc(Ganv::Canvas& canvas,
Ganv::Node* dst)
: Ganv::Edge(canvas, src, dst), _arc_model(model)
{
- std::shared_ptr<const client::ObjectModel> tparent = model->tail()->parent();
- std::shared_ptr<const client::BlockModel> tparent_block;
+ const std::shared_ptr<const client::ObjectModel> tparent = model->tail()->parent();
+ std::shared_ptr<const client::BlockModel> tparent_block;
if ((tparent_block = std::dynamic_pointer_cast<const client::BlockModel>(tparent))) {
if (tparent_block->plugin_uri() == NS_INTERNALS "BlockDelay") {
g_object_set(_gobj, "dash-length", 4.0, nullptr);
@@ -51,5 +47,4 @@ Arc::Arc(Ganv::Canvas& canvas,
}
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/Arc.hpp b/src/gui/Arc.hpp
index 82467a5a..ad1bc6f2 100644
--- a/src/gui/Arc.hpp
+++ b/src/gui/Arc.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_GUI_ARC_HPP
#define INGEN_GUI_ARC_HPP
-#include "ganv/Edge.hpp"
+#include <ganv/Edge.hpp>
#include <memory>
diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp
index 46a0757a..5bd4d30a 100644
--- a/src/gui/BreadCrumbs.cpp
+++ b/src/gui/BreadCrumbs.cpp
@@ -19,18 +19,21 @@
#include "App.hpp"
#include "GraphView.hpp"
-#include "ingen/client/SigClientInterface.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/SigClientInterface.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
-#include <boost/variant/get.hpp>
-#include <glibmm/signalproxy.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <algorithm>
#include <string>
+#include <variant>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
using std::string;
@@ -47,13 +50,13 @@ BreadCrumbs::BreadCrumbs(App& app)
std::shared_ptr<GraphView>
BreadCrumbs::view(const raul::Path& path)
{
- for (const auto& b : _breadcrumbs) {
- if (b->path() == path) {
- return b->view();
- }
- }
+ const auto b = std::find_if(_breadcrumbs.begin(),
+ _breadcrumbs.end(),
+ [&path](const auto* crumb) {
+ return crumb->path() == path;
+ });
- return nullptr;
+ return b == _breadcrumbs.end() ? nullptr : (*b)->view();
}
/** Sets up the crumbs to display `path`.
@@ -65,12 +68,12 @@ void
BreadCrumbs::build(const raul::Path& path,
const std::shared_ptr<GraphView>& view)
{
- bool old_enable_signal = _enable_signal;
+ const bool old_enable_signal = _enable_signal;
_enable_signal = false;
if (!_breadcrumbs.empty() && (path.is_parent_of(_full_path) || path == _full_path)) {
// Moving to a path we already contain, just switch the active button
- for (const auto& b : _breadcrumbs) {
+ for (auto* b : _breadcrumbs) {
if (b->path() == path) {
b->set_active(true);
if (!b->view()) {
@@ -86,13 +89,12 @@ BreadCrumbs::build(const raul::Path& path,
}
_active_path = path;
- _enable_signal = old_enable_signal;
} else if (!_breadcrumbs.empty() && path.is_child_of(_full_path)) {
// Moving to a child of the full path, append crumbs (preserve cache)
string suffix = path.substr(_full_path.length());
- while (suffix.length() > 0) {
+ while (!suffix.empty()) {
if (suffix[0] == '/') {
suffix = suffix.substr(1);
}
@@ -109,7 +111,7 @@ BreadCrumbs::build(const raul::Path& path,
suffix = suffix.substr(suffix.find('/') + 1);
}
- for (const auto& b : _breadcrumbs) {
+ for (auto* b : _breadcrumbs) {
b->set_active(false);
}
_breadcrumbs.back()->set_active(true);
@@ -122,7 +124,7 @@ BreadCrumbs::build(const raul::Path& path,
_active_path = path;
// Empty existing breadcrumbs
- for (const auto& b : _breadcrumbs) {
+ for (auto* b : _breadcrumbs) {
remove(*b);
}
_breadcrumbs.clear();
@@ -135,7 +137,7 @@ BreadCrumbs::build(const raul::Path& path,
raul::Path working_path("/");
string suffix = path.substr(1);
- while (suffix.length() > 0) {
+ while (!suffix.empty()) {
if (suffix[0] == '/') {
suffix = suffix.substr(1);
}
@@ -196,7 +198,7 @@ BreadCrumbs::breadcrumb_clicked(BreadCrumb* crumb)
void
BreadCrumbs::message(const Message& msg)
{
- if (const Del* const del = boost::get<Del>(&msg)) {
+ if (const Del* const del = std::get_if<Del>(&msg)) {
object_destroyed(del->uri);
}
}
@@ -204,15 +206,19 @@ BreadCrumbs::message(const Message& msg)
void
BreadCrumbs::object_destroyed(const URI& uri)
{
- for (auto i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) {
- if ((*i)->path() == uri.c_str()) {
- // Remove all crumbs after the removed one (inclusive)
- for (auto j = i; j != _breadcrumbs.end(); ) {
- BreadCrumb* bc = *j;
- j = _breadcrumbs.erase(j);
- remove(*bc);
- }
- break;
+ const auto i = std::find_if(_breadcrumbs.begin(),
+ _breadcrumbs.end(),
+ [&uri](const auto& b) {
+ return b->path() == uri.c_str();
+ });
+
+ if (i != _breadcrumbs.end()) {
+ // Remove all crumbs after the removed one (inclusive)
+ for (auto j = i; j != _breadcrumbs.end();) {
+ BreadCrumb* const bc = *j;
+
+ j = _breadcrumbs.erase(j);
+ remove(*bc);
}
}
}
@@ -220,12 +226,11 @@ BreadCrumbs::object_destroyed(const URI& uri)
void
BreadCrumbs::object_moved(const raul::Path& old_path, const raul::Path& new_path)
{
- for (const auto& b : _breadcrumbs) {
+ for (auto* b : _breadcrumbs) {
if (b->path() == old_path) {
b->set_path(new_path);
}
}
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/BreadCrumbs.hpp b/src/gui/BreadCrumbs.hpp
index 9ed6f04a..89a339f2 100644
--- a/src/gui/BreadCrumbs.hpp
+++ b/src/gui/BreadCrumbs.hpp
@@ -19,11 +19,12 @@
#include "GraphView.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <raul/Path.hpp>
+#include <glibmm/ustring.h>
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/object.h>
@@ -35,8 +36,7 @@
#include <memory>
#include <string>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
class App;
@@ -71,7 +71,7 @@ private:
{
public:
BreadCrumb(const raul::Path& path,
- const std::shared_ptr<GraphView>& view = nullptr)
+ const std::shared_ptr<GraphView>& view)
: _path(path), _view(view)
{
assert(!view || view->graph()->path() == path);
@@ -81,6 +81,10 @@ private:
show_all();
}
+ explicit BreadCrumb(const raul::Path& path)
+ : BreadCrumb{path, nullptr}
+ {}
+
void set_view(const std::shared_ptr<GraphView>& view) {
assert(!view || view->graph()->path() == _path);
_view = view;
@@ -122,7 +126,6 @@ private:
std::list<BreadCrumb*> _breadcrumbs;
};
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
#endif // INGEN_GUI_BREADCRUMBS_HPP
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index a4c8a433..edafdfa4 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -20,30 +20,33 @@
#include "Window.hpp"
#include "WindowFactory.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/EngineBase.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/QueuedInterface.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp" // IWYU pragma: keep
-#include "ingen/client/SigClientInterface.hpp"
-#include "ingen/client/SocketClient.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Process.hpp"
-
-#include <boost/variant/get.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/EngineBase.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/QueuedInterface.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/SigClientInterface.hpp>
+#include <ingen/client/SocketClient.hpp>
+#include <ingen/fmt.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Process.hpp>
+
#include <glib.h>
#include <glibmm/main.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
+#include <gtkmm/dialog.h>
#include <gtkmm/entry.h>
#include <gtkmm/enums.h>
#include <gtkmm/image.h>
@@ -55,6 +58,7 @@
#include <gtkmm/stock.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <sigc++/functors/slot.h>
#include <sigc++/signal.h>
#include <limits>
@@ -62,9 +66,9 @@
#include <string>
#include <sys/time.h>
#include <utility>
+#include <variant>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
ConnectWindow::ConnectWindow(BaseObjectType* cobject,
Glib::RefPtr<Gtk::Builder> xml)
@@ -75,9 +79,9 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject,
void
ConnectWindow::message(const Message& msg)
{
- if (const Response* const r = boost::get<Response>(&msg)) {
+ if (const Response* const r = std::get_if<Response>(&msg)) {
ingen_response(r->id, r->status, r->subject);
- } else if (const Error* const e = boost::get<Error>(&msg)) {
+ } else if (const Error* const e = std::get_if<Error>(&msg)) {
error(e->message);
}
}
@@ -109,7 +113,7 @@ ConnectWindow::start(App& app, ingen::World& world)
}
set_connected_to(world.interface());
- connect(bool(world.interface()));
+ connect(!!world.interface());
}
void
@@ -196,7 +200,7 @@ ConnectWindow::connect_remote(const URI& uri)
auto sci = std::make_shared<client::SigClientInterface>();
auto qi = std::make_shared<QueuedInterface>(sci);
- std::shared_ptr<ingen::Interface> iface(world.new_interface(uri, qi));
+ const std::shared_ptr<ingen::Interface> iface{world.new_interface(uri, qi)};
if (iface) {
world.set_interface(iface);
_app->attach(qi);
@@ -439,18 +443,17 @@ ConnectWindow::internal_toggled()
void
ConnectWindow::next_stage()
{
- static const char* labels[] = {
- "Connecting...",
- "Pinging engine...",
- "Attaching to engine...",
- "Requesting root graph...",
- "Waiting for root graph...",
- "Connected"
- };
-
-
++_connect_stage;
if (_widgets_loaded) {
+ static const char* labels[] = {
+ "Connecting...",
+ "Pinging engine...",
+ "Attaching to engine...",
+ "Requesting root graph...",
+ "Waiting for root graph...",
+ "Connected"
+ };
+
_progress_label->set_text(labels[_connect_stage]);
}
}
@@ -473,8 +476,8 @@ ConnectWindow::gtk_callback()
// Show if attempted connection goes on for a noticeable amount of time
if (!is_visible()) {
- const float ms_since_start = (now.tv_sec - start.tv_sec) * 1000.0f +
- (now.tv_usec - start.tv_usec) * 0.001f;
+ const float ms_since_start = ((now.tv_sec - start.tv_sec) * 1000.0f) +
+ ((now.tv_usec - start.tv_usec) * 0.001f);
if (ms_since_start > 500) {
present();
set_connecting_widget_states();
@@ -482,8 +485,8 @@ ConnectWindow::gtk_callback()
}
if (_connect_stage == 0) {
- const float ms_since_last = (now.tv_sec - last.tv_sec) * 1000.0f +
- (now.tv_usec - last.tv_usec) * 0.001f;
+ const float ms_since_last = ((now.tv_sec - last.tv_sec) * 1000.0f) +
+ ((now.tv_usec - last.tv_usec) * 0.001f);
if (ms_since_last >= 250) {
last = now;
if (_mode == Mode::INTERNAL) {
@@ -512,8 +515,8 @@ ConnectWindow::gtk_callback()
if (_attached) {
next_stage();
} else {
- const float ms_since_last = (now.tv_sec - last.tv_sec) * 1000.0f +
- (now.tv_usec - last.tv_usec) * 0.001f;
+ const float ms_since_last = ((now.tv_sec - last.tv_sec) * 1000.0f) +
+ ((now.tv_usec - last.tv_usec) * 0.001f);
if (attempts > 10) {
error("Failed to ping engine");
_connect_stage = -1;
@@ -571,5 +574,4 @@ ConnectWindow::quit()
Gtk::Main::quit();
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp
index b0e03850..cd9059e1 100644
--- a/src/gui/ConnectWindow.hpp
+++ b/src/gui/ConnectWindow.hpp
@@ -19,13 +19,11 @@
#include "Window.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/URI.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/URI.hpp>
#include <glibmm/refptr.h>
#include <gtkmm/builder.h>
-#include <gtkmm/dialog.h>
#include <cstdint>
#include <memory>
@@ -43,6 +41,8 @@ class SpinButton;
namespace ingen {
+enum class Status;
+
class Interface;
class World;
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index 14258a5a..47c567e3 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2017 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -29,34 +29,34 @@
#include "WindowFactory.hpp"
#include "ingen_config.h"
-#include "ganv/canvas.h"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "ingen/fmt.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ganv/canvas.h>
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <ingen/fmt.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <gdk/gdk.h>
+#include <glib.h>
#include <glib/gstdio.h>
#include <glibmm/convert.h>
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/alignment.h>
#include <gtkmm/box.h>
@@ -92,6 +92,7 @@
# include <webkit/webkit.h>
#endif
+#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio>
@@ -101,7 +102,6 @@
#include <sstream>
#include <string>
#include <utility>
-#include <vector>
namespace ingen {
@@ -228,7 +228,7 @@ GraphBox::GraphBox(BaseObjectType* cobject,
_menu_view_graph_properties->signal_activate().connect(
sigc::mem_fun(this, &GraphBox::event_show_properties));
- Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
+ const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
clipboard->signal_owner_change().connect(
sigc::mem_fun(this, &GraphBox::event_clipboard_changed));
@@ -250,8 +250,12 @@ std::shared_ptr<GraphBox>
GraphBox::create(App& app, const std::shared_ptr<const GraphModel>& graph)
{
GraphBox* result = nullptr;
- Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("graph_win");
+ const Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("graph_win");
xml->get_widget_derived("graph_win_vbox", result);
+ if (!result) {
+ return {};
+ }
+
result->init_box(app);
result->set_graph(graph, nullptr);
@@ -379,14 +383,14 @@ GraphBox::set_graph(const std::shared_ptr<const GraphModel>& graph,
_menu_view_control_window->property_sensitive() = false;
- for (const auto& p : graph->ports()) {
- if (_app->can_control(p.get())) {
- _menu_view_control_window->property_sensitive() = true;
- break;
- }
- }
+ _menu_view_control_window->property_sensitive() =
+ std::any_of(graph->ports().begin(),
+ graph->ports().end(),
+ [this](const auto& p) {
+ return _app->can_control(p.get());
+ });
- _menu_parent->property_sensitive() = bool(graph->parent());
+ _menu_parent->property_sensitive() = !!graph->parent();
new_port_connection = graph->signal_new_port().connect(
sigc::mem_fun(this, &GraphBox::graph_port_added));
@@ -422,14 +426,12 @@ GraphBox::graph_port_removed(const std::shared_ptr<const PortModel>& port)
return;
}
- for (const auto& p : _graph->ports()) {
- if (p->is_input() && _app->can_control(p.get())) {
- _menu_view_control_window->property_sensitive() = true;
- return;
- }
- }
-
- _menu_view_control_window->property_sensitive() = false;
+ _menu_view_control_window->property_sensitive() =
+ std::any_of(_graph->ports().begin(),
+ _graph->ports().end(),
+ [this](const auto& p) {
+ return p->is_input() && _app->can_control(p.get());
+ });
}
void
@@ -535,7 +537,7 @@ GraphBox::event_show_engine()
void
GraphBox::event_clipboard_changed(GdkEventOwnerChange* ev)
{
- Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
+ const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
_menu_paste->set_sensitive(clipboard->wait_is_text_available());
}
@@ -882,10 +884,10 @@ GraphBox::event_refresh_activated()
void
GraphBox::event_fullscreen_toggled()
{
- // FIXME: ugh, use GTK signals to track state and know for sure
- static bool is_fullscreen = false;
-
if (_window) {
+ // FIXME: ugh, use GTK signals to track state and know for sure
+ static bool is_fullscreen = false;
+
if (!is_fullscreen) {
_window->fullscreen();
is_fullscreen = true;
@@ -927,8 +929,7 @@ GraphBox::event_animate_signals_toggled()
_app->interface()->set_property(
URI("ingen:/clients/this"),
_app->uris().ingen_broadcast,
- _app->forge().make(
- static_cast<bool>(_menu_animate_signals->get_active())));
+ _app->forge().make(_menu_animate_signals->get_active()));
}
void
diff --git a/src/gui/GraphBox.hpp b/src/gui/GraphBox.hpp
index cfc4a67f..07962a3d 100644
--- a/src/gui/GraphBox.hpp
+++ b/src/gui/GraphBox.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_GUI_GRAPH_BOX_HPP
#define INGEN_GUI_GRAPH_BOX_HPP
-#include "ingen/ingen.h"
+#include <ingen/ingen.h>
#include <gdk/gdk.h>
#include <glibmm/ustring.h>
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index 3acd510d..3090186a 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -28,46 +28,48 @@
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
-#include "ganv/Canvas.hpp"
-#include "ganv/Edge.hpp"
-#include "ganv/Module.hpp"
-#include "ganv/Node.hpp"
-#include "ganv/Port.hpp"
-#include "ganv/canvas.h"
-#include "ganv/edge.h"
-#include "ganv/module.h"
-#include "ganv/types.h"
-#include "ingen/Arc.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/ClashAvoider.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Parser.hpp"
-#include "ingen/Serialiser.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ArcModel.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Symbol.hpp"
-#include "sord/sordmm.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ganv/Canvas.hpp>
+#include <ganv/Edge.hpp>
+#include <ganv/Module.hpp>
+#include <ganv/Node.hpp>
+#include <ganv/Port.hpp>
+#include <ganv/canvas.h>
+#include <ganv/edge.h>
+#include <ganv/module.h>
+#include <ganv/types.h>
+#include <ingen/Arc.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/ClashAvoider.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Parser.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/Serialiser.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ArcModel.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+#include <sord/sordmm.hpp>
+
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms-compat.h>
#include <gdkmm/window.h>
#include <glib.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/builder.h>
#include <gtkmm/checkmenuitem.h>
@@ -78,9 +80,9 @@
#include <gtkmm/menu.h>
#include <gtkmm/menu_elems.h>
#include <gtkmm/menuitem.h>
-#include <gtkmm/menushell.h>
#include <gtkmm/object.h>
#include <gtkmm/stock.h>
+#include <gtkmm/stockid.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
#include <sigc++/signal.h>
@@ -94,6 +96,7 @@
#include <map>
#include <memory>
#include <mutex>
+#include <optional>
#include <set>
#include <sstream>
#include <string>
@@ -131,7 +134,7 @@ GraphCanvas::GraphCanvas(App& app,
, _app(app)
, _graph(std::move(graph))
{
- Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("canvas_menu");
+ const Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("canvas_menu");
xml->get_widget("canvas_menu", _menu);
xml->get_widget("canvas_menu_add_audio_input", _menu_add_audio_input);
@@ -250,7 +253,7 @@ GraphCanvas::build_menus()
_menu->reorder_child(*internal_menu_item, 4);
}
- // Build skeleton LV2 plugin class heirarchy for 'Plugin' menu
+ // Build skeleton LV2 plugin class hierarchy for 'Plugin' menu
if (_plugin_menu) {
_plugin_menu->clear();
} else {
@@ -266,7 +269,7 @@ GraphCanvas::build_menus()
sigc::mem_fun(this, &GraphCanvas::load_plugin));
}
- // Add known plugins to menu heirarchy
+ // Add known plugins to menu hierarchy
auto plugins = _app.store()->plugins();
for (const auto& p : *plugins) {
add_plugin(p.second);
@@ -302,7 +305,7 @@ GraphCanvas::build()
static void
show_module_human_names(GanvNode* node, void* data)
{
- bool b = *static_cast<bool*>(data);
+ const bool b = *static_cast<bool*>(data);
if (GANV_IS_MODULE(node)) {
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
auto* nmod = dynamic_cast<NodeModule*>(module);
@@ -611,14 +614,14 @@ destroy_node(GanvNode* node, void* data)
return;
}
- App* app = static_cast<App*>(data);
+ const App* app = static_cast<App*>(data);
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
- auto* node_module = dynamic_cast<NodeModule*>(module);
+ const auto* node_module = dynamic_cast<NodeModule*>(module);
if (node_module) {
app->interface()->del(node_module->block()->uri());
} else {
- auto* port_module = dynamic_cast<GraphPortModule*>(module);
+ const auto* port_module = dynamic_cast<GraphPortModule*>(module);
if (port_module &&
strcmp(port_module->port()->path().symbol(), "control") &&
strcmp(port_module->port()->path().symbol(), "notify")) {
@@ -630,11 +633,11 @@ destroy_node(GanvNode* node, void* data)
static void
destroy_arc(GanvEdge* arc, void* data)
{
- App* app = static_cast<App*>(data);
+ const App* app = static_cast<App*>(data);
Ganv::Edge* arcmm = Glib::wrap(arc);
- Port* tail = dynamic_cast<Port*>(arcmm->get_tail());
- Port* head = dynamic_cast<Port*>(arcmm->get_head());
+ const Port* tail = dynamic_cast<Port*>(arcmm->get_tail());
+ const Port* head = dynamic_cast<Port*>(arcmm->get_head());
app->interface()->disconnect(tail->model()->path(), head->model()->path());
}
@@ -659,12 +662,12 @@ serialise_node(GanvNode* node, void* data)
}
Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
- auto* node_module = dynamic_cast<NodeModule*>(module);
+ const auto* node_module = dynamic_cast<NodeModule*>(module);
if (node_module) {
serialiser->serialise(node_module->block());
} else {
- auto* port_module = dynamic_cast<GraphPortModule*>(module);
+ const auto* port_module = dynamic_cast<GraphPortModule*>(module);
if (port_module) {
serialiser->serialise(port_module->port());
}
@@ -679,7 +682,7 @@ serialise_arc(GanvEdge* arc, void* data)
return;
}
- auto* garc = dynamic_cast<gui::Arc*>(Glib::wrap(GANV_EDGE(arc)));
+ const auto* garc = dynamic_cast<gui::Arc*>(Glib::wrap(GANV_EDGE(arc)));
if (garc) {
serialiser->serialise_arc(Sord::Node(), garc->model());
}
@@ -688,7 +691,7 @@ serialise_arc(GanvEdge* arc, void* data)
void
GraphCanvas::copy_selection()
{
- std::lock_guard<std::mutex> lock(_app.world().rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()};
Serialiser serialiser(_app.world());
serialiser.start_to_string(_graph->path(), _graph->base_uri());
@@ -696,7 +699,7 @@ GraphCanvas::copy_selection()
for_each_selected_node(serialise_node, &serialiser);
for_each_selected_edge(serialise_arc, &serialiser);
- Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
+ const Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
clipboard->set_text(serialiser.finish());
_paste_count = 0;
}
@@ -704,7 +707,7 @@ GraphCanvas::copy_selection()
void
GraphCanvas::paste()
{
- std::lock_guard<std::mutex> lock(_app.world().rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()};
const Glib::ustring str = Gtk::Clipboard::get()->wait_for_text();
auto parser = _app.loader()->parser();
@@ -727,7 +730,7 @@ GraphCanvas::paste()
{{uris.rdf_type, Property(uris.ingen_Graph)}});
// Parse clipboard text into clipboard store
- boost::optional<URI> base_uri = parser->parse_string(
+ std::optional<URI> base_uri = parser->parse_string(
_app.world(), clipboard, str, main_uri());
// Figure out the copy graph base path
@@ -735,7 +738,7 @@ GraphCanvas::paste()
if (base_uri) {
std::string base = *base_uri;
if (base[base.size() - 1] == '/') {
- base = base.substr(0, base.size() - 1);
+ base.resize(base.size() - 1);
}
copy_root = uri_to_path(URI(base));
}
@@ -875,7 +878,7 @@ GraphCanvas::menu_add_port(const string& sym_base,
uris.rdf_type,
Property(is_output ? uris.lv2_OutputPort : uris.lv2_InputPort));
props.emplace(uris.lv2_index,
- _app.forge().make(int32_t(_graph->num_ports())));
+ _app.forge().make(static_cast<int32_t>(_graph->num_ports())));
props.emplace(uris.lv2_name, _app.forge().alloc(name.c_str()));
_app.interface()->put(path_to_uri(path), props);
}
@@ -888,8 +891,8 @@ GraphCanvas::load_plugin(const std::weak_ptr<PluginModel>& weak_plugin)
return;
}
- raul::Symbol symbol = plugin->default_block_symbol();
- unsigned offset = _app.store()->child_name_offset(_graph->path(), symbol);
+ raul::Symbol symbol = plugin->default_block_symbol();
+ const unsigned offset = _app.store()->child_name_offset(_graph->path(), symbol);
if (offset != 0) {
std::stringstream ss;
ss << symbol << "_" << offset;
diff --git a/src/gui/GraphCanvas.hpp b/src/gui/GraphCanvas.hpp
index 3ebd61df..38f3ab08 100644
--- a/src/gui/GraphCanvas.hpp
+++ b/src/gui/GraphCanvas.hpp
@@ -17,12 +17,12 @@
#ifndef INGEN_GUI_GRAPHCANVAS_HPP
#define INGEN_GUI_GRAPHCANVAS_HPP
-#include "ganv/Canvas.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
-#include "raul/Path.hpp"
+#include <ganv/Canvas.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <lilv/lilv.h>
+#include <raul/Path.hpp>
#include <gdk/gdk.h>
diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp
index 4c161f3f..cd471d97 100644
--- a/src/gui/GraphPortModule.cpp
+++ b/src/gui/GraphPortModule.cpp
@@ -20,17 +20,18 @@
#include "GraphCanvas.hpp"
#include "Port.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "raul/Symbol.hpp"
-
-#include "ingen/Configuration.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/client/GraphModel.hpp" // IWYU pragma: keep
-#include "ingen/client/PortModel.hpp"
+#include <ganv/Module.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <raul/Symbol.hpp>
#include <sigc++/functors/mem_fun.h>
#include <sigc++/signal.h>
@@ -42,9 +43,7 @@
#include <string>
#include <utility>
-namespace ingen {
-
-namespace gui {
+namespace ingen::gui {
GraphPortModule::GraphPortModule(
GraphCanvas& canvas,
@@ -169,5 +168,4 @@ GraphPortModule::set_selected(gboolean b)
}
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/GraphPortModule.hpp b/src/gui/GraphPortModule.hpp
index b02f63a1..a8091f38 100644
--- a/src/gui/GraphPortModule.hpp
+++ b/src/gui/GraphPortModule.hpp
@@ -17,8 +17,8 @@
#ifndef INGEN_GUI_GRAPHPORTMODULE_HPP
#define INGEN_GUI_GRAPHPORTMODULE_HPP
-#include "ganv/Module.hpp"
-#include "ingen/URI.hpp"
+#include <ganv/Module.hpp>
+#include <ingen/URI.hpp>
#include <gdk/gdk.h>
#include <glib.h>
@@ -33,9 +33,7 @@ class Atom;
namespace client {
class PortModel;
} // namespace client
-} // namespace ingen
-namespace ingen {
namespace gui {
class App;
diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp
index 53defd75..1d141271 100644
--- a/src/gui/GraphTreeWindow.cpp
+++ b/src/gui/GraphTreeWindow.cpp
@@ -20,18 +20,19 @@
#include "Window.hpp"
#include "WindowFactory.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <glibmm/propertyproxy.h>
-#include <glibmm/signalproxy.h>
#include <gtkmm/builder.h>
#include <gtkmm/cellrenderer.h>
#include <gtkmm/cellrenderertoggle.h>
@@ -46,6 +47,7 @@
#include <cassert>
#include <cstdint>
#include <memory>
+#include <string>
namespace ingen {
@@ -159,7 +161,7 @@ GraphTreeWindow::find_graph(Gtk::TreeModel::Children root,
const std::shared_ptr<client::ObjectModel>& graph)
{
for (auto c = root.begin(); c != root.end(); ++c) {
- std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col];
+ const std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col];
if (graph == pm) {
return c;
}
@@ -198,7 +200,7 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path,
const auto active = _graph_treestore->get_iter(path);
auto row = *active;
- std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
+ const std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
_app->window_factory()->present_graph(pm);
}
@@ -206,17 +208,17 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path,
void
GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str)
{
- Gtk::TreeModel::Path path(path_str);
- auto active = _graph_treestore->get_iter(path);
- auto row = *active;
+ const Gtk::TreeModel::Path path{path_str};
+ auto active = _graph_treestore->get_iter(path);
+ auto row = *active;
- std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
+ const std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
assert(pm);
if (_enable_signal) {
_app->set_property(pm->uri(),
_app->uris().ingen_enabled,
- _app->forge().make(static_cast<bool>(!pm->enabled())));
+ _app->forge().make(!pm->enabled()));
}
}
diff --git a/src/gui/GraphTreeWindow.hpp b/src/gui/GraphTreeWindow.hpp
index 8534d66c..6f33f258 100644
--- a/src/gui/GraphTreeWindow.hpp
+++ b/src/gui/GraphTreeWindow.hpp
@@ -19,7 +19,7 @@
#include "Window.hpp"
-#include "ingen/URI.hpp"
+#include <ingen/URI.hpp>
#include <gdk/gdk.h>
#include <glibmm/refptr.h>
@@ -29,7 +29,6 @@
#include <gtkmm/treeselection.h>
#include <gtkmm/treestore.h>
#include <gtkmm/treeview.h>
-#include <gtkmm/window.h>
#include <memory>
@@ -119,7 +118,7 @@ public:
void set_window(GraphTreeWindow* win) { _window = win; }
bool on_button_press_event(GdkEventButton* ev) override {
- bool ret = Gtk::TreeView::on_button_press_event(ev);
+ const bool ret = Gtk::TreeView::on_button_press_event(ev);
if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
_window->show_graph_menu(ev);
diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp
index a5ca7dd1..8d1e1777 100644
--- a/src/gui/GraphView.cpp
+++ b/src/gui/GraphView.cpp
@@ -20,16 +20,15 @@
#include "GraphCanvas.hpp"
#include "WidgetFactory.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/GraphModel.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/GraphModel.hpp>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/builder.h>
#include <gtkmm/enums.h>
@@ -46,6 +45,7 @@
#include <cstdint>
#include <map>
#include <memory>
+#include <string>
#include <utility>
namespace ingen {
@@ -120,8 +120,9 @@ GraphView::set_graph(const std::shared_ptr<const GraphModel>& graph)
std::shared_ptr<GraphView>
GraphView::create(App& app, const std::shared_ptr<const GraphModel>& graph)
{
- GraphView* result = nullptr;
- Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("warehouse_win");
+ GraphView* result = nullptr;
+ const Glib::RefPtr<Gtk::Builder> xml =
+ WidgetFactory::create("warehouse_win");
xml->get_widget_derived("graph_view_box", result);
if (!result) {
@@ -142,8 +143,7 @@ GraphView::process_toggled()
_app->set_property(_graph->uri(),
_app->uris().ingen_enabled,
- _app->forge().make(
- static_cast<bool>(_process_but->get_active())));
+ _app->forge().make(_process_but->get_active()));
}
void
diff --git a/src/gui/GraphView.hpp b/src/gui/GraphView.hpp
index 0b6aee1e..812f2cbc 100644
--- a/src/gui/GraphView.hpp
+++ b/src/gui/GraphView.hpp
@@ -48,7 +48,7 @@ namespace gui {
class App;
class GraphCanvas;
-/** The graph specific contents of a GraphWindow (ie the canvas and whatever else).
+/** The graph specific contents of a GraphWindow (the canvas and whatever else).
*
* \ingroup GUI
*/
diff --git a/src/gui/GraphWindow.cpp b/src/gui/GraphWindow.cpp
index 94df34e0..a6978e46 100644
--- a/src/gui/GraphWindow.cpp
+++ b/src/gui/GraphWindow.cpp
@@ -25,9 +25,9 @@
#include <glibmm/refptr.h>
#include <gtkmm/builder.h>
#include <gtkmm/layout.h>
+#include <gtkmm/window.h>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
GraphWindow::GraphWindow(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
@@ -80,5 +80,4 @@ GraphWindow::on_key_press_event(GdkEventKey* event)
return Gtk::Window::on_key_press_event(event);
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/GraphWindow.hpp b/src/gui/GraphWindow.hpp
index d1361ca5..9936b5df 100644
--- a/src/gui/GraphWindow.hpp
+++ b/src/gui/GraphWindow.hpp
@@ -21,7 +21,6 @@
#include "Window.hpp"
#include <gdk/gdk.h>
-#include <gtkmm/window.h>
#include <memory>
#include <string>
@@ -45,8 +44,6 @@ class PortModel;
namespace gui {
-class App;
-
/** A window for a graph.
*
* \ingroup GUI
diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp
index b44a1fe7..5124face 100644
--- a/src/gui/LoadGraphWindow.cpp
+++ b/src/gui/LoadGraphWindow.cpp
@@ -19,24 +19,24 @@
#include "App.hpp"
#include "ThreadedLoader.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/runtime_paths.hpp"
-#include "raul/Path.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/runtime_paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+
#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/slisthandle.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
@@ -52,6 +52,7 @@
#include <list>
#include <map>
#include <memory>
+#include <optional>
#include <sstream>
#include <string>
#include <utility>
@@ -187,8 +188,8 @@ LoadGraphWindow::ok_clicked()
if (_import) {
// If unset load_graph will load value
- boost::optional<raul::Path> parent;
- boost::optional<raul::Symbol> symbol;
+ std::optional<raul::Path> parent;
+ std::optional<raul::Symbol> symbol;
if (!_graph->path().is_root()) {
parent = _graph->path().parent();
symbol = _graph->symbol();
@@ -198,7 +199,7 @@ LoadGraphWindow::ok_clicked()
true, FilePath(get_filename()), parent, symbol, _initial_data);
} else {
- std::list<Glib::ustring> uri_list = get_filenames();
+ const std::list<Glib::ustring> uri_list = get_filenames();
for (const auto& u : uri_list) {
// Cascade
Atom& x = _initial_data.find(uris.ingen_canvasX)->second;
@@ -237,14 +238,14 @@ raul::Symbol
LoadGraphWindow::symbol_from_filename(const Glib::ustring& filename)
{
std::string symbol_str = Glib::path_get_basename(get_filename());
- symbol_str = symbol_str.substr(0, symbol_str.find('.'));
+ symbol_str.resize(symbol_str.find('.'));
return raul::Symbol::symbolify(symbol_str);
}
raul::Symbol
LoadGraphWindow::avoid_symbol_clash(const raul::Symbol& symbol)
{
- unsigned offset = _app->store()->child_name_offset(
+ const unsigned offset = _app->store()->child_name_offset(
_graph->path(), symbol);
if (offset != 0) {
diff --git a/src/gui/LoadGraphWindow.hpp b/src/gui/LoadGraphWindow.hpp
index adb6bce1..bfa2590e 100644
--- a/src/gui/LoadGraphWindow.hpp
+++ b/src/gui/LoadGraphWindow.hpp
@@ -17,8 +17,8 @@
#ifndef INGEN_GUI_LOADGRAPHWINDOW_HPP
#define INGEN_GUI_LOADGRAPHWINDOW_HPP
-#include "ingen/Properties.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Properties.hpp>
+#include <raul/Symbol.hpp>
#include <glibmm/ustring.h>
#include <gtkmm/filechooserdialog.h>
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index 940f09b1..3d8b2cd5 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -19,22 +19,23 @@
#include "App.hpp"
#include "Window.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/paths.hpp"
-#include "lilv/lilv.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/paths.hpp>
+#include <lilv/lilv.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <gdk/gdkkeysyms-compat.h>
#include <glibmm/listhandle.h>
#include <glibmm/propertyproxy.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
@@ -42,9 +43,12 @@
#include <gtkmm/combobox.h>
#include <gtkmm/enums.h>
#include <gtkmm/messagedialog.h>
+#include <gtkmm/object.h>
#include <gtkmm/treeiter.h>
+#include <gtkmm/treepath.h>
#include <gtkmm/treeview.h>
#include <gtkmm/treeviewcolumn.h>
+#include <gtkmm/window.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
#include <sigc++/signal.h>
@@ -351,7 +355,7 @@ LoadPluginWindow::plugin_activated(const Gtk::TreeModel::Path& path,
void
LoadPluginWindow::plugin_selection_changed()
{
- size_t n_selected = _selection->get_selected_rows().size();
+ const size_t n_selected = _selection->get_selected_rows().size();
if (n_selected == 0) {
_name_offset = 0;
_name_entry->set_text("");
@@ -405,7 +409,7 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter)
const URIs& uris = _app->uris();
auto row = *iter;
auto plugin = row.get_value(_plugins_columns._col_plugin);
- bool polyphonic = _polyphonic_checkbutton->get_active();
+ const bool polyphonic = _polyphonic_checkbutton->get_active();
string name = _name_entry->get_text();
if (name.empty()) {
@@ -420,8 +424,8 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter)
dialog.run();
} else {
- raul::Path path = _graph->path().child(raul::Symbol::symbolify(name));
- Properties props = _initial_data;
+ const raul::Path path = _graph->path().child(raul::Symbol::symbolify(name));
+ Properties props = _initial_data;
props.emplace(uris.rdf_type, Property(uris.ingen_Block));
props.emplace(uris.lv2_prototype, _app->forge().make_urid(plugin->uri()));
props.emplace(uris.ingen_polyphonic, _app->forge().make(polyphonic));
@@ -457,7 +461,7 @@ LoadPluginWindow::filter_changed()
// Get selected criteria
const auto row = *(_filter_combo->get_active());
- CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria];
+ const CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria];
string field;
diff --git a/src/gui/LoadPluginWindow.hpp b/src/gui/LoadPluginWindow.hpp
index 7a9313e2..eab48913 100644
--- a/src/gui/LoadPluginWindow.hpp
+++ b/src/gui/LoadPluginWindow.hpp
@@ -19,9 +19,9 @@
#include "Window.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/client/ClientStore.hpp"
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/client/ClientStore.hpp>
#include <gdk/gdk.h>
#include <glibmm/refptr.h>
@@ -30,7 +30,6 @@
#include <gtkmm/treemodel.h>
#include <gtkmm/treemodelcolumn.h>
#include <gtkmm/treeselection.h>
-#include <gtkmm/window.h>
#include <map>
#include <memory>
diff --git a/src/gui/MessagesWindow.cpp b/src/gui/MessagesWindow.cpp
index 9127ad61..993fbb33 100644
--- a/src/gui/MessagesWindow.cpp
+++ b/src/gui/MessagesWindow.cpp
@@ -20,12 +20,12 @@
#include "Window.hpp"
#include "ingen_config.h"
-#include "ingen/URIs.hpp"
-#include "lv2/urid/urid.h"
+#include <ingen/URIs.hpp>
+#include <lv2/urid/urid.h>
#include <gdkmm/color.h>
#include <glibmm/propertyproxy.h>
-#include <glibmm/signalproxy.h>
+#include <glibmm/ustring.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
#include <gtkmm/enums.h>
@@ -39,8 +39,8 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
+
using std::string;
MessagesWindow::MessagesWindow(BaseObjectType* cobject,
@@ -84,7 +84,7 @@ MessagesWindow::init_window(App& app)
void
MessagesWindow::post_error(const string& msg)
{
- Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer();
+ const Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer();
text_buf->insert_with_tag(text_buf->end(), msg, _error_tag);
text_buf->insert(text_buf->end(), "\n");
@@ -101,7 +101,7 @@ MessagesWindow::post_error(const string& msg)
int
MessagesWindow::log(LV2_URID type, const char* fmt, va_list args)
{
- std::lock_guard<std::mutex> lock(_mutex);
+ const std::lock_guard<std::mutex> lock{_mutex};
#if USE_VASPRINTF
char* buf = nullptr;
@@ -125,7 +125,7 @@ MessagesWindow::flush()
std::string line;
{
- std::lock_guard<std::mutex> lock(_mutex);
+ const std::lock_guard<std::mutex> lock{_mutex};
if (!_stream.rdbuf()->in_avail()) {
return;
}
@@ -133,7 +133,7 @@ MessagesWindow::flush()
std::getline(_stream, line, '\0');
}
- Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer();
+ const Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer();
auto t = _tags.find(type);
if (t != _tags.end()) {
@@ -151,10 +151,9 @@ MessagesWindow::flush()
void
MessagesWindow::clear_clicked()
{
- Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer();
+ const Glib::RefPtr<Gtk::TextBuffer> text_buf = _textview->get_buffer();
text_buf->erase(text_buf->begin(), text_buf->end());
_clear_button->set_sensitive(false);
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/MessagesWindow.hpp b/src/gui/MessagesWindow.hpp
index 45301889..0a70e76c 100644
--- a/src/gui/MessagesWindow.hpp
+++ b/src/gui/MessagesWindow.hpp
@@ -19,11 +19,10 @@
#include "Window.hpp"
-#include "lv2/urid/urid.h"
+#include <lv2/urid/urid.h>
#include <glibmm/refptr.h>
#include <gtkmm/texttag.h>
-#include <gtkmm/window.h>
#include <cstdarg>
#include <map>
@@ -37,10 +36,7 @@ class Button;
class TextView;
} // namespace Gtk
-namespace ingen {
-namespace gui {
-
-class App;
+namespace ingen::gui {
/** Messages Window.
*
@@ -75,7 +71,6 @@ private:
std::map< LV2_URID, Glib::RefPtr<Gtk::TextTag> > _tags;
};
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
#endif // INGEN_GUI_MESSAGESWINDOW_HPP
diff --git a/src/gui/NewSubgraphWindow.cpp b/src/gui/NewSubgraphWindow.cpp
index 9b6c4a1a..3d6bf019 100644
--- a/src/gui/NewSubgraphWindow.cpp
+++ b/src/gui/NewSubgraphWindow.cpp
@@ -19,20 +19,20 @@
#include "App.hpp"
#include "Window.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/builder.h>
@@ -40,6 +40,7 @@
#include <gtkmm/entry.h>
#include <gtkmm/label.h>
#include <gtkmm/spinbutton.h>
+#include <gtkmm/window.h>
#include <sigc++/functors/mem_fun.h>
#include <cstdint>
@@ -47,8 +48,7 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
NewSubgraphWindow::NewSubgraphWindow(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
@@ -94,7 +94,7 @@ NewSubgraphWindow::set_graph(std::shared_ptr<const client::GraphModel> graph)
void
NewSubgraphWindow::name_changed()
{
- std::string name = _name_entry->get_text();
+ const std::string name = _name_entry->get_text();
if (!raul::Symbol::is_valid(name)) {
_message_label->set_text("Name contains invalid characters.");
_ok_button->property_sensitive() = false;
@@ -118,8 +118,8 @@ NewSubgraphWindow::ok_clicked()
// Create graph
Properties props;
props.emplace(_app->uris().rdf_type, Property(_app->uris().ingen_Graph));
- props.emplace(_app->uris().ingen_polyphony, _app->forge().make(int32_t(poly)));
- props.emplace(_app->uris().ingen_enabled, _app->forge().make(bool(true)));
+ props.emplace(_app->uris().ingen_polyphony, _app->forge().make(static_cast<int32_t>(poly)));
+ props.emplace(_app->uris().ingen_enabled, _app->forge().make(true));
_app->interface()->put(
path_to_uri(path), props, Resource::Graph::INTERNAL);
@@ -138,5 +138,4 @@ NewSubgraphWindow::cancel_clicked()
hide();
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/NewSubgraphWindow.hpp b/src/gui/NewSubgraphWindow.hpp
index be660da5..b0fb24d2 100644
--- a/src/gui/NewSubgraphWindow.hpp
+++ b/src/gui/NewSubgraphWindow.hpp
@@ -19,9 +19,7 @@
#include "Window.hpp"
-#include "ingen/Properties.hpp"
-
-#include <gtkmm/window.h>
+#include <ingen/Properties.hpp>
#include <memory>
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index faddaae7..2815194c 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -19,22 +19,22 @@
#include "App.hpp"
#include "ObjectMenu.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <raul/Symbol.hpp>
#include <glib.h>
#include <glibmm/convert.h>
#include <glibmm/miscutils.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/box.h>
#include <gtkmm/builder.h>
@@ -46,15 +46,17 @@
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/image.h>
#include <gtkmm/label.h>
+#include <gtkmm/menu.h>
#include <gtkmm/menu_elems.h>
#include <gtkmm/menuitem.h>
-#include <gtkmm/menushell.h>
#include <gtkmm/object.h>
#include <gtkmm/separatormenuitem.h>
#include <gtkmm/stock.h>
+#include <gtkmm/stockid.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
@@ -62,8 +64,7 @@
#include <utility>
#include <vector>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
NodeMenu::NodeMenu(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
@@ -161,6 +162,12 @@ NodeMenu::init(App& app, const std::shared_ptr<const client::BlockModel>& block)
_enable_signal = true;
}
+std::shared_ptr<const client::BlockModel>
+NodeMenu::block() const
+{
+ return std::dynamic_pointer_cast<const client::BlockModel>(_object);
+}
+
void
NodeMenu::add_preset(const URI& uri, const std::string& label)
{
@@ -184,7 +191,7 @@ NodeMenu::on_menu_enabled()
{
_app->set_property(_object->uri(),
_app->uris().ingen_enabled,
- _app->forge().make(bool(_enabled_menuitem->get_active())));
+ _app->forge().make(_enabled_menuitem->get_active()));
}
void
@@ -200,7 +207,7 @@ NodeMenu::on_menu_randomize()
bm->port_value_range(p, min, max, _app->sample_rate());
const auto r = static_cast<float>(g_random_double_range(0.0, 1.0));
- const float val = r * (max - min) + min;
+ const float val = (r * (max - min)) + min;
_app->set_property(p->uri(),
_app->uris().ingen_value,
_app->forge().make(val));
@@ -246,7 +253,7 @@ NodeMenu::on_save_preset_activated()
const std::string real_path = Glib::build_filename(dirname, bundle, file);
const std::string real_uri = Glib::filename_to_uri(real_path);
- Properties props{
+ const Properties props{
{ _app->uris().rdf_type,
_app->uris().pset_Preset },
{ _app->uris().rdfs_label,
@@ -268,14 +275,11 @@ NodeMenu::on_preset_activated(const std::string& uri)
bool
NodeMenu::has_control_inputs()
{
- for (const auto& p : block()->ports()) {
- if (p->is_input() && p->is_numeric()) {
- return true;
- }
- }
-
- return false;
+ return std::any_of(block()->ports().begin(),
+ block()->ports().end(),
+ [](const auto& p) {
+ return p->is_input() && p->is_numeric();
+ });
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp
index f109c3e4..0427672c 100644
--- a/src/gui/NodeMenu.hpp
+++ b/src/gui/NodeMenu.hpp
@@ -19,9 +19,8 @@
#include "ObjectMenu.hpp"
-#include "ingen/URI.hpp"
+#include <ingen/URI.hpp>
-#include <gtkmm/menu.h>
#include <sigc++/connection.h>
#include <sigc++/signal.h>
@@ -35,6 +34,7 @@ template <class T> class RefPtr;
namespace Gtk {
class Builder;
class CheckMenuItem;
+class Menu;
class MenuItem;
} // namespace Gtk
@@ -66,9 +66,7 @@ public:
sigc::signal<void, bool> signal_embed_gui;
protected:
- std::shared_ptr<const client::BlockModel> block() const {
- return std::dynamic_pointer_cast<const client::BlockModel>(_object);
- }
+ std::shared_ptr<const client::BlockModel> block() const;
void add_preset(const URI& uri, const std::string& label);
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 1b090c4f..deb8fe52 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -27,27 +27,28 @@
#include "WindowFactory.hpp"
#include "ingen_config.h"
-#include "ganv/Port.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/GraphModel.hpp" // IWYU pragma: keep
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PluginUI.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "lv2/atom/util.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ganv/Module.hpp>
+#include <ganv/Port.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PluginUI.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <lv2/atom/util.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <glibmm/main.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/container.h>
#include <gtkmm/eventbox.h>
@@ -56,6 +57,7 @@
#include <sigc++/adaptors/bind.h>
#include <sigc++/adaptors/retype_return.h>
#include <sigc++/functors/mem_fun.h>
+#include <sigc++/functors/slot.h>
#include <sigc++/signal.h>
#include <cassert>
@@ -207,7 +209,7 @@ NodeModule::show_human_names(bool b)
if (name_property.type() == uris.forge.String) {
label = name_property.ptr<char>();
} else {
- Glib::ustring hn = block()->plugin_model()->port_human_name(
+ const Glib::ustring hn = block()->plugin_model()->port_human_name(
port->model()->index());
if (!hn.empty()) {
label = hn;
@@ -532,9 +534,10 @@ NodeModule::on_selected(gboolean selected)
if (selected && win->documentation_is_visible()) {
std::string doc;
- bool html = false;
#if USE_WEBKIT
- html = true;
+ const bool html = true;
+#else
+ const bool html = false;
#endif
if (block()->plugin_model()) {
doc = block()->plugin_model()->documentation(html);
diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp
index f94a10e9..64ad8f66 100644
--- a/src/gui/NodeModule.hpp
+++ b/src/gui/NodeModule.hpp
@@ -17,8 +17,8 @@
#ifndef INGEN_GUI_NODEMODULE_HPP
#define INGEN_GUI_NODEMODULE_HPP
-#include "ganv/Module.hpp"
-#include "ingen/URI.hpp"
+#include <ganv/Module.hpp>
+#include <ingen/URI.hpp>
#include <gdk/gdk.h>
#include <glib.h>
@@ -42,8 +42,7 @@ class PortModel;
} // namespace client
} // namespace ingen
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
class App;
class GraphCanvas;
@@ -113,7 +112,6 @@ protected:
bool _initialised{false};
};
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
#endif // INGEN_GUI_NODEMODULE_HPP
diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp
index 87f6f9e9..8c41ff10 100644
--- a/src/gui/ObjectMenu.cpp
+++ b/src/gui/ObjectMenu.cpp
@@ -19,15 +19,15 @@
#include "App.hpp"
#include "WindowFactory.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ObjectModel.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ObjectModel.hpp>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <gtkmm/builder.h>
#include <gtkmm/checkmenuitem.h>
#include <gtkmm/menuitem.h>
@@ -39,8 +39,7 @@
#include <cstdint>
#include <memory>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
ObjectMenu::ObjectMenu(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
@@ -119,7 +118,7 @@ ObjectMenu::on_menu_polyphonic()
_app->set_property(
_object->uri(),
_app->uris().ingen_polyphonic,
- _app->forge().make(bool(_polyphonic_menuitem->get_active())));
+ _app->forge().make(_polyphonic_menuitem->get_active()));
}
}
@@ -146,5 +145,4 @@ ObjectMenu::on_menu_properties()
_app->window_factory()->present_properties(_object);
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/ObjectMenu.hpp b/src/gui/ObjectMenu.hpp
index de105364..5a4c83f4 100644
--- a/src/gui/ObjectMenu.hpp
+++ b/src/gui/ObjectMenu.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_GUI_OBJECTMENU_HPP
#define INGEN_GUI_OBJECTMENU_HPP
-#include "ingen/URI.hpp"
+#include <ingen/URI.hpp>
#include <gtkmm/menu.h>
diff --git a/src/gui/PluginMenu.cpp b/src/gui/PluginMenu.cpp
index 1993a7a7..26bbed08 100644
--- a/src/gui/PluginMenu.cpp
+++ b/src/gui/PluginMenu.cpp
@@ -16,15 +16,15 @@
#include "PluginMenu.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/PluginModel.hpp"
+#include <ingen/Log.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <lilv/lilv.h>
#include <glibmm/ustring.h>
#include <gtkmm/menu_elems.h>
#include <gtkmm/menuitem.h>
-#include <gtkmm/menushell.h>
#include <gtkmm/object.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
@@ -32,8 +32,7 @@
#include <memory>
#include <utility>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
PluginMenu::PluginMenu(ingen::World& world)
: _world(world)
@@ -127,7 +126,7 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu,
return 0;
}
- Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem(
+ const Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem(
std::string("_") + sub_label_str);
menu->items().push_back(menu_elem);
Gtk::MenuItem* menu_item = &(menu->items().back());
@@ -135,7 +134,7 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu,
Gtk::Menu* submenu = Gtk::manage(new Gtk::Menu());
menu_item->set_submenu(*submenu);
- size_t num_child_items = build_plugin_class_menu(
+ const size_t num_child_items = build_plugin_class_menu(
submenu, c, classes, children, ancestors);
_class_menus.emplace(sub_uri_str, MenuRecord(menu_item, submenu));
@@ -159,10 +158,10 @@ PluginMenu::add_plugin_to_menu(MenuRecord& menu,
LilvNode* ingen_Graph = lilv_new_uri(lworld, uris.ingen_Graph.c_str());
LilvNode* rdf_type = lilv_new_uri(lworld, uris.rdf_type.c_str());
- bool is_graph = lilv_world_ask(lworld,
- lilv_plugin_get_uri(p->lilv_plugin()),
- rdf_type,
- ingen_Graph);
+ const bool is_graph = lilv_world_ask(lworld,
+ lilv_plugin_get_uri(p->lilv_plugin()),
+ rdf_type,
+ ingen_Graph);
menu.menu->items().push_back(
Gtk::Menu_Helpers::MenuElem(
@@ -183,5 +182,4 @@ PluginMenu::load_plugin(const std::weak_ptr<client::PluginModel>& weak_plugin)
signal_load_plugin.emit(weak_plugin);
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/PluginMenu.hpp b/src/gui/PluginMenu.hpp
index b2c75ffe..eb0a565a 100644
--- a/src/gui/PluginMenu.hpp
+++ b/src/gui/PluginMenu.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_GUI_PLUGINMENU_HPP
#define INGEN_GUI_PLUGINMENU_HPP
-#include "lilv/lilv.h"
+#include <lilv/lilv.h>
#include <gtkmm/menu.h>
#include <sigc++/signal.h>
@@ -50,7 +50,7 @@ namespace gui {
class PluginMenu : public Gtk::Menu
{
public:
- PluginMenu(ingen::World& world);
+ explicit PluginMenu(ingen::World& world);
void clear();
void add_plugin(const std::shared_ptr<client::PluginModel>& p);
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 89b86184..4d11e309 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -27,30 +27,30 @@
#include "ingen_config.h"
#include "rgba.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/GraphModel.hpp" // IWYU pragma: keep
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PluginModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "lilv/lilv.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-#include "sord/sordmm.hpp"
-
-#include <glibmm/signalproxy.h>
+#include <ganv/Port.hpp>
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PluginModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <lilv/lilv.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+#include <sord/sordmm.hpp>
+
+#include <glibmm/ustring.h>
#include <gtkmm/menu.h>
#include <gtkmm/menu_elems.h>
#include <gtkmm/menuitem.h>
-#include <gtkmm/menushell.h>
#include <gtkmm/object.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
@@ -230,7 +230,7 @@ Port::on_value_changed(double value)
return; // No change
}
- const Atom atom = _app.forge().make(float(value));
+ const Atom atom = _app.forge().make(static_cast<float>(value));
_app.set_property(model()->uri(),
_app.world().uris().ingen_value,
atom);
@@ -265,7 +265,7 @@ Port::build_enum_menu()
auto block = std::dynamic_pointer_cast<BlockModel>(model()->parent());
Gtk::Menu* menu = Gtk::manage(new Gtk::Menu());
- PluginModel::ScalePoints points = block->plugin_model()->port_scale_points(
+ const PluginModel::ScalePoints points = block->plugin_model()->port_scale_points(
model()->index());
for (const auto& p : points) {
menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p.second));
@@ -316,7 +316,7 @@ Port::build_uri_menu()
rdfs::classes(world, ranges, false);
// Get all objects in range
- rdfs::Objects values = rdfs::instances(world, ranges);
+ const rdfs::Objects values = rdfs::instances(world, ranges);
// Add a menu item for each such class
for (const auto& v : values) {
@@ -553,9 +553,10 @@ Port::on_selected(gboolean b)
GraphWindow* win = _app.window_factory()->parent_graph_window(block);
if (win && win->documentation_is_visible() && block->plugin_model()) {
- bool html = false;
#if USE_WEBKIT
- html = true;
+ const bool html = true;
+#else
+ const bool html = false;
#endif
const std::string& doc = block->plugin_model()->port_documentation(
pm->index(), html);
diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp
index 8e8077bc..bfd8e15d 100644
--- a/src/gui/Port.hpp
+++ b/src/gui/Port.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_GUI_PORT_HPP
#define INGEN_GUI_PORT_HPP
-#include "ganv/Port.hpp"
+#include <ganv/Port.hpp>
#include <gdk/gdk.h>
#include <glib.h>
diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp
index 96b0788a..373425cf 100644
--- a/src/gui/PortMenu.cpp
+++ b/src/gui/PortMenu.cpp
@@ -19,24 +19,25 @@
#include "App.hpp"
#include "ObjectMenu.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/GraphModel.hpp" // IWYU pragma: keep
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/client/PortModel.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/client/PortModel.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <gtkmm/builder.h>
#include <gtkmm/checkmenuitem.h>
+#include <gtkmm/menu.h>
#include <gtkmm/menuitem.h>
#include <gtkmm/separatormenuitem.h>
#include <sigc++/functors/mem_fun.h>
diff --git a/src/gui/PortMenu.hpp b/src/gui/PortMenu.hpp
index 71a5f48b..cf7f9c62 100644
--- a/src/gui/PortMenu.hpp
+++ b/src/gui/PortMenu.hpp
@@ -19,8 +19,6 @@
#include "ObjectMenu.hpp"
-#include <gtkmm/menu.h>
-
#include <memory>
namespace Glib {
@@ -29,6 +27,7 @@ template <class T> class RefPtr;
namespace Gtk {
class Builder;
+class Menu;
class MenuItem;
} // namespace Gtk
diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp
index 4ea1536d..0dde0ab2 100644
--- a/src/gui/PropertiesWindow.cpp
+++ b/src/gui/PropertiesWindow.cpp
@@ -21,23 +21,25 @@
#include "URIEntry.hpp"
#include "Window.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "lilv/lilv.h"
-#include "lv2/urid/urid.h"
-#include "raul/Path.hpp"
-#include "sord/sordmm.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <lilv/lilv.h>
+#include <lv2/urid/urid.h>
+#include <raul/Path.hpp>
+#include <sord/sordmm.hpp>
#include <glibmm/containers.h>
#include <glibmm/propertyproxy.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
+#include <gtk/gtk.h>
#include <gtkmm/alignment.h>
#include <gtkmm/bin.h>
#include <gtkmm/box.h>
@@ -54,6 +56,7 @@
#include <gtkmm/table.h>
#include <gtkmm/treeiter.h>
#include <gtkmm/widget.h>
+#include <gtkmm/window.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
#include <sigc++/signal.h>
@@ -382,9 +385,9 @@ PropertiesWindow::create_value_widget(const URI& key,
? world.uri_map().unmap_uri(value.get<int32_t>())
: "");
- LilvNode* pred = lilv_new_uri(lworld, key.c_str());
- URISet ranges = rdfs::range(world, pred, true);
- URIEntry* widget = manage(new URIEntry(_app, ranges, str ? str : ""));
+ LilvNode* pred = lilv_new_uri(lworld, key.c_str());
+ const URISet ranges = rdfs::range(world, pred, true);
+ URIEntry* widget = manage(new URIEntry(_app, ranges, str ? str : ""));
widget->signal_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
lilv_node_free(pred);
@@ -400,10 +403,10 @@ PropertiesWindow::create_value_widget(const URI& key,
if (type == _app->uris().atom_URI ||
type == _app->uris().rdfs_Class ||
is_class) {
- LilvNode* pred = lilv_new_uri(lworld, key.c_str());
- URISet ranges = rdfs::range(world, pred, true);
- const char* str = value.is_valid() ? value.ptr<const char>() : "";
- URIEntry* widget = manage(new URIEntry(_app, ranges, str));
+ LilvNode* pred = lilv_new_uri(lworld, key.c_str());
+ const URISet ranges = rdfs::range(world, pred, true);
+ const char* str = value.is_valid() ? value.ptr<const char>() : "";
+ URIEntry* widget = manage(new URIEntry(_app, ranges, str));
widget->signal_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
lilv_node_free(pred);
@@ -482,7 +485,7 @@ PropertiesWindow::remove_property(const URI& key, const Atom& value)
Atom
PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget)
{
- Forge& forge = _app->forge();
+ const Forge& forge = _app->forge();
if (type == forge.Int) {
auto* spin = dynamic_cast<Gtk::SpinButton*>(value_widget);
@@ -501,10 +504,13 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget)
}
} else if (type == forge.URI || type == forge.URID) {
auto* uri_entry = dynamic_cast<URIEntry*>(value_widget);
- if (uri_entry && URI::is_valid(uri_entry->get_text())) {
- return _app->forge().make_urid(URI(uri_entry->get_text()));
+ if (uri_entry) {
+ if (URI::is_valid(uri_entry->get_text())) {
+ return _app->forge().make_urid(URI(uri_entry->get_text()));
+ }
+
+ _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text());
}
- _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text());
} else if (type == forge.String) {
auto* entry = dynamic_cast<Gtk::Entry*>(value_widget);
if (entry) {
@@ -542,7 +548,7 @@ PropertiesWindow::active_key() const
return "";
}
- Glib::ustring prop_uri = (*iter)[_combo_columns.uri_col];
+ const Glib::ustring prop_uri = (*iter)[_combo_columns.uri_col];
return prop_uri;
}
diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp
index 60b6bda3..e788d140 100644
--- a/src/gui/PropertiesWindow.hpp
+++ b/src/gui/PropertiesWindow.hpp
@@ -19,15 +19,14 @@
#include "Window.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/URI.hpp"
-#include "lv2/urid/urid.h"
+#include <ingen/Atom.hpp>
+#include <ingen/URI.hpp>
+#include <lv2/urid/urid.h>
#include <glibmm/refptr.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/treemodelcolumn.h>
-#include <gtkmm/window.h>
#include <sigc++/connection.h>
#include <map>
diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp
index 3a277950..09af81af 100644
--- a/src/gui/RDFS.cpp
+++ b/src/gui/RDFS.cpp
@@ -14,21 +14,20 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "lilv/lilv.h"
-
#include "RDFS.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <lilv/lilv.h>
+
#include <utility>
-namespace ingen {
-namespace gui {
-namespace rdfs {
+namespace ingen::gui::rdfs {
std::string
label(World& world, const LilvNode* node)
@@ -79,7 +78,7 @@ closure(World& world, const LilvNode* pred, URISet& types, bool super)
LILV_FOREACH (nodes, m, matches) {
const LilvNode* klass_node = lilv_nodes_get(matches, m);
if (lilv_node_is_uri(klass_node)) {
- URI klass(lilv_node_as_uri(klass_node));
+ const URI klass{lilv_node_as_uri(klass_node)};
if (!types.count(klass)) {
++added;
klasses.insert(klass);
@@ -146,8 +145,8 @@ URISet
properties(World& world,
const std::shared_ptr<const client::ObjectModel>& model)
{
- URISet properties;
- URISet types = rdfs::types(world, model);
+ URISet properties;
+ const URISet types = rdfs::types(world, model);
LilvNode* rdf_type = lilv_new_uri(world.lilv_world(),
LILV_NS_RDF "type");
@@ -257,6 +256,4 @@ is_a(World& world, const LilvNode* inst, const LilvNode* klass)
return is_instance;
}
-} // namespace rdfs
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui::rdfs
diff --git a/src/gui/RDFS.hpp b/src/gui/RDFS.hpp
index 9a212dff..e4c2b673 100644
--- a/src/gui/RDFS.hpp
+++ b/src/gui/RDFS.hpp
@@ -17,8 +17,8 @@
#ifndef INGEN_GUI_RDF_HPP
#define INGEN_GUI_RDF_HPP
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
+#include <ingen/URI.hpp>
+#include <lilv/lilv.h>
#include <map>
#include <memory>
@@ -33,9 +33,7 @@ namespace client {
class ObjectModel;
} // namespace client
-namespace gui {
-
-namespace rdfs {
+namespace gui::rdfs {
/** Set of URIs. */
using URISet = std::set<URI>;
@@ -79,8 +77,7 @@ URISet range(World& world, const LilvNode* prop, bool recursive);
/** Return true iff `inst` is-a `klass`. */
bool is_a(World& world, const LilvNode* inst, const LilvNode* klass);
-} // namespace rdfs
-} // namespace gui
+} // namespace gui::rdfs
} // namespace ingen
#endif // INGEN_GUI_RDF_HPP
diff --git a/src/gui/RenameWindow.cpp b/src/gui/RenameWindow.cpp
index e2c1e98c..569baea8 100644
--- a/src/gui/RenameWindow.cpp
+++ b/src/gui/RenameWindow.cpp
@@ -19,24 +19,24 @@
#include "App.hpp"
#include "Window.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
-#include <glibmm/signalproxy.h>
#include <glibmm/ustring.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
#include <gtkmm/entry.h>
#include <gtkmm/label.h>
+#include <gtkmm/window.h>
#include <sigc++/functors/mem_fun.h>
#include <memory>
diff --git a/src/gui/RenameWindow.hpp b/src/gui/RenameWindow.hpp
index 42db3ff6..9c97d234 100644
--- a/src/gui/RenameWindow.hpp
+++ b/src/gui/RenameWindow.hpp
@@ -19,8 +19,6 @@
#include "Window.hpp"
-#include <gtkmm/window.h>
-
#include <memory>
namespace Glib {
diff --git a/src/gui/Style.cpp b/src/gui/Style.cpp
index bce98648..f1f1b12b 100644
--- a/src/gui/Style.cpp
+++ b/src/gui/Style.cpp
@@ -18,13 +18,12 @@
#include "App.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/PortModel.hpp"
+#include <ingen/URIs.hpp>
+#include <ingen/client/PortModel.hpp>
#include <string>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
Style::Style(App& app)
: _app(app)
@@ -97,5 +96,4 @@ Style::get_port_color(const client::PortModel* p)
return 0x555555FF;
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/SubgraphModule.cpp b/src/gui/SubgraphModule.cpp
index fee602b5..a1b14bb6 100644
--- a/src/gui/SubgraphModule.cpp
+++ b/src/gui/SubgraphModule.cpp
@@ -20,16 +20,17 @@
#include "NodeModule.hpp"
#include "WindowFactory.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/GraphModel.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/GraphModel.hpp>
#include <cassert>
#include <memory>
+#include <utility>
namespace ingen {
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp
index 7c5fdd99..abbedbaf 100644
--- a/src/gui/ThreadedLoader.cpp
+++ b/src/gui/ThreadedLoader.cpp
@@ -18,29 +18,31 @@
#include "App.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Parser.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Serialiser.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Parser.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Serialiser.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <raul/Path.hpp>
+#include <raul/Semaphore.hpp>
+#include <raul/Symbol.hpp>
+
#include <glibmm/ustring.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/adaptors/retype_return.h>
#include <sigc++/functors/mem_fun.h>
#include <cassert>
+#include <filesystem>
#include <memory>
+#include <optional>
#include <string>
+#include <string_view>
#include <utility>
-using boost::optional;
-
namespace ingen {
class Interface;
@@ -76,7 +78,7 @@ void
ThreadedLoader::run()
{
while (_sem.wait() && !_exit_flag) {
- std::lock_guard<std::mutex> lock(_mutex);
+ const std::lock_guard<std::mutex> lock{_mutex};
while (!_events.empty()) {
_events.front()();
_events.pop_front();
@@ -85,20 +87,20 @@ ThreadedLoader::run()
}
void
-ThreadedLoader::load_graph(bool merge,
- const FilePath& file_path,
- const optional<raul::Path>& engine_parent,
- const optional<raul::Symbol>& engine_symbol,
- const optional<Properties>& engine_data)
+ThreadedLoader::load_graph(bool merge,
+ const FilePath& file_path,
+ const std::optional<raul::Path>& engine_parent,
+ const std::optional<raul::Symbol>& engine_symbol,
+ const std::optional<Properties>& engine_data)
{
- std::lock_guard<std::mutex> lock(_mutex);
+ const std::lock_guard<std::mutex> lock{_mutex};
Glib::ustring engine_base = "";
if (engine_parent) {
if (merge) {
- engine_base = engine_parent.get();
+ engine_base = *engine_parent;
} else {
- engine_base = engine_parent.get().base();
+ engine_base = engine_parent->base();
}
}
@@ -113,12 +115,13 @@ ThreadedLoader::load_graph(bool merge,
}
void
-ThreadedLoader::load_graph_event(const FilePath& file_path,
- const optional<raul::Path>& engine_parent,
- const optional<raul::Symbol>& engine_symbol,
- const optional<Properties>& engine_data)
+ThreadedLoader::load_graph_event(
+ const FilePath& file_path,
+ const std::optional<raul::Path>& engine_parent,
+ const std::optional<raul::Symbol>& engine_symbol,
+ const std::optional<Properties>& engine_data)
{
- std::lock_guard<std::mutex> lock(_app.world().rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()};
_app.world().parser()->parse_file(_app.world(),
*_app.world().interface(),
@@ -133,7 +136,7 @@ ThreadedLoader::save_graph(
const std::shared_ptr<const client::GraphModel>& model,
const URI& uri)
{
- std::lock_guard<std::mutex> lock(_mutex);
+ const std::lock_guard<std::mutex> lock{_mutex};
_events.emplace_back(sigc::hide_return(
sigc::bind(sigc::mem_fun(this, &ThreadedLoader::save_graph_event),
@@ -150,7 +153,7 @@ ThreadedLoader::save_graph_event(
{
assert(uri.scheme() == "file");
if (_app.serialiser()) {
- std::lock_guard<std::mutex> lock(_app.world().rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_app.world().rdf_mutex()};
if (uri.string().find(".ingen") != std::string::npos) {
_app.serialiser()->write_bundle(model, uri);
diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp
index d338b63f..27ba7c8c 100644
--- a/src/gui/ThreadedLoader.hpp
+++ b/src/gui/ThreadedLoader.hpp
@@ -17,20 +17,17 @@
#ifndef INGEN_GUI_THREADEDLOADER_HPP
#define INGEN_GUI_THREADEDLOADER_HPP
-#include "ingen/FilePath.hpp"
-#include "raul/Semaphore.hpp"
+#include <ingen/FilePath.hpp>
+#include <raul/Semaphore.hpp>
#include <sigc++/functors/slot.h>
#include <list>
#include <memory>
#include <mutex>
+#include <optional>
#include <thread>
-namespace boost {
-template <class T> class optional;
-} // namespace boost
-
namespace raul {
class Path;
class Symbol;
@@ -53,7 +50,7 @@ class App;
/** Thread for loading graph files.
*
- * This is a seperate thread so it can send all the loading message without
+ * This is a separate thread so it can send all the loading message without
* blocking everything else, so the app can respond to the incoming events
* caused as a result of the graph loading, while the graph loads.
*
@@ -70,11 +67,11 @@ public:
~ThreadedLoader();
- void load_graph(bool merge,
- const FilePath& file_path,
- const boost::optional<raul::Path>& engine_parent,
- const boost::optional<raul::Symbol>& engine_symbol,
- const boost::optional<Properties>& engine_data);
+ void load_graph(bool merge,
+ const FilePath& file_path,
+ const std::optional<raul::Path>& engine_parent,
+ const std::optional<raul::Symbol>& engine_symbol,
+ const std::optional<Properties>& engine_data);
void save_graph(const std::shared_ptr<const client::GraphModel>& model,
const URI& uri);
@@ -82,16 +79,16 @@ public:
std::shared_ptr<Parser> parser();
private:
- void load_graph_event(const FilePath& file_path,
- const boost::optional<raul::Path>& engine_parent,
- const boost::optional<raul::Symbol>& engine_symbol,
- const boost::optional<Properties>& engine_data);
+ void load_graph_event(const FilePath& file_path,
+ const std::optional<raul::Path>& engine_parent,
+ const std::optional<raul::Symbol>& engine_symbol,
+ const std::optional<Properties>& engine_data);
void
save_graph_event(const std::shared_ptr<const client::GraphModel>& model,
const URI& uri);
- /** Returns nothing and takes no parameters (because they have all been bound) */
+ /// Returns nothing and takes no parameters (because they're all bound)
using Closure = sigc::slot<void>;
void run();
diff --git a/src/gui/URIEntry.cpp b/src/gui/URIEntry.cpp
index 4ae8da10..92320009 100644
--- a/src/gui/URIEntry.cpp
+++ b/src/gui/URIEntry.cpp
@@ -19,15 +19,15 @@
#include "App.hpp"
#include "RDFS.hpp"
-#include "ingen/World.hpp"
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <lilv/lilv.h>
#include <gdk/gdk.h>
-#include <glibmm/helperlist.h>
#include <gtkmm/button.h>
#include <gtkmm/menu.h>
#include <gtkmm/menu_elems.h>
#include <gtkmm/menuitem.h>
-#include <gtkmm/menushell.h>
#include <gtkmm/object.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
@@ -35,8 +35,7 @@
#include <map>
#include <utility>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
URIEntry::URIEntry(App* app, std::set<URI> types, const std::string& value)
: Gtk::HBox(false, 4)
@@ -67,7 +66,7 @@ URIEntry::build_value_menu()
LilvNode* rdfs_Datatype = lilv_new_uri(lworld, LILV_NS_RDFS "Datatype");
LilvNode* rdfs_subClassOf = lilv_new_uri(lworld, LILV_NS_RDFS "subClassOf");
- rdfs::Objects values = rdfs::instances(world, _types);
+ const rdfs::Objects values = rdfs::instances(world, _types);
for (const auto& v : values) {
const LilvNode* inst = lilv_new_uri(lworld, v.second.c_str());
@@ -203,5 +202,4 @@ URIEntry::menu_button_event(GdkEvent* ev)
return true;
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/URIEntry.hpp b/src/gui/URIEntry.hpp
index 04dfaa41..45fa6894 100644
--- a/src/gui/URIEntry.hpp
+++ b/src/gui/URIEntry.hpp
@@ -17,8 +17,8 @@
#ifndef INGEN_GUI_URI_ENTRY_HPP
#define INGEN_GUI_URI_ENTRY_HPP
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
+#include <ingen/URI.hpp>
+#include <lilv/lilv.h>
#include <gdk/gdk.h>
#include <glibmm/signalproxy.h>
@@ -34,8 +34,7 @@ class Button;
class Menu;
} // namespace Gtk
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
class App;
@@ -73,7 +72,6 @@ private:
Gtk::Entry* _entry;
};
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
#endif // INGEN_GUI_URI_ENTRY_HPP
diff --git a/src/gui/WidgetFactory.cpp b/src/gui/WidgetFactory.cpp
index d70a5084..33660d77 100644
--- a/src/gui/WidgetFactory.cpp
+++ b/src/gui/WidgetFactory.cpp
@@ -16,16 +16,14 @@
#include "WidgetFactory.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/runtime_paths.hpp"
+#include <ingen/runtime_paths.hpp>
#include <cstdlib>
#include <fstream>
#include <stdexcept>
#include <string>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
Glib::ustring WidgetFactory::ui_filename = "";
@@ -77,5 +75,4 @@ WidgetFactory::create(const std::string& toplevel_widget)
return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str());
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
diff --git a/src/gui/WidgetFactory.hpp b/src/gui/WidgetFactory.hpp
index d2f449ee..d10a5e1a 100644
--- a/src/gui/WidgetFactory.hpp
+++ b/src/gui/WidgetFactory.hpp
@@ -19,12 +19,11 @@
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
-#include <gtkmm/builder.h> // IWYU pragma: keep
+#include <gtkmm/builder.h>
#include <string>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
/** Loads widgets from an XML description.
* Purely static.
@@ -39,13 +38,13 @@ public:
template<typename T>
static void get_widget(const Glib::ustring& name, T*& widget) {
- Glib::RefPtr<Gtk::Builder> xml = create(name);
+ const Glib::RefPtr<Gtk::Builder> xml = create(name);
xml->get_widget(name, widget);
}
template<typename T>
static void get_widget_derived(const Glib::ustring& name, T*& widget) {
- Glib::RefPtr<Gtk::Builder> xml = create(name);
+ const Glib::RefPtr<Gtk::Builder> xml = create(name);
xml->get_widget_derived(name, widget);
}
@@ -54,7 +53,6 @@ private:
static Glib::ustring ui_filename;
};
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
#endif // INGEN_GUI_WIDGETFACTORY_HPP
diff --git a/src/gui/Window.hpp b/src/gui/Window.hpp
index fa2016a8..756ba8f0 100644
--- a/src/gui/Window.hpp
+++ b/src/gui/Window.hpp
@@ -22,9 +22,7 @@
#include <gtkmm/dialog.h>
#include <gtkmm/window.h>
-namespace ingen {
-
-namespace gui {
+namespace ingen::gui {
class App;
@@ -80,7 +78,6 @@ public:
App* _app = nullptr;
};
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
#endif // INGEN_GUI_WINDOW_HPP
diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp
index 8928b664..78acf4fb 100644
--- a/src/gui/WindowFactory.cpp
+++ b/src/gui/WindowFactory.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -26,16 +26,17 @@
#include "RenameWindow.hpp"
#include "WidgetFactory.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/client/BlockModel.hpp"
-#include "ingen/client/GraphModel.hpp"
-#include "ingen/client/ObjectModel.hpp"
+#include <ingen/Log.hpp>
+#include <ingen/client/BlockModel.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <raul/Path.hpp>
#include <gdkmm/window.h>
-#include <glibmm/signalproxy.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/functors/mem_fun.h>
+#include <algorithm>
#include <cassert>
#include <memory>
#include <stdexcept>
@@ -44,6 +45,8 @@
namespace ingen {
+class Properties;
+
using client::BlockModel;
using client::GraphModel;
using client::ObjectModel;
@@ -93,14 +96,9 @@ WindowFactory::clear()
size_t
WindowFactory::num_open_graph_windows()
{
- size_t ret = 0;
- for (const auto& w : _graph_windows) {
- if (w.second->is_visible()) {
- ++ret;
- }
- }
-
- return ret;
+ return std::count_if(_graph_windows.begin(),
+ _graph_windows.end(),
+ [](const auto& w) { return w.second->is_visible(); });
}
GraphBox*
@@ -226,7 +224,7 @@ WindowFactory::present_load_plugin(
int width = 0;
int height = 0;
w->second->get_size(width, height);
- _load_plugin_win->set_default_size(width - width / 8, height / 2);
+ _load_plugin_win->set_default_size(width - (width / 8), height / 2);
}
_load_plugin_win->set_title(
std::string("Load Plugin - ") + graph->path() + " - Ingen");
diff --git a/src/gui/WindowFactory.hpp b/src/gui/WindowFactory.hpp
index 4ef79239..e643505a 100644
--- a/src/gui/WindowFactory.hpp
+++ b/src/gui/WindowFactory.hpp
@@ -17,15 +17,14 @@
#ifndef INGEN_GUI_WINDOWFACTORY_HPP
#define INGEN_GUI_WINDOWFACTORY_HPP
-#include "ingen/Properties.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Properties.hpp>
+#include <raul/Path.hpp>
#include <gdk/gdk.h>
#include <cstddef>
#include <map>
#include <memory>
-#include <string>
namespace ingen {
diff --git a/src/gui/ingen_gui.cpp b/src/gui/ingen_gui.cpp
index 329e098f..7fba2d50 100644
--- a/src/gui/ingen_gui.cpp
+++ b/src/gui/ingen_gui.cpp
@@ -16,27 +16,27 @@
#include "App.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Module.hpp"
-#include "ingen/QueuedInterface.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/SigClientInterface.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Module.hpp>
+#include <ingen/QueuedInterface.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/SigClientInterface.hpp>
#include <glibmm/thread.h>
#include <memory>
+#include <string>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
struct GUIModule : public Module {
using SigClientInterface = client::SigClientInterface;
void load(World& world) override {
- URI uri(world.conf().option("connect").ptr<char>());
+ const URI uri{world.conf().option("connect").ptr<char>()};
if (!world.interface()) {
world.set_interface(
world.new_interface(URI(uri), make_client(world)));
@@ -63,8 +63,7 @@ struct GUIModule : public Module {
std::shared_ptr<gui::App> app;
};
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
extern "C" {
diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp
index d80d92c0..67290c76 100644
--- a/src/gui/ingen_gui_lv2.cpp
+++ b/src/gui/ingen_gui_lv2.cpp
@@ -17,28 +17,28 @@
#include "App.hpp"
#include "GraphBox.hpp"
-#include "ingen/AtomReader.hpp"
-#include "ingen/AtomSink.hpp"
-#include "ingen/AtomWriter.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/GraphModel.hpp" // IWYU pragma: keep
-#include "ingen/client/SigClientInterface.hpp"
-#include "ingen/ingen.h"
-#include "ingen/paths.hpp"
-#include "ingen/runtime_paths.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/core/lv2.h"
-#include "lv2/log/log.h"
-#include "lv2/ui/ui.h"
-#include "lv2/urid/urid.h"
-#include "raul/Path.hpp"
+#include <ingen/AtomReader.hpp>
+#include <ingen/AtomSink.hpp>
+#include <ingen/AtomWriter.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ClientStore.hpp>
+#include <ingen/client/GraphModel.hpp>
+#include <ingen/client/SigClientInterface.hpp>
+#include <ingen/ingen.h>
+#include <ingen/paths.hpp>
+#include <ingen/runtime_paths.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/core/lv2.h>
+#include <lv2/log/log.h>
+#include <lv2/ui/ui.h>
+#include <lv2/urid/urid.h>
+#include <raul/Path.hpp>
#include <cstdint>
#include <cstring>
@@ -49,7 +49,8 @@
namespace ingen {
/** A sink that writes atoms to a port via the UI extension. */
-struct IngenLV2AtomSink : public AtomSink {
+class IngenLV2AtomSink : public AtomSink {
+public:
IngenLV2AtomSink(URIs& uris,
LV2UI_Write_Function ui_write,
LV2UI_Controller ui_controller)
@@ -67,14 +68,13 @@ struct IngenLV2AtomSink : public AtomSink {
return true;
}
+private:
URIs& _uris;
LV2UI_Write_Function _ui_write;
LV2UI_Controller _ui_controller;
};
struct IngenLV2UI {
- IngenLV2UI() = default;
-
int argc{0};
char** argv{nullptr};
Forge* forge{nullptr};
diff --git a/src/gui/meson.build b/src/gui/meson.build
index 67914cca..810c7829 100644
--- a/src/gui/meson.build
+++ b/src/gui/meson.build
@@ -7,35 +7,47 @@
gui_defines = platform_defines
-glibmm_dep = dependency('glibmm-2.4',
- version: '>= 2.14.0',
- include_type: 'system',
- required: get_option('gui'))
-
-gthread_dep = dependency('gthread-2.0',
- version: '>= 2.14.0',
- include_type: 'system',
- required: get_option('gui'))
-
-gtkmm_dep = dependency('gtkmm-2.4',
- version: '>= 2.14.0',
- include_type: 'system',
- required: get_option('gui'))
-
-ganv_dep = dependency('ganv-1',
- version: '>= 1.5.2',
- fallback: ['ganv', 'ganv_dep'],
- required: get_option('gui'))
-
-webkit_dep = dependency('webkit-1.0',
- version: '>= 1.4.0',
- include_type: 'system',
- required: false)
-
-build_gui = (glibmm_dep.found() and
- gthread_dep.found() and
- gtkmm_dep.found() and
- ganv_dep.found())
+glibmm_dep = dependency(
+ 'glibmm-2.4',
+ include_type: 'system',
+ required: get_option('gui'),
+ version: '>= 2.14.0',
+)
+
+gthread_dep = dependency(
+ 'gthread-2.0',
+ include_type: 'system',
+ required: get_option('gui'),
+ version: '>= 2.14.0',
+)
+
+gtkmm_dep = dependency(
+ 'gtkmm-2.4',
+ include_type: 'system',
+ required: get_option('gui'),
+ version: '>= 2.14.0',
+)
+
+ganv_dep = dependency(
+ 'ganv-1',
+ include_type: 'system',
+ required: get_option('gui'),
+ version: '>= 1.5.2',
+)
+
+webkit_dep = dependency(
+ 'webkit-1.0',
+ include_type: 'system',
+ required: false,
+ version: '>= 1.4.0',
+)
+
+build_gui = (
+ glibmm_dep.found()
+ and gthread_dep.found()
+ and gtkmm_dep.found()
+ and ganv_dep.found()
+)
if webkit_dep.found()
gui_defines += ['-DHAVE_WEBKIT=1']
@@ -149,15 +161,19 @@ if build_gui
config = configuration_data()
config.set('INGEN_VERSION', meson.project_version())
- configure_file(configuration: config,
- input: files('ingen_gui.ui.in'),
- output: 'ingen_gui.ui',
- install: true,
- install_dir: ingen_data_dir)
-
- configure_file(copy: true,
- input: files('ingen_style.rc'),
- output: '@PLAINNAME@',
- install: true,
- install_dir: ingen_data_dir)
+ configure_file(
+ configuration: config,
+ input: files('ingen_gui.ui.in'),
+ install: true,
+ install_dir: ingen_data_dir,
+ output: 'ingen_gui.ui',
+ )
+
+ configure_file(
+ copy: true,
+ input: files('ingen_style.rc'),
+ install: true,
+ install_dir: ingen_data_dir,
+ output: '@PLAINNAME@',
+ )
endif
diff --git a/src/gui/rgba.hpp b/src/gui/rgba.hpp
index 0d2c57aa..e01a069d 100644
--- a/src/gui/rgba.hpp
+++ b/src/gui/rgba.hpp
@@ -20,8 +20,7 @@
#include <cmath>
#include <cstdint>
-namespace ingen {
-namespace gui {
+namespace ingen::gui {
inline uint32_t
rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
@@ -35,7 +34,7 @@ rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
inline uint8_t
mono_interpolate(uint8_t v1, uint8_t v2, float f)
{
- return static_cast<uint8_t>(rintf((v2) * (f) + (v1) * (1 - (f))));
+ return static_cast<uint8_t>(rintf((v2 * f) + (v1 * (1.0f - f))));
}
#define RGBA_R(x) (static_cast<uint32_t>(x) >> 24)
@@ -53,7 +52,6 @@ rgba_interpolate(uint32_t c1, uint32_t c2, float f)
mono_interpolate(RGBA_A(c1), RGBA_A(c2), f));
}
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui
#endif // INGEN_GUI_RGBA_HPP
diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp
index 06d990f2..7f1a587e 100644
--- a/src/ingen/ingen.cpp
+++ b/src/ingen/ingen.cpp
@@ -14,29 +14,26 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/EngineBase.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Parser.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/World.hpp"
-#include "ingen/fmt.hpp"
-#include "ingen/paths.hpp"
-#include "ingen/runtime_paths.hpp"
-#include "ingen_config.h"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-#include "serd/serd.h"
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/EngineBase.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Parser.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <ingen/fmt.hpp>
+#include <ingen/paths.hpp>
+#include <ingen/runtime_paths.hpp>
+#include <ingen_config.h>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+#include <serd/serd.h>
#if USE_SOCKET
#include "ingen/client/SocketClient.hpp"
#endif
-#include <boost/optional/optional.hpp>
-
#include <chrono>
#include <csignal>
#include <cstdint>
@@ -45,6 +42,7 @@
#include <iostream>
#include <memory>
#include <mutex>
+#include <optional>
#include <string>
#include <thread>
@@ -133,7 +131,7 @@ run(int argc, char** argv)
ingen_try(world->load_module("server"), "Failed to load server module");
- ingen_try(bool(world->engine()), "Unable to create engine");
+ ingen_try(!!world->engine(), "Unable to create engine");
world->engine()->listen();
}
@@ -180,8 +178,8 @@ run(int argc, char** argv)
// Load a graph
if (conf.option("load").is_valid()) {
- boost::optional<raul::Path> parent;
- boost::optional<raul::Symbol> symbol;
+ std::optional<raul::Path> parent;
+ std::optional<raul::Symbol> symbol;
const Atom& path_option = conf.option("path");
if (path_option.is_valid()) {
@@ -197,14 +195,14 @@ run(int argc, char** argv)
}
}
- ingen_try(bool(world->parser()), "Failed to create parser");
+ ingen_try(!!world->parser(), "Failed to create parser");
const std::string graph = conf.option("load").ptr<char>();
engine_interface->get(URI("ingen:/plugins"));
engine_interface->get(main_uri());
- std::lock_guard<std::mutex> lock(world->rdf_mutex());
+ const std::lock_guard<std::mutex> lock{world->rdf_mutex()};
world->parser()->parse_file(
*world, *engine_interface, graph, parent, symbol);
} else if (conf.option("server-load").is_valid()) {
diff --git a/src/meson.build b/src/meson.build
index 6c83ae95..bbd4bb5f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -2,12 +2,12 @@
# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later
sources = files(
+ 'AtomForge.cpp',
'AtomReader.cpp',
'AtomWriter.cpp',
'ClashAvoider.cpp',
'ColorContext.cpp',
'Configuration.cpp',
- 'FilePath.cpp',
'Forge.cpp',
'LV2Features.cpp',
'Library.cpp',
@@ -22,7 +22,7 @@ sources = files(
'URIMap.cpp',
'URIs.cpp',
'World.cpp',
- 'runtime_paths.cpp'
+ 'runtime_paths.cpp',
)
if have_socket
@@ -31,26 +31,30 @@ endif
ingen_deps = [
boost_dep,
- lilv_dep,
lv2_dep,
raul_dep,
serd_dep,
+ thread_dep,
+
sord_dep,
+
+ lilv_dep,
sratom_dep,
- thread_dep,
]
ingen_include_dirs = include_directories('../include', 'include')
libingen = shared_library(
- 'ingen' + library_suffix,
+ versioned_name,
sources,
cpp_args: cpp_suppressions + platform_defines,
+ darwin_versions: [major_version + '.0.0', meson.project_version()],
dependencies: ingen_deps,
gnu_symbol_visibility: 'hidden',
implicit_include_directories: false,
include_directories: ingen_include_dirs,
install: true,
+ soversion: soversion,
version: meson.project_version(),
)
diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp
index 86315be8..17167e9a 100644
--- a/src/runtime_paths.cpp
+++ b/src/runtime_paths.cpp
@@ -14,15 +14,15 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/runtime_paths.hpp"
+#include <ingen/runtime_paths.hpp>
+
+#include <ingen/FilePath.hpp>
-#include "ingen/FilePath.hpp"
-#include "ingen/filesystem.hpp"
#include "ingen_config.h"
-#include <algorithm>
#include <cstdlib>
#include <dlfcn.h>
+#include <filesystem>
#include <sstream>
#include <string>
@@ -45,7 +45,8 @@ static const char* const library_suffix = ".so";
#endif
static std::vector<FilePath>
-parse_search_path(const char* search_path, std::vector<FilePath> defaults)
+parse_search_path(const char* search_path,
+ const std::vector<FilePath>& defaults)
{
if (!search_path) {
return defaults;
@@ -92,7 +93,7 @@ find_in_search_path(const std::string& name,
{
for (const auto& dir : search_path) {
FilePath path = dir / name;
- if (filesystem::exists(path)) {
+ if (std::filesystem::exists(path)) {
return path;
}
}
diff --git a/src/server/.clang-tidy b/src/server/.clang-tidy
index 51c9b102..a580cc7e 100644
--- a/src/server/.clang-tidy
+++ b/src/server/.clang-tidy
@@ -1,7 +1,7 @@
Checks: >
-*-avoid-c-arrays,
+ -*-narrowing-conversions,
-*-non-private-member-variables-in-classes,
- -*-uppercase-literal-suffix,
-*-vararg,
-bugprone-branch-clone,
-bugprone-parent-virtual-call,
@@ -10,7 +10,6 @@ Checks: >
-cert-dcl37-c,
-cert-dcl51-cpp,
-cppcoreguidelines-pro-bounds-constant-array-index,
- -cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-static-cast-downcast,
-google-readability-todo,
-google-runtime-int,
diff --git a/src/server/ArcImpl.cpp b/src/server/ArcImpl.cpp
index 689be199..2c5b4ee1 100644
--- a/src/server/ArcImpl.cpp
+++ b/src/server/ArcImpl.cpp
@@ -22,15 +22,14 @@
#include "PortImpl.hpp"
#include "PortType.hpp"
-#include "ingen/URIs.hpp"
-#include "raul/Path.hpp"
+#include <ingen/URIs.hpp>
+#include <raul/Path.hpp>
#include <algorithm>
#include <cassert>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** Constructor for an arc from a block's output port.
*
@@ -85,33 +84,30 @@ ArcImpl::can_connect(const PortImpl* src, const InputPort* dst)
{
const ingen::URIs& uris = src->bufs().uris();
return (
- // (Audio | Control | CV) => (Audio | Control | CV)
- ( (src->is_a(PortType::ID::CONTROL) ||
- src->is_a(PortType::ID::AUDIO) ||
- src->is_a(PortType::ID::CV))
- && (dst->is_a(PortType::ID::CONTROL)
- || dst->is_a(PortType::ID::AUDIO)
- || dst->is_a(PortType::ID::CV)))
+ // (Audio | Control | CV) => (Audio | Control | CV)
+ ((src->is_a(PortType::CONTROL) || src->is_a(PortType::AUDIO) ||
+ src->is_a(PortType::CV)) &&
+ (dst->is_a(PortType::CONTROL) || dst->is_a(PortType::AUDIO) ||
+ dst->is_a(PortType::CV)))
- // Equal types
- || (src->type() == dst->type() &&
- src->buffer_type() == dst->buffer_type())
+ // Equal types
+ ||
+ (src->type() == dst->type() && src->buffer_type() == dst->buffer_type())
- // Control => atom:Float Value
- || (src->is_a(PortType::ID::CONTROL) && dst->supports(uris.atom_Float))
+ // Control => atom:Float Value
+ || (src->is_a(PortType::CONTROL) && dst->supports(uris.atom_Float))
- // Audio => atom:Sound Value
- || (src->is_a(PortType::ID::AUDIO) && dst->supports(uris.atom_Sound))
+ // Audio => atom:Sound Value
+ || (src->is_a(PortType::AUDIO) && dst->supports(uris.atom_Sound))
- // atom:Float Value => Control
- || (src->supports(uris.atom_Float) && dst->is_a(PortType::ID::CONTROL))
+ // atom:Float Value => Control
+ || (src->supports(uris.atom_Float) && dst->is_a(PortType::CONTROL))
- // atom:Float Value => CV
- || (src->supports(uris.atom_Float) && dst->is_a(PortType::ID::CV))
+ // atom:Float Value => CV
+ || (src->supports(uris.atom_Float) && dst->is_a(PortType::CV))
- // atom:Sound Value => Audio
- || (src->supports(uris.atom_Sound) && dst->is_a(PortType::ID::AUDIO)));
+ // atom:Sound Value => Audio
+ || (src->supports(uris.atom_Sound) && dst->is_a(PortType::AUDIO)));
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/ArcImpl.hpp b/src/server/ArcImpl.hpp
index 5e7e4357..5be51187 100644
--- a/src/server/ArcImpl.hpp
+++ b/src/server/ArcImpl.hpp
@@ -17,23 +17,16 @@
#ifndef INGEN_ENGINE_ARC_IMPL_HPP
#define INGEN_ENGINE_ARC_IMPL_HPP
-// IWYU pragma: no_include "raul/Path.hpp"
-
#include "BufferRef.hpp"
-#include "ingen/Arc.hpp"
-#include "raul/Noncopyable.hpp"
+#include <ingen/Arc.hpp>
+#include <raul/Noncopyable.hpp>
#include <boost/intrusive/slist_hook.hpp>
#include <cstdint>
-namespace raul {
-class Path; // IWYU pragma: keep
-} // namespace raul
-
-namespace ingen {
-namespace server {
+namespace ingen::server {
class InputPort;
class PortImpl;
@@ -83,7 +76,6 @@ protected:
PortImpl* const _head;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_ARC_IMPL_HPP
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 2b80f037..a70de0b6 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -22,26 +22,27 @@
#include "PortType.hpp"
#include "ThreadManager.hpp"
-#include "ingen/LV2Features.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "internals/BlockDelay.hpp"
-#include "internals/Controller.hpp"
-#include "internals/Note.hpp"
-#include "internals/Time.hpp"
-#include "internals/Trigger.hpp"
-#include "lilv/lilv.h"
+#include <ingen/LV2Features.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <internals/BlockDelay.hpp>
+#include <internals/Controller.hpp>
+#include <internals/Note.hpp>
+#include <internals/Time.hpp>
+#include <internals/Trigger.hpp>
+#include <lilv/lilv.h>
#include <algorithm>
#include <cstdint>
#include <iterator>
#include <memory>
+#include <string>
#include <utility>
#include <vector>
-namespace ingen {
-namespace server {
+namespace ingen::server {
BlockFactory::BlockFactory(ingen::World& world)
: _world(world)
@@ -149,8 +150,10 @@ BlockFactory::load_lv2_plugins()
// Build an array of port type nodes for checking compatibility
using Types = std::vector<std::shared_ptr<LilvNode>>;
Types types;
- for (unsigned t = PortType::ID::AUDIO; t <= PortType::ID::ATOM; ++t) {
- const URI& uri(PortType(static_cast<PortType::ID>(t)).uri());
+ for (auto t = static_cast<unsigned>(PortType::AUDIO);
+ t <= static_cast<unsigned>(PortType::ATOM);
+ ++t) {
+ const URI uri = port_type_uri(static_cast<PortType>(t));
types.push_back(std::shared_ptr<LilvNode>(
lilv_new_uri(_world.lilv_world(), uri.c_str()), lilv_node_free));
}
@@ -187,13 +190,13 @@ BlockFactory::load_lv2_plugins()
const uint32_t n_ports = lilv_plugin_get_num_ports(lv2_plug);
for (uint32_t p = 0; p < n_ports; ++p) {
const LilvPort* port = lilv_plugin_get_port_by_index(lv2_plug, p);
- supported = false;
- for (const auto& t : types) {
- if (lilv_port_is_a(lv2_plug, port, t.get())) {
- supported = true;
- break;
- }
- }
+ supported =
+ std::any_of(types.begin(),
+ types.end(),
+ [&lv2_plug, &port](const auto& t) {
+ return lilv_port_is_a(lv2_plug, port, t.get());
+ });
+
if (!supported &&
!lilv_port_has_property(lv2_plug,
port,
@@ -221,5 +224,4 @@ BlockFactory::load_lv2_plugins()
_world.log().info("Loaded %1% plugins\n", _plugins.size());
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/BlockFactory.hpp b/src/server/BlockFactory.hpp
index 17c11bb4..68699d8a 100644
--- a/src/server/BlockFactory.hpp
+++ b/src/server/BlockFactory.hpp
@@ -17,8 +17,8 @@
#ifndef INGEN_ENGINE_BLOCKFACTORY_HPP
#define INGEN_ENGINE_BLOCKFACTORY_HPP
-#include "ingen/URI.hpp"
-#include "raul/Noncopyable.hpp"
+#include <ingen/URI.hpp>
+#include <raul/Noncopyable.hpp>
#include <map>
#include <memory>
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index 81474126..b4f407c3 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -20,20 +20,21 @@
#include "GraphImpl.hpp"
#include "PluginImpl.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "RunContext.hpp"
#include "ThreadManager.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Symbol.hpp"
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Symbol.hpp>
+#include <algorithm>
#include <cassert>
#include <cstdint>
#include <initializer_list>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
BlockImpl::BlockImpl(PluginImpl* plugin,
const raul::Symbol& symbol,
@@ -201,10 +202,10 @@ BlockImpl::bypass(RunContext& ctx)
}
// Dumb bypass
- for (PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) {
+ for (const PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) {
for (uint32_t i = 0;; ++i) {
- PortImpl* in = nth_port_by_type(i, true, t);
- PortImpl* out = nth_port_by_type(i, false, t);
+ const PortImpl* in = nth_port_by_type(i, true, t);
+ const PortImpl* out = nth_port_by_type(i, false, t);
if (!out) {
break; // Finished writing all outputs
}
@@ -241,13 +242,11 @@ BlockImpl::process(RunContext& ctx)
// Find earliest offset of a value change
SampleCount chunk_end = ctx.nframes();
for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
- PortImpl* const port = _ports->at(i);
+ const PortImpl* const port = _ports->at(i);
if (port->type() == PortType::CONTROL && port->is_input()) {
const SampleCount o = port->next_value_offset(
offset, ctx.nframes());
- if (o < chunk_end) {
- chunk_end = o;
- }
+ chunk_end = std::min(o, chunk_end);
}
}
@@ -265,7 +264,7 @@ BlockImpl::process(RunContext& ctx)
// Emit control port outputs as events
for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
- PortImpl* const port = _ports->at(i);
+ const PortImpl* const port = _ports->at(i);
if (port->type() == PortType::CONTROL && port->is_output()) {
// TODO: Only emit events when value has actually changed?
for (uint32_t v = 0; v < _polyphony; ++v) {
@@ -297,5 +296,4 @@ BlockImpl::set_port_buffer(uint32_t, uint32_t, const BufferRef&, SampleCount)
<< " buffer " << buf << " offset " << offset << std::endl;*/
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index 9d63f78e..69564ff4 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -19,24 +19,22 @@
#include "BufferRef.hpp"
#include "NodeImpl.hpp"
-#include "PortType.hpp"
#include "State.hpp"
#include "types.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <lilv/lilv.h>
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
#include <boost/intrusive/slist_hook.hpp>
-#include <boost/optional/optional.hpp>
#include <cstdint>
#include <memory>
+#include <optional>
#include <set>
namespace raul {
@@ -44,6 +42,9 @@ class Symbol;
} // namespace raul
namespace ingen {
+
+enum class PortType;
+
namespace server {
class BufferFactory;
@@ -115,14 +116,16 @@ public:
{}
/** Save current state as preset. */
- virtual boost::optional<Resource>
- save_preset(const URI& bundle,
- const Properties& props) { return {}; }
+ virtual std::optional<Resource>
+ save_preset(const URI& bundle, const Properties& props)
+ {
+ return std::nullopt;
+ }
/** Learn the next incoming MIDI event (for internals) */
virtual void learn() {}
- /** Do whatever needs doing in the process thread before process() is called */
+ /** Do any necessary preparation in the process thread before process(). */
virtual void pre_process(RunContext& ctx);
/** Run block for an entire process cycle (calls run()). */
diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp
index 04fbdba0..76b21fc6 100644
--- a/src/server/Broadcaster.cpp
+++ b/src/server/Broadcaster.cpp
@@ -19,18 +19,17 @@
#include "BlockFactory.hpp"
#include "PluginImpl.hpp"
-#include "ingen/Interface.hpp"
+#include <ingen/Interface.hpp>
#include <cstddef>
#include <memory>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
Broadcaster::~Broadcaster()
{
- std::lock_guard<std::mutex> lock(_clients_mutex);
+ const std::lock_guard<std::mutex> lock{_clients_mutex};
_clients.clear();
_broadcastees.clear();
}
@@ -40,7 +39,7 @@ Broadcaster::~Broadcaster()
void
Broadcaster::register_client(const std::shared_ptr<Interface>& client)
{
- std::lock_guard<std::mutex> lock(_clients_mutex);
+ const std::lock_guard<std::mutex> lock{_clients_mutex};
_clients.insert(client);
}
@@ -51,7 +50,7 @@ Broadcaster::register_client(const std::shared_ptr<Interface>& client)
bool
Broadcaster::unregister_client(const std::shared_ptr<Interface>& client)
{
- std::lock_guard<std::mutex> lock(_clients_mutex);
+ const std::lock_guard<std::mutex> lock{_clients_mutex};
const size_t erased = _clients.erase(client);
_broadcastees.erase(client);
return (erased > 0);
@@ -72,7 +71,7 @@ Broadcaster::set_broadcast(const std::shared_ptr<Interface>& client,
void
Broadcaster::send_plugins(const BlockFactory::Plugins& plugins)
{
- std::lock_guard<std::mutex> lock(_clients_mutex);
+ const std::lock_guard<std::mutex> lock{_clients_mutex};
for (const auto& c : _clients) {
send_plugins_to(c.get(), plugins);
}
@@ -92,5 +91,4 @@ Broadcaster::send_plugins_to(Interface* client,
client->bundle_end();
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp
index 39acca04..4cdf65ca 100644
--- a/src/server/Broadcaster.hpp
+++ b/src/server/Broadcaster.hpp
@@ -19,18 +19,17 @@
#include "BlockFactory.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/URI.hpp"
-#include "raul/Noncopyable.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/URI.hpp>
+#include <raul/Noncopyable.hpp>
#include <atomic>
#include <memory>
#include <mutex>
#include <set>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** Broadcaster for all clients.
*
@@ -98,7 +97,7 @@ public:
send_plugins_to(Interface*, const BlockFactory::Plugins& plugins);
void message(const Message& msg) override {
- std::lock_guard<std::mutex> lock(_clients_mutex);
+ const std::lock_guard<std::mutex> lock{_clients_mutex};
for (const auto& c : _clients) {
if (c != _ignore_client) {
c->message(msg);
@@ -121,7 +120,6 @@ private:
std::shared_ptr<Interface> _ignore_client;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_BROADCASTER_HPP
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index f561871f..0c4c0951 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -18,15 +18,16 @@
#include "BufferFactory.hpp"
#include "Engine.hpp"
+#include "PortType.hpp"
#include "RunContext.hpp"
#include "ingen_config.h"
-#include "ingen/Atom.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/urid/urid.h"
+#include <ingen/Atom.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/urid/urid.h>
#include <algorithm>
#include <cstdint>
@@ -38,8 +39,7 @@
# include <xmmintrin.h>
#endif
-namespace ingen {
-namespace server {
+namespace ingen::server {
Buffer::Buffer(BufferFactory& bufs,
LV2_URID type,
@@ -172,7 +172,12 @@ void
Buffer::resize(uint32_t capacity)
{
if (!_external) {
- _buf = realloc(_buf, capacity);
+ void* const new_buf = realloc(_buf, capacity);
+ if (!new_buf) {
+ throw std::bad_alloc{};
+ }
+
+ _buf = new_buf;
_capacity = capacity;
clear();
} else {
@@ -183,18 +188,18 @@ Buffer::resize(uint32_t capacity)
void*
Buffer::port_data(PortType port_type, SampleCount offset)
{
- switch (port_type.id()) {
- case PortType::ID::CONTROL:
+ switch (port_type) {
+ case PortType::CONTROL:
return &_value_buffer->get<LV2_Atom_Float>()->body;
- case PortType::ID::CV:
- case PortType::ID::AUDIO:
+ case PortType::CV:
+ case PortType::AUDIO:
if (_type == _factory.uris().atom_Float) {
return &get<LV2_Atom_Float>()->body;
} else if (_type == _factory.uris().atom_Sound) {
return static_cast<Sample*>(_buf) + offset;
}
break;
- case PortType::ID::ATOM:
+ case PortType::ATOM:
if (_type != _factory.uris().atom_Sound) {
return _buf;
}
@@ -208,8 +213,7 @@ Buffer::port_data(PortType port_type, SampleCount offset)
const void*
Buffer::port_data(PortType port_type, SampleCount offset) const
{
- return const_cast<void*>(
- const_cast<Buffer*>(this)->port_data(port_type, offset));
+ return const_cast<Buffer*>(this)->port_data(port_type, offset);
}
#ifdef __SSE__
@@ -436,7 +440,7 @@ void* Buffer::aligned_alloc(size_t size)
{
#if USE_POSIX_MEMALIGN
void* buf = nullptr;
- if (!posix_memalign(static_cast<void**>(&buf), 16, size)) {
+ if (!posix_memalign(&buf, 16, size)) {
memset(buf, 0, size);
return buf;
}
@@ -458,5 +462,4 @@ intrusive_ptr_release(Buffer* b)
b->deref();
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 8a64e621..2c32076b 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -19,13 +19,12 @@
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
-#include "PortType.hpp"
#include "server.h"
#include "types.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/urid/urid.h"
+#include <ingen/URIs.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/urid/urid.h>
#include <atomic>
#include <cassert>
@@ -34,6 +33,8 @@
namespace ingen {
+enum class PortType;
+
class Atom;
namespace server {
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index 8ed4eaae..b8f6ee35 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -19,17 +19,16 @@
#include "Buffer.hpp"
#include "Engine.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/urid/urid.h"
+#include <ingen/Log.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/urid/urid.h>
#include <algorithm>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
BufferFactory::BufferFactory(Engine& engine, URIs& uris)
: _free_audio(nullptr)
@@ -110,7 +109,7 @@ BufferFactory::default_size(LV2_URID type) const
}
if (type == _uris.atom_Sequence) {
- if (_seq_size == 0) {
+ if (_seq_size == 0U) {
return _engine.sequence_size();
}
@@ -199,5 +198,4 @@ BufferFactory::recycle(Buffer* buf)
} while (!head_ptr.compare_exchange_weak(try_head, buf));
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp
index 657ce7d2..dbadaede 100644
--- a/src/server/BufferFactory.hpp
+++ b/src/server/BufferFactory.hpp
@@ -17,13 +17,13 @@
#ifndef INGEN_ENGINE_BUFFERFACTORY_HPP
#define INGEN_ENGINE_BUFFERFACTORY_HPP
-#include "ingen/URIs.hpp"
-#include "lv2/urid/urid.h"
-#include "server.h"
-
#include "BufferRef.hpp"
+#include "server.h"
#include "types.hpp"
+#include <ingen/URIs.hpp>
+#include <lv2/urid/urid.h>
+
#include <atomic>
#include <cstdint>
#include <mutex>
@@ -111,7 +111,7 @@ private:
std::mutex _mutex;
Engine& _engine;
URIs& _uris;
- uint32_t _seq_size{0};
+ uint32_t _seq_size{0U};
BufferRef _silent_buffer;
};
diff --git a/src/server/BufferRef.hpp b/src/server/BufferRef.hpp
index bb692001..cc5b840f 100644
--- a/src/server/BufferRef.hpp
+++ b/src/server/BufferRef.hpp
@@ -21,8 +21,7 @@
#include <boost/smart_ptr/intrusive_ptr.hpp> // IWYU pragma: export
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Buffer;
@@ -32,7 +31,6 @@ using BufferRef = boost::intrusive_ptr<Buffer>;
INGEN_SERVER_API void intrusive_ptr_add_ref(Buffer* b);
INGEN_SERVER_API void intrusive_ptr_release(Buffer* b);
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_BUFFER_REF_HPP
diff --git a/src/server/ClientUpdate.cpp b/src/server/ClientUpdate.cpp
index 5034257b..008e9843 100644
--- a/src/server/ClientUpdate.cpp
+++ b/src/server/ClientUpdate.cpp
@@ -23,11 +23,14 @@
#include "PortImpl.hpp"
#include "PortType.hpp"
-#include "ingen/Arc.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/URIs.hpp"
+#include <ingen/Arc.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <raul/Path.hpp>
#include <boost/intrusive/slist.hpp>
@@ -38,8 +41,7 @@
#include <memory>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
void
ClientUpdate::put(const URI& uri,
@@ -166,5 +168,4 @@ ClientUpdate::send(Interface& dest)
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/ClientUpdate.hpp b/src/server/ClientUpdate.hpp
index 9fadae90..1d16e6d6 100644
--- a/src/server/ClientUpdate.hpp
+++ b/src/server/ClientUpdate.hpp
@@ -17,10 +17,10 @@
#ifndef INGEN_ENGINE_CLIENTUPDATE_HPP
#define INGEN_ENGINE_CLIENTUPDATE_HPP
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <raul/Path.hpp>
#include <string>
#include <vector>
diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp
index f03187ae..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,12 +35,12 @@
#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
@@ -62,13 +61,11 @@ 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)
@@ -77,11 +74,11 @@ CompiledGraph::CompiledGraph(GraphImpl* graph)
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) {
@@ -97,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
@@ -162,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());
}
}
@@ -287,5 +282,4 @@ CompiledGraph::dump(const std::string& name) const
sink(")\n");
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/CompiledGraph.hpp b/src/server/CompiledGraph.hpp
index f33941aa..1949563d 100644
--- a/src/server/CompiledGraph.hpp
+++ b/src/server/CompiledGraph.hpp
@@ -19,16 +19,14 @@
#include "Task.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Noncopyable.hpp"
+#include <raul/Noncopyable.hpp>
#include <cstddef>
#include <memory>
#include <set>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class BlockImpl;
class GraphImpl;
@@ -40,18 +38,15 @@ class RunContext;
* execute the nodes in order and have nodes always executed before any of
* their dependencies.
*/
-class CompiledGraph : public raul::Maid::Disposable
- , public raul::Noncopyable
+class CompiledGraph : public raul::Noncopyable
{
public:
- static raul::managed_ptr<CompiledGraph> compile(raul::Maid& maid, GraphImpl& graph);
+ static std::unique_ptr<CompiledGraph> compile(GraphImpl& graph);
void run(RunContext& ctx);
private:
- friend class raul::Maid; ///< Allow make_managed to construct
-
- CompiledGraph(GraphImpl* graph);
+ explicit CompiledGraph(GraphImpl* graph);
using BlockSet = std::set<BlockImpl*>;
@@ -73,13 +68,12 @@ private:
std::unique_ptr<Task> _master;
};
-inline raul::managed_ptr<CompiledGraph>
-compile(raul::Maid& maid, GraphImpl& graph)
+inline std::unique_ptr<CompiledGraph>
+compile(GraphImpl& graph)
{
- return CompiledGraph::compile(maid, graph);
+ return CompiledGraph::compile(graph);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_COMPILEDGRAPH_HPP
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 1ea417d2..489d5384 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -23,29 +23,27 @@
#include "RunContext.hpp"
#include "ThreadManager.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/forge.h"
-#include "lv2/atom/util.h"
-#include "lv2/midi/midi.h"
-#include "lv2/urid/urid.h"
-#include "raul/Path.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/forge.h>
+#include <lv2/atom/util.h>
+#include <lv2/midi/midi.h>
+#include <lv2/urid/urid.h>
+#include <raul/Path.hpp>
#include <boost/intrusive/bstree.hpp>
#include <algorithm>
-#include <cassert>
#include <cmath>
#include <cstring>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
ControlBindings::ControlBindings(Engine& engine)
: _engine(engine)
@@ -201,8 +199,9 @@ ControlBindings::port_value_changed(RunContext& ctx,
{
const ingen::URIs& uris = ctx.engine().world().uris();
if (!!key) {
- int16_t value = port_value_to_control(
- ctx, port, key.type, value_atom);
+ const int16_t value =
+ port_value_to_control(ctx, port, key.type, value_atom);
+
uint16_t size = 0;
uint8_t buf[4];
switch (key.type) {
@@ -251,7 +250,7 @@ ControlBindings::start_learn(PortImpl* port)
ThreadManager::assert_thread(THREAD_PRE_PROCESS);
Binding* b = _learn_binding.load();
if (!b) {
- _learn_binding = new Binding(Type::NULL_CONTROL, port);
+ _learn_binding = new Binding();
} else {
b->port = port;
}
@@ -298,7 +297,7 @@ ControlBindings::control_to_port_value(RunContext& ctx,
float max = 1.0f;
get_range(ctx, port, &min, &max);
- return normal * (max - min) + min;
+ return (normal * (max - min)) + min;
}
int16_t
@@ -318,16 +317,10 @@ ControlBindings::port_value_to_control(RunContext& ctx,
const float value = value_atom.get<float>();
float normal = (value - min) / (max - min);
- if (normal < 0.0f) {
- normal = 0.0f;
- }
-
- if (normal > 1.0f) {
- normal = 1.0f;
- }
+ normal = std::max(0.0f, std::min(1.0f, normal));
if (port->is_logarithmic()) {
- normal = logf(normal * (static_cast<float>(M_E) - 1.0f) + 1.0f);
+ normal = logf((normal * (static_cast<float>(M_E) - 1.0f)) + 1.0f);
}
switch (type) {
@@ -393,7 +386,7 @@ ControlBindings::set_port_value(RunContext& ctx,
// TODO: Set port value property so it is saved
port->set_control_value(ctx, ctx.start(), val);
- URIs& uris = ctx.engine().world().uris();
+ const URIs& uris = ctx.engine().world().uris();
ctx.notify(uris.ingen_value, ctx.start(), port,
sizeof(float), _forge.Float, &val);
}
@@ -483,5 +476,4 @@ ControlBindings::post_process(RunContext&, Buffer* buffer)
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp
index d72fd2fd..0e6dbf63 100644
--- a/src/server/ControlBindings.hpp
+++ b/src/server/ControlBindings.hpp
@@ -19,9 +19,10 @@
#include "BufferRef.hpp"
-#include "lv2/atom/forge.h"
-#include "raul/Maid.hpp"
+#include <lv2/atom/forge.h>
+#include <raul/Maid.hpp>
+#include <boost/intrusive/options.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/set_hook.hpp>
@@ -34,14 +35,6 @@ namespace raul {
class Path;
} // namespace raul
-namespace boost {
-namespace intrusive {
-
-template <class Compare> struct compare;
-
-} // namespace intrusive
-} // namespace boost
-
namespace ingen {
class Atom;
@@ -67,9 +60,8 @@ public:
};
struct Key {
- Key(Type t = Type::NULL_CONTROL, int16_t n = 0) noexcept
- : type(t), num(n)
- {}
+ Key(Type t, int16_t n) noexcept : type{t}, num{n} {}
+ Key() noexcept : Key{Type::NULL_CONTROL, 0U} {}
bool operator<(const Key& other) const {
return ((type < other.type) ||
@@ -89,7 +81,8 @@ public:
/** One binding of a controller to a port. */
struct Binding : public boost::intrusive::set_base_hook<>,
public raul::Maid::Disposable {
- Binding(Key k=Key(), PortImpl* p=nullptr) : key(k), port(p) {}
+ Binding(Key k, PortImpl* p) noexcept : key{k}, port{p} {}
+ Binding() noexcept : Binding{Key{}, nullptr} {}
bool operator<(const Binding& rhs) const { return key < rhs.key; }
diff --git a/src/server/DirectDriver.hpp b/src/server/DirectDriver.hpp
index 48de44f9..bc52fc3a 100644
--- a/src/server/DirectDriver.hpp
+++ b/src/server/DirectDriver.hpp
@@ -24,20 +24,17 @@
#include "RunContext.hpp"
#include "types.hpp"
-#include "raul/Path.hpp"
+#include <raul/Path.hpp>
#include <boost/intrusive/slist.hpp>
#include <cstddef>
+#include <cstdint>
#include <string>
-namespace boost {
-namespace intrusive {
-
+namespace boost::intrusive {
template <bool Enabled> struct cache_last;
-
-} // namespace intrusive
-} // namespace boost
+} // namespace boost::intrusive
namespace ingen {
@@ -57,7 +54,7 @@ public:
DirectDriver(Engine& engine,
double sample_rate,
SampleCount block_length,
- size_t seq_size)
+ uint32_t seq_size)
: _engine(engine)
, _sample_rate(sample_rate)
, _block_length(block_length)
@@ -104,7 +101,7 @@ public:
SampleCount block_length() const override { return _block_length; }
- size_t seq_size() const override { return _seq_size; }
+ uint32_t seq_size() const override { return _seq_size; }
SampleCount sample_rate() const override { return _sample_rate; }
@@ -124,7 +121,7 @@ private:
Ports _ports;
SampleCount _sample_rate;
SampleCount _block_length;
- size_t _seq_size;
+ uint32_t _seq_size;
};
} // namespace server
diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp
index 83436389..112fb8ba 100644
--- a/src/server/Driver.hpp
+++ b/src/server/Driver.hpp
@@ -19,8 +19,8 @@
#include "types.hpp"
-#include "ingen/URI.hpp"
-#include "raul/Noncopyable.hpp"
+#include <ingen/URI.hpp>
+#include <raul/Noncopyable.hpp>
#include <cstddef>
@@ -98,7 +98,7 @@ public:
virtual SampleCount block_length() const = 0;
/** Return the event buffer size in bytes */
- virtual size_t seq_size() const = 0;
+ virtual uint32_t seq_size() const = 0;
/** Return the sample rate in Hz */
virtual SampleRate sample_rate() const = 0;
diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp
index 0c4c83e6..1e07afd2 100644
--- a/src/server/DuplexPort.cpp
+++ b/src/server/DuplexPort.cpp
@@ -23,23 +23,24 @@
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "NodeImpl.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
+#include "PortType.hpp"
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
#include <algorithm>
#include <map>
#include <memory>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
DuplexPort::DuplexPort(BufferFactory& bufs,
GraphImpl* parent,
@@ -96,7 +97,7 @@ DuplexPort::duplicate(Engine& engine,
GraphImpl* parent)
{
BufferFactory& bufs = *engine.buffer_factory();
- const Atom polyphonic = get_property(bufs.uris().ingen_polyphonic);
+ const Atom& polyphonic = get_property(bufs.uris().ingen_polyphonic);
auto* dup = new DuplexPort(
bufs, parent, symbol, _index,
@@ -257,5 +258,4 @@ DuplexPort::next_value_offset(SampleCount offset, SampleCount end) const
return PortImpl::next_value_offset(offset, end);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/DuplexPort.hpp b/src/server/DuplexPort.hpp
index 3cc0efba..fb3eb74e 100644
--- a/src/server/DuplexPort.hpp
+++ b/src/server/DuplexPort.hpp
@@ -19,13 +19,11 @@
#include "InputPort.hpp"
#include "PortImpl.hpp"
-#include "PortType.hpp"
#include "server.h"
#include "types.hpp"
-#include "ingen/URI.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Maid.hpp"
+#include <lv2/urid/urid.h>
+#include <raul/Maid.hpp>
#include <boost/intrusive/slist_hook.hpp>
@@ -38,15 +36,15 @@ class Symbol;
namespace ingen {
+enum class PortType;
+
class Atom;
-class Properties;
namespace server {
class BufferFactory;
class Engine;
class GraphImpl;
-class RunContext;
/** A duplex Port (both an input and output port on a Graph)
*
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 613def62..4d753bbc 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2017 David Robillard <http://drobilla.net/>
+ Copyright 2007-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
@@ -19,7 +19,6 @@
#include "BlockFactory.hpp"
#include "Broadcaster.hpp"
#include "BufferFactory.hpp"
-#include "BufferRef.hpp"
#include "ControlBindings.hpp"
#include "DirectDriver.hpp"
#include "Driver.hpp"
@@ -43,26 +42,28 @@
#include "SocketListener.hpp"
#endif
-#include "ingen/Atom.hpp"
-#include "ingen/AtomReader.hpp"
-#include "ingen/ColorContext.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/LV2Features.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/StreamWriter.hpp"
-#include "ingen/Tee.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/buf-size/buf-size.h"
-#include "lv2/state/state.h"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-#include "raul/RingBuffer.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/AtomReader.hpp>
+#include <ingen/Clock.hpp>
+#include <ingen/ColorContext.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/LV2Features.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/StreamWriter.hpp>
+#include <ingen/Tee.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/buf-size/buf-size.h>
+#include <lv2/state/state.h>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
+#include <raul/RingBuffer.hpp>
#include <algorithm>
#include <cmath>
@@ -71,11 +72,11 @@
#include <limits>
#include <map>
#include <memory>
+#include <string>
#include <thread>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
thread_local unsigned ThreadManager::flags(0);
bool ThreadManager::single_threaded(true);
@@ -106,11 +107,14 @@ Engine::Engine(ingen::World& world)
}
for (int i = 0; i < world.conf().option("threads").get<int32_t>(); ++i) {
+ const bool is_threaded = (i > 0);
_notifications.emplace_back(
- std::make_unique<raul::RingBuffer>(uint32_t(24 * event_queue_size())));
+ std::make_unique<raul::RingBuffer>(24U * event_queue_size()));
_run_contexts.emplace_back(
- std::make_unique<RunContext>(
- *this, _notifications.back().get(), unsigned(i), i > 0));
+ std::make_unique<RunContext>(*this,
+ _notifications.back().get(),
+ static_cast<unsigned>(i),
+ is_threaded));
}
_world.lv2_features().add_feature(_worker->schedule_feature());
@@ -238,12 +242,11 @@ Engine::emit_notifications(FrameTime end)
bool
Engine::pending_notifications()
{
- for (const auto& ctx : _run_contexts) {
- if (ctx->pending_notifications()) {
- return true;
- }
- }
- return false;
+ return std::any_of(_run_contexts.begin(),
+ _run_contexts.end(),
+ [](const auto& ctx) {
+ return ctx->pending_notifications();
+ });
}
bool
@@ -297,16 +300,17 @@ Engine::block_length() const
return _driver->block_length();
}
-size_t
+uint32_t
Engine::sequence_size() const
{
return _driver->seq_size();
}
-size_t
+uint32_t
Engine::event_queue_size() const
{
- return _world.conf().option("queue-size").get<int32_t>();
+ return static_cast<uint32_t>(
+ std::max(0, _world.conf().option("queue-size").get<int32_t>()));
}
void
@@ -380,7 +384,7 @@ Engine::reset_load()
}
void
-Engine::init(double sample_rate, uint32_t block_length, size_t seq_size)
+Engine::init(double sample_rate, uint32_t block_length, uint32_t seq_size)
{
set_driver(std::make_shared<DirectDriver>(
*this, sample_rate, block_length, seq_size));
@@ -531,5 +535,4 @@ Engine::unregister_client(const std::shared_ptr<Interface>& client)
return _broadcaster->unregister_client(client);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index d224d5b5..8fa1d169 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -22,9 +22,9 @@
#include "server.h"
#include "types.hpp"
-#include "ingen/Clock.hpp"
-#include "ingen/EngineBase.hpp"
-#include "ingen/Properties.hpp"
+#include <ingen/Clock.hpp>
+#include <ingen/EngineBase.hpp>
+#include <ingen/Properties.hpp>
#include <chrono>
#include <condition_variable>
@@ -85,7 +85,7 @@ public:
Engine& operator=(const Engine&) = delete;
// EngineBase methods
- void init(double sample_rate, uint32_t block_length, size_t seq_size) override;
+ void init(double sample_rate, uint32_t block_length, uint32_t seq_size) override;
bool supports_dynamic_ports() const override;
bool activate() override;
void deactivate() override;
@@ -170,8 +170,8 @@ public:
SampleRate sample_rate() const;
SampleCount block_length() const;
- size_t sequence_size() const;
- size_t event_queue_size() const;
+ uint32_t sequence_size() const;
+ uint32_t event_queue_size() const;
size_t n_threads() const { return _run_contexts.size(); }
bool atomic_bundles() const { return _atomic_bundles; }
diff --git a/src/server/EnginePort.hpp b/src/server/EnginePort.hpp
index d6e67f1e..d7e73f63 100644
--- a/src/server/EnginePort.hpp
+++ b/src/server/EnginePort.hpp
@@ -19,15 +19,14 @@
#include "DuplexPort.hpp"
-#include "raul/Deletable.hpp"
-#include "raul/Noncopyable.hpp"
+#include <raul/Deletable.hpp>
+#include <raul/Noncopyable.hpp>
#include <boost/intrusive/slist_hook.hpp>
#include <cstdint>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** A "system" port (e.g. a Jack port, an external port on Ingen).
*
@@ -59,7 +58,6 @@ protected:
uint32_t _driver_index{0};
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_ENGINE_PORT_HPP
diff --git a/src/server/Event.hpp b/src/server/Event.hpp
index 68b66c86..3c9c5c26 100644
--- a/src/server/Event.hpp
+++ b/src/server/Event.hpp
@@ -19,12 +19,12 @@
#include "types.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Deletable.hpp"
-#include "raul/Noncopyable.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Deletable.hpp>
+#include <raul/Noncopyable.hpp>
#include <atomic>
#include <cstdint>
@@ -36,8 +36,7 @@ namespace raul {
class Path;
} // namespace raul
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Engine;
class RunContext;
@@ -169,7 +168,6 @@ protected:
Mode _mode;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_EVENT_HPP
diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp
index e9fb56a6..fff9226a 100644
--- a/src/server/EventWriter.cpp
+++ b/src/server/EventWriter.cpp
@@ -18,21 +18,21 @@
#include "Engine.hpp"
-#include "events/Connect.hpp"
-#include "events/Copy.hpp"
-#include "events/Delete.hpp"
-#include "events/Delta.hpp"
-#include "events/Disconnect.hpp"
-#include "events/DisconnectAll.hpp"
-#include "events/Get.hpp"
-#include "events/Mark.hpp"
-#include "events/Move.hpp"
-#include "events/Undo.hpp"
-
-#include <boost/variant/apply_visitor.hpp>
-
-namespace ingen {
-namespace server {
+#include <events/Connect.hpp>
+#include <events/Copy.hpp>
+#include <events/Delete.hpp>
+#include <events/Delta.hpp>
+#include <events/Disconnect.hpp>
+#include <events/DisconnectAll.hpp>
+#include <events/Get.hpp>
+#include <events/Mark.hpp>
+#include <events/Move.hpp>
+#include <events/Undo.hpp>
+#include <ingen/Message.hpp>
+
+#include <variant>
+
+namespace ingen::server {
EventWriter::EventWriter(Engine& engine)
: _engine(engine)
@@ -47,7 +47,7 @@ EventWriter::now() const
void
EventWriter::message(const Message& msg)
{
- boost::apply_visitor(*this, msg);
+ std::visit(*this, msg);
}
void
@@ -150,5 +150,4 @@ EventWriter::operator()(const Get& msg)
_event_mode);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp
index a71242c1..55ee1158 100644
--- a/src/server/EventWriter.hpp
+++ b/src/server/EventWriter.hpp
@@ -20,14 +20,13 @@
#include "Event.hpp"
#include "types.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/URI.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/URI.hpp>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Engine;
@@ -80,7 +79,6 @@ private:
SampleCount now() const;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_EVENTWRITER_HPP
diff --git a/src/server/FrameTimer.hpp b/src/server/FrameTimer.hpp
index dfa5c46b..0078f99c 100644
--- a/src/server/FrameTimer.hpp
+++ b/src/server/FrameTimer.hpp
@@ -20,8 +20,7 @@
#include <cmath>
#include <cstdint>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** Delay-locked loop for monotonic sample time.
*
@@ -95,16 +94,15 @@ private:
const double b;
const double c;
- uint64_t nper = 0u;
+ uint64_t nper = 0U;
double e2 = 0.0;
double t0 = 0.0;
double t1 = 0.0;
- uint64_t n0 = 0u;
- uint64_t n1 = 0u;
+ uint64_t n0 = 0U;
+ uint64_t n1 = 0U;
bool initialized = false;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_FRAMETIMER_HPP
diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp
index 1ed6c37f..9e44a4d4 100644
--- a/src/server/GraphImpl.cpp
+++ b/src/server/GraphImpl.cpp
@@ -28,24 +28,24 @@
#include "PortImpl.hpp"
#include "ThreadManager.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <cstddef>
#include <map>
#include <memory>
-#include <type_traits>
+#include <string>
#include <unordered_map>
-namespace ingen {
-namespace server {
+namespace ingen::server {
GraphImpl::GraphImpl(Engine& engine,
const raul::Symbol& symbol,
@@ -310,13 +310,15 @@ GraphImpl::has_arc(const PortImpl* tail, const PortImpl* dst_port) const
return (i != _graph_arcs.end());
}
-void
-GraphImpl::set_compiled_graph(raul::managed_ptr<CompiledGraph>&& cg)
+std::unique_ptr<CompiledGraph>
+GraphImpl::swap_compiled_graph(std::unique_ptr<CompiledGraph> cg)
{
if (_compiled_graph && _compiled_graph != cg) {
_engine.reset_load();
}
- _compiled_graph = std::move(cg);
+
+ _compiled_graph.swap(cg);
+ return cg;
}
uint32_t
@@ -330,7 +332,7 @@ bool
GraphImpl::has_port_with_index(uint32_t index) const
{
BufferFactory& bufs = *_engine.buffer_factory();
- const auto index_atom = bufs.forge().make(int32_t(index));
+ const auto index_atom = bufs.forge().make(static_cast<int32_t>(index));
for (const auto& p : _inputs) {
if (p.has_property(bufs.uris().lv2_index, index_atom)) {
@@ -390,5 +392,4 @@ GraphImpl::build_ports_array(raul::Maid& maid)
return result;
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp
index 3746961a..6c852106 100644
--- a/src/server/GraphImpl.hpp
+++ b/src/server/GraphImpl.hpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-2023 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
@@ -23,10 +23,10 @@
#include "server.h"
#include "types.hpp"
-#include "ingen/Node.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Maid.hpp"
+#include <lv2/urid/urid.h>
+#include <raul/Maid.hpp>
+#include <boost/intrusive/options.hpp>
#include <boost/intrusive/slist.hpp>
#include <cassert>
@@ -38,16 +38,7 @@ namespace raul {
class Symbol;
} // namespace raul
-namespace boost {
-namespace intrusive {
-
-template <bool Enabled> struct constant_time_size;
-
-} // namespace intrusive
-} // namespace boost
-
-namespace ingen {
-namespace server {
+namespace ingen::server {
class ArcImpl;
class BufferFactory;
@@ -106,9 +97,14 @@ public:
* Audio thread.
*
* \param ctx Process context
+ *
* \param bufs New set of buffers
- * \param poly Must be < the most recent value passed to prepare_internal_poly.
- * \param maid Any objects no longer needed will be pushed to this
+ *
+ * \param poly Must be < the most recent value passed to
+ * prepare_internal_poly.
+ *
+ * \param maid Any objects no longer needed will be
+ * pushed to this
*/
bool apply_internal_poly(RunContext& ctx,
BufferFactory& bufs,
@@ -185,7 +181,8 @@ public:
bool has_arc(const PortImpl* tail, const PortImpl* dst_port) const;
/** Set a new compiled graph to run, and return the old one. */
- void set_compiled_graph(raul::managed_ptr<CompiledGraph>&& cg);
+ [[nodiscard]] std::unique_ptr<CompiledGraph>
+ swap_compiled_graph(std::unique_ptr<CompiledGraph> cg);
const raul::managed_ptr<Ports>& external_ports() { return _ports; }
@@ -204,7 +201,7 @@ public:
Engine& engine() { return _engine; }
private:
- using CompiledGraphPtr = raul::managed_ptr<CompiledGraph>;
+ using CompiledGraphPtr = std::unique_ptr<CompiledGraph>;
Engine& _engine;
uint32_t _poly_pre; ///< Pre-process thread only
@@ -216,7 +213,6 @@ private:
bool _process{false}; ///< True iff graph is enabled
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_GRAPHIMPL_HPP
diff --git a/src/server/GraphPlugin.hpp b/src/server/GraphPlugin.hpp
index b7a281f5..302141e7 100644
--- a/src/server/GraphPlugin.hpp
+++ b/src/server/GraphPlugin.hpp
@@ -19,15 +19,14 @@
#include "PluginImpl.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "lilv/lilv.h"
-#include "raul/Symbol.hpp"
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <lilv/lilv.h>
+#include <raul/Symbol.hpp>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class BlockImpl;
class BufferFactory;
@@ -66,7 +65,6 @@ private:
const std::string _name;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_GRAPHPLUGIN_HPP
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 8547dc35..01622209 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -23,22 +23,23 @@
#include "BufferRef.hpp"
#include "GraphImpl.hpp"
#include "NodeImpl.hpp"
+#include "PortType.hpp"
#include "RunContext.hpp"
#include "mix.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
InputPort::InputPort(BufferFactory& bufs,
BlockImpl* parent,
@@ -177,7 +178,7 @@ InputPort::pre_run(RunContext& ctx)
{
if ((_user_buffer || !_arcs.empty()) && !direct_connect()) {
const uint32_t src_poly = max_tail_poly(ctx);
- const uint32_t max_n_srcs = _arcs.size() * src_poly + 1;
+ const uint32_t max_n_srcs = (_arcs.size() * src_poly) + 1;
for (uint32_t v = 0; v < _poly; ++v) {
if (!buffer(v)->get<void>()) {
@@ -231,9 +232,7 @@ InputPort::next_value_offset(SampleCount offset, SampleCount end) const
for (const auto& arc : _arcs) {
const SampleCount o = arc.tail()->next_value_offset(offset, end);
- if (o < earliest) {
- earliest = o;
- }
+ earliest = std::min(o, earliest);
}
return earliest;
@@ -261,5 +260,4 @@ InputPort::direct_connect() const
&& buffer(0)->type() != _bufs.uris().atom_Sequence;
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp
index 72040a49..f3c6e553 100644
--- a/src/server/InputPort.hpp
+++ b/src/server/InputPort.hpp
@@ -17,14 +17,14 @@
#ifndef INGEN_ENGINE_INPUTPORT_HPP
#define INGEN_ENGINE_INPUTPORT_HPP
-#include "ArcImpl.hpp" // IWYU pragma: keep
+#include "ArcImpl.hpp"
#include "PortImpl.hpp"
-#include "PortType.hpp"
#include "types.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Maid.hpp"
+#include <lv2/urid/urid.h>
+#include <raul/Maid.hpp>
+#include <boost/intrusive/options.hpp>
#include <boost/intrusive/slist.hpp>
#include <cstdint>
@@ -34,16 +34,10 @@ namespace raul {
class Symbol;
} // namespace raul
-namespace boost {
-namespace intrusive {
-
-template <bool Enabled> struct constant_time_size;
-
-} // namespace intrusive
-} // namespace boost
-
namespace ingen {
+enum class PortType;
+
class Atom;
namespace server {
@@ -102,7 +96,7 @@ public:
/** Like `get_buffers`, but for the pre-process thread.
*
- * This uses the "current" number of arcs fromthe perspective of the
+ * This uses the "current" number of arcs from the perspective of the
* pre-process thread to allocate buffers for application of a
* connection/disconnection/etc in the next process cycle.
*/
diff --git a/src/server/InternalBlock.cpp b/src/server/InternalBlock.cpp
index 68e1f3e8..2eb0d411 100644
--- a/src/server/InternalBlock.cpp
+++ b/src/server/InternalBlock.cpp
@@ -23,8 +23,8 @@
#include "PluginImpl.hpp"
#include "PortImpl.hpp"
-#include "ingen/URIs.hpp"
-#include "raul/Array.hpp"
+#include <ingen/URIs.hpp>
+#include <raul/Array.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
@@ -43,7 +43,6 @@ class Atom;
namespace server {
class GraphImpl;
-class RunContext;
InternalBlock::InternalBlock(PluginImpl* plugin,
const raul::Symbol& symbol,
diff --git a/src/server/InternalBlock.hpp b/src/server/InternalBlock.hpp
index 2357f405..9eca9716 100644
--- a/src/server/InternalBlock.hpp
+++ b/src/server/InternalBlock.hpp
@@ -24,13 +24,10 @@ namespace raul {
class Symbol;
} // namespace raul
-namespace ingen {
-namespace server {
+namespace ingen::server {
-class Engine;
class GraphImpl;
class PluginImpl;
-class RunContext;
/** An internal Block implemented inside Ingen.
*
@@ -52,7 +49,6 @@ public:
void pre_process(RunContext& ctx) override;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_BLOCKIMPL_HPP
diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp
index 6c188c5e..7670c931 100644
--- a/src/server/InternalPlugin.cpp
+++ b/src/server/InternalPlugin.cpp
@@ -24,12 +24,14 @@
#include "internals/Trigger.hpp"
#include "types.hpp"
-#include "ingen/URIs.hpp"
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <lilv/lilv.h>
+#include <raul/Symbol.hpp>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
InternalPlugin::InternalPlugin(URIs& uris, const URI& uri, raul::Symbol symbol)
: PluginImpl(uris, uris.ingen_Internal.urid_atom(), uri)
@@ -76,5 +78,4 @@ InternalPlugin::instantiate(BufferFactory& bufs,
return nullptr;
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/InternalPlugin.hpp b/src/server/InternalPlugin.hpp
index 9dfabc5f..4d715491 100644
--- a/src/server/InternalPlugin.hpp
+++ b/src/server/InternalPlugin.hpp
@@ -19,9 +19,9 @@
#include "PluginImpl.hpp"
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
-#include "raul/Symbol.hpp"
+#include <ingen/URI.hpp>
+#include <lilv/lilv.h>
+#include <raul/Symbol.hpp>
#define NS_INTERNALS "http://drobilla.net/ns/ingen-internals#"
@@ -31,11 +31,6 @@ class URIs;
namespace server {
-class BlockImpl;
-class BufferFactory;
-class Engine;
-class GraphImpl;
-
/** Implementation of an Internal plugin.
*/
class InternalPlugin : public PluginImpl
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 32029c6e..e508c850 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -21,6 +21,7 @@
#include "BufferRef.hpp"
#include "DuplexPort.hpp"
#include "Engine.hpp"
+#include "FrameTimer.hpp"
#include "GraphImpl.hpp"
#include "PortType.hpp"
#include "RunContext.hpp"
@@ -28,19 +29,21 @@
#include "ingen_config.h"
#include "util.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/forge.h"
-#include "lv2/atom/util.h"
-#include "raul/Path.hpp"
-
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/forge.h>
+#include <lv2/atom/util.h>
+#include <raul/Path.hpp>
+#include <raul/Semaphore.hpp>
+
+#include <jack/jack.h>
#include <jack/midiport.h>
#include <jack/transport.h>
@@ -51,14 +54,14 @@
#include <cassert>
#include <chrono>
+#include <cstdint>
#include <map>
#include <string>
#include <utility>
using jack_sample_t = jack_default_audio_sample_t;
-namespace ingen {
-namespace server {
+namespace ingen::server {
JackDriver::JackDriver(Engine& engine)
: _engine(engine)
@@ -109,7 +112,8 @@ JackDriver::attach(const std::string& server_name,
_sample_rate = jack_get_sample_rate(_client);
_block_length = jack_get_buffer_size(_client);
- _seq_size = jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE);
+ _seq_size = static_cast<uint32_t>(
+ jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE));
_fallback_buffer = AudioBufPtr(
static_cast<float*>(
@@ -124,6 +128,8 @@ JackDriver::attach(const std::string& server_name,
register_port(p);
}
+ _timer = std::make_unique<FrameTimer>(_block_length, _sample_rate);
+
return true;
}
@@ -257,14 +263,14 @@ void
JackDriver::rename_port(const raul::Path& old_path,
const raul::Path& new_path)
{
- EnginePort* eport = get_port(old_path);
+ const EnginePort* eport = get_port(old_path);
if (eport) {
#if USE_JACK_PORT_RENAME
jack_port_rename(_client,
static_cast<jack_port_t*>(eport->handle()),
new_path.substr(1).c_str());
#else
- jack_port_set_name((jack_port_t*)eport->handle(),
+ jack_port_set_name(static_cast<jack_port_t*>(eport->handle()),
new_path.substr(1).c_str());
#endif
}
@@ -457,6 +463,12 @@ JackDriver::append_time_events(RunContext& ctx, Buffer& buffer)
static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(lpos)));
}
+SampleCount
+JackDriver::frame_time() const
+{
+ return _timer->frame_time(_engine.current_time()) + _engine.block_length();
+}
+
/**** Jack Callbacks ****/
/** Jack process callback, drives entire audio thread.
@@ -479,6 +491,7 @@ JackDriver::_process_cb(jack_nframes_t nframes)
_transport_state = jack_transport_query(_client, &_position);
+ _timer->update(_engine.current_time(), start_of_current_cycle - _engine.block_length());
_engine.locate(start_of_current_cycle, nframes);
// Read input
@@ -520,18 +533,22 @@ JackDriver::_shutdown_cb()
int
JackDriver::_block_length_cb(jack_nframes_t nframes)
{
+ const URIs& uris = _engine.world().uris();
+
if (_engine.root_graph()) {
_block_length = nframes;
- _seq_size = jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE);
+ _seq_size = static_cast<uint32_t>(
+ jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE));
_engine.root_graph()->set_buffer_size(
- _engine.run_context(), *_engine.buffer_factory(), PortType::AUDIO,
+ _engine.run_context(), *_engine.buffer_factory(),
+ uris.atom_Sound,
_engine.buffer_factory()->audio_buffer_size(nframes));
_engine.root_graph()->set_buffer_size(
- _engine.run_context(), *_engine.buffer_factory(), PortType::ATOM,
+ _engine.run_context(), *_engine.buffer_factory(),
+ uris.atom_Sequence,
_seq_size);
}
return 0;
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp
index 7a1dd2e0..4c8e779e 100644
--- a/src/server/JackDriver.hpp
+++ b/src/server/JackDriver.hpp
@@ -18,47 +18,35 @@
#define INGEN_ENGINE_JACKAUDIODRIVER_HPP
#include "Driver.hpp"
-#include "EnginePort.hpp" // IWYU pragma: keep
+#include "EnginePort.hpp"
#include "types.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/memory.hpp" // IWYU pragma: keep
-#include "lv2/atom/forge.h"
-#include "raul/Semaphore.hpp"
+#include <ingen/URI.hpp>
+#include <ingen/memory.hpp>
+#include <lv2/atom/forge.h>
+#include <raul/Semaphore.hpp>
+#include <boost/intrusive/options.hpp>
#include <boost/intrusive/slist.hpp>
-#include <jack/jack.h>
-#include <jack/thread.h>
+#include <jack/transport.h> // IWYU pragma: keep
#include <jack/types.h>
+#include <jack/thread.h>
+
#include <atomic>
-#include <cstddef>
#include <cstdint>
#include <exception>
#include <memory>
#include <string>
-namespace raul {
-class Path;
-} // namespace raul
-
-namespace boost {
-namespace intrusive {
-
-template <bool Enabled> struct cache_last;
-
-} // namespace intrusive
-} // namespace boost
-
namespace ingen {
class Atom;
namespace server {
-class Buffer;
-class DuplexPort;
class Engine;
+class FrameTimer;
class RunContext;
/** The Jack Driver.
@@ -107,12 +95,10 @@ public:
jack_client_t* jack_client() const { return _client; }
SampleCount block_length() const override { return _block_length; }
- size_t seq_size() const override { return _seq_size; }
+ uint32_t seq_size() const override { return _seq_size; }
SampleCount sample_rate() const override { return _sample_rate; }
- SampleCount frame_time() const override {
- return _client ? jack_frame_time(_client) : 0;
- }
+ SampleCount frame_time() const override;
class PortRegistrationFailedException : public std::exception
{};
@@ -125,7 +111,7 @@ private:
// Static JACK callbacks which call the non-static callbacks (methods)
static void shutdown_cb(void* const jack_driver) {
- return static_cast<JackDriver*>(jack_driver)->_shutdown_cb();
+ static_cast<JackDriver*>(jack_driver)->_shutdown_cb();
}
static int process_cb(jack_nframes_t nframes, void* const jack_driver) {
@@ -156,23 +142,24 @@ protected:
using AudioBufPtr = std::unique_ptr<float, FreeDeleter<float>>;
- Engine& _engine;
- Ports _ports;
- AudioBufPtr _fallback_buffer;
- LV2_Atom_Forge _forge;
- raul::Semaphore _sem{0};
- std::atomic<bool> _flag{false};
- jack_client_t* _client{nullptr};
- jack_nframes_t _block_length{0};
- size_t _seq_size{0};
- jack_nframes_t _sample_rate{0};
- uint32_t _midi_event_type;
- bool _is_activated{false};
- jack_position_t _position{};
- jack_transport_state_t _transport_state{};
- double _old_bpm{120.0};
- jack_nframes_t _old_frame{0};
- bool _old_rolling{false};
+ Engine& _engine;
+ Ports _ports;
+ AudioBufPtr _fallback_buffer;
+ LV2_Atom_Forge _forge;
+ raul::Semaphore _sem{0};
+ std::unique_ptr<FrameTimer> _timer;
+ std::atomic<bool> _flag{false};
+ jack_client_t* _client{nullptr};
+ jack_nframes_t _block_length{0};
+ uint32_t _seq_size{0};
+ jack_nframes_t _sample_rate{0};
+ uint32_t _midi_event_type;
+ bool _is_activated{false};
+ jack_position_t _position{};
+ jack_transport_state_t _transport_state{};
+ double _old_bpm{120.0};
+ jack_nframes_t _old_frame{0};
+ bool _old_rolling{false};
};
} // namespace server
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index 4cdcecd7..ad7b28ae 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -28,24 +28,27 @@
#include "RunContext.hpp"
#include "Worker.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/core/lv2.h"
-#include "lv2/options/options.h"
-#include "lv2/state/state.h"
-#include "lv2/urid/urid.h"
-#include "lv2/worker/worker.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/LV2Features.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lilv/lilv.h>
+#include <lv2/core/lv2.h>
+#include <lv2/options/options.h>
+#include <lv2/state/state.h>
+#include <lv2/urid/urid.h>
+#include <lv2/worker/worker.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <algorithm>
#include <cassert>
@@ -53,11 +56,11 @@
#include <cstdint>
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** Partially construct a LV2Block.
*
@@ -110,7 +113,7 @@ LV2Block::make_instance(URIs& uris,
}
for (uint32_t p = 0; p < num_ports(); ++p) {
- PortImpl* const port = _ports->at(p);
+ const PortImpl* const port = _ports->at(p);
Buffer* const buffer = (preparing)
? port->prepared_buffer(voice).get()
: port->buffer(voice).get();
@@ -223,7 +226,7 @@ LV2Block::apply_poly(RunContext& ctx, uint32_t poly)
/** Instantiate self from LV2 plugin descriptor.
*
- * Implemented as a seperate function (rather than in the constructor) to
+ * Implemented as a separate function (rather than in the constructor) to
* allow graceful error-catching of broken plugins.
*
* Returns whether or not plugin was successfully instantiated. If return
@@ -350,7 +353,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state)
LILV_FOREACH (nodes, i, sizes) {
const LilvNode* d = lilv_nodes_get(sizes, i);
if (lilv_node_is_int(d)) {
- uint32_t size_val = lilv_node_as_int(d);
+ const uint32_t size_val = lilv_node_as_int(d);
port_buffer_size = std::max(port_buffer_size, size_val);
}
}
@@ -482,7 +485,7 @@ LV2Block::save_state(const FilePath& dir) const
World& world = _lv2_plugin->world();
LilvWorld* lworld = world.lilv_world();
- StatePtr state{
+ const StatePtr state{
lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(),
const_cast<LV2Block*>(this)->instance(0),
&world.uri_map().urid_map(),
@@ -522,7 +525,7 @@ LV2Block::duplicate(Engine& engine,
const SampleRate rate = engine.sample_rate();
// Get current state
- StatePtr state{
+ const StatePtr state{
lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(),
instance(0),
&engine.world().uri_map().urid_map(),
@@ -590,10 +593,10 @@ LV2_Worker_Status
LV2Block::work(uint32_t size, const void* data)
{
if (_worker_iface) {
- std::lock_guard<std::mutex> lock(_work_mutex);
+ const std::lock_guard<std::mutex> lock{_work_mutex};
- LV2_Handle inst = lilv_instance_get_handle(instance(0));
- LV2_Worker_Status st = _worker_iface->work(inst, work_respond, this, size, data);
+ LV2_Handle inst = lilv_instance_get_handle(instance(0));
+ const LV2_Worker_Status st = _worker_iface->work(inst, work_respond, this, size, data);
if (st) {
parent_graph()->engine().log().error(
"Error calling %1% work method\n", _path);
@@ -693,8 +696,8 @@ get_port_value(const char* port_symbol,
uint32_t* size,
uint32_t* type)
{
- auto* const block = static_cast<LV2Block*>(user_data);
- auto* const port = block->port_by_symbol(port_symbol);
+ auto* const block = static_cast<LV2Block*>(user_data);
+ const auto* const port = block->port_by_symbol(port_symbol);
if (port && port->is_input() && port->value().is_valid()) {
*size = port->value().size();
@@ -705,7 +708,7 @@ get_port_value(const char* port_symbol,
return nullptr;
}
-boost::optional<Resource>
+std::optional<Resource>
LV2Block::save_preset(const URI& uri,
const Properties& props)
{
@@ -718,17 +721,17 @@ LV2Block::save_preset(const URI& uri,
const FilePath dirname = path.parent_path();
const FilePath basename = path.stem();
- StatePtr state{lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(),
- instance(0),
- lmap,
- nullptr,
- nullptr,
- nullptr,
- path.c_str(),
- get_port_value,
- this,
- LV2_STATE_IS_NATIVE,
- nullptr)};
+ const StatePtr state{lilv_state_new_from_instance(_lv2_plugin->lilv_plugin(),
+ instance(0),
+ lmap,
+ nullptr,
+ nullptr,
+ nullptr,
+ path.c_str(),
+ get_port_value,
+ this,
+ LV2_STATE_IS_NATIVE,
+ nullptr)};
if (state) {
const auto l = props.find(_uris.rdfs_label);
@@ -774,5 +777,4 @@ LV2Block::set_port_buffer(uint32_t voice,
buf ? buf->port_data(_ports->at(port_num)->type(), offset) : nullptr);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp
index 9e907ffa..78b5ffac 100644
--- a/src/server/LV2Block.hpp
+++ b/src/server/LV2Block.hpp
@@ -22,22 +22,21 @@
#include "State.hpp"
#include "types.hpp"
-#include "ingen/LV2Features.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
-#include "lv2/worker/worker.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Noncopyable.hpp"
-
+#include <ingen/LV2Features.hpp>
+#include <lilv/lilv.h>
+#include <lv2/worker/worker.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Noncopyable.hpp>
+
+#include <boost/intrusive/options.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/slist_hook.hpp>
-#include <boost/optional/optional.hpp>
#include <cstdint>
#include <cstdlib>
#include <cstring>
+#include <filesystem>
#include <memory>
#include <mutex>
@@ -45,33 +44,16 @@ namespace raul {
class Symbol;
} // namespace raul
-namespace boost {
-namespace intrusive {
-
-template <bool Enabled>
-struct cache_last;
-
-template <bool Enabled>
-struct constant_time_size;
-
-} // namespace intrusive
-} // namespace boost
-
namespace ingen {
-class FilePath;
-class Resource;
class URIs;
class World;
namespace server {
class BufferFactory;
-class Engine;
class GraphImpl;
class LV2Plugin;
-class RunContext;
-class Worker;
/** An instance of a LV2 plugin.
*
@@ -91,7 +73,7 @@ public:
bool instantiate(BufferFactory& bufs, const LilvState* state);
LilvInstance* instance() override { return instance(0); }
- bool save_state(const FilePath& dir) const override;
+ bool save_state(const std::filesystem::path& dir) const override;
BlockImpl* duplicate(Engine& engine,
const raul::Symbol& symbol,
@@ -113,15 +95,15 @@ public:
void apply_state(const std::unique_ptr<Worker>& worker,
const LilvState* state) override;
- boost::optional<Resource> save_preset(const URI& uri,
- const Properties& props) override;
+ std::optional<Resource> save_preset(const URI& uri,
+ const Properties& props) override;
void set_port_buffer(uint32_t voice,
uint32_t port_num,
const BufferRef& buf,
SampleCount offset) override;
- static StatePtr load_state(World& world, const FilePath& path);
+ static StatePtr load_state(World& world, const std::filesystem::path& path);
protected:
struct Instance : public raul::Noncopyable {
@@ -135,7 +117,7 @@ protected:
std::shared_ptr<Instance>
make_instance(URIs& uris, SampleRate rate, uint32_t voice, bool preparing);
- inline LilvInstance* instance(uint32_t voice) {
+ LilvInstance* instance(uint32_t voice) {
return static_cast<LilvInstance*>((*_instances)[voice]->instance);
}
diff --git a/src/server/LV2Options.hpp b/src/server/LV2Options.hpp
index 02824be6..b1b57429 100644
--- a/src/server/LV2Options.hpp
+++ b/src/server/LV2Options.hpp
@@ -17,10 +17,10 @@
#ifndef INGEN_ENGINE_LV2OPTIONS_HPP
#define INGEN_ENGINE_LV2OPTIONS_HPP
-#include "ingen/LV2Features.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/core/lv2.h"
-#include "lv2/options/options.h"
+#include <ingen/LV2Features.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/core/lv2.h>
+#include <lv2/options/options.h>
#include <cstdint>
#include <cstdlib>
diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp
index 98234746..87072ab0 100644
--- a/src/server/LV2Plugin.cpp
+++ b/src/server/LV2Plugin.cpp
@@ -19,16 +19,18 @@
#include "Engine.hpp"
#include "LV2Block.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lilv/lilv.h>
+#include <raul/Symbol.hpp>
#include <cstdlib>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
LV2Plugin::LV2Plugin(World& world, const LilvPlugin* lplugin)
: PluginImpl(world.uris(),
@@ -70,18 +72,18 @@ LV2Plugin::symbol() const
{
std::string working = uri();
if (working.back() == '/') {
- working = working.substr(0, working.length() - 1);
+ working.resize(working.length() - 1);
}
- while (working.length() > 0) {
- size_t last_slash = working.find_last_of('/');
+ while (!working.empty()) {
+ const size_t last_slash = working.find_last_of('/');
const std::string symbol = working.substr(last_slash+1);
if ( (symbol[0] >= 'a' && symbol[0] <= 'z')
|| (symbol[0] >= 'A' && symbol[0] <= 'Z') ) {
return raul::Symbol::symbolify(symbol);
}
- working = working.substr(0, last_slash);
+ working.resize(last_slash);
}
return raul::Symbol("lv2_symbol");
@@ -140,5 +142,4 @@ LV2Plugin::load_presets()
PluginImpl::load_presets();
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/LV2Plugin.hpp b/src/server/LV2Plugin.hpp
index fa007327..c94e88f7 100644
--- a/src/server/LV2Plugin.hpp
+++ b/src/server/LV2Plugin.hpp
@@ -19,9 +19,8 @@
#include "PluginImpl.hpp"
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
-#include "raul/Symbol.hpp"
+#include <ingen/URI.hpp>
+#include <lilv/lilv.h>
namespace ingen {
@@ -29,11 +28,6 @@ class World;
namespace server {
-class BlockImpl;
-class BufferFactory;
-class Engine;
-class GraphImpl;
-
/** Implementation of an LV2 plugin (loaded shared library).
*/
class LV2Plugin : public PluginImpl
diff --git a/src/server/LV2ResizeFeature.hpp b/src/server/LV2ResizeFeature.hpp
index ddad2ea7..66720e0d 100644
--- a/src/server/LV2ResizeFeature.hpp
+++ b/src/server/LV2ResizeFeature.hpp
@@ -21,13 +21,12 @@
#include "Buffer.hpp"
#include "PortImpl.hpp"
-#include "ingen/LV2Features.hpp"
-#include "lv2/resize-port/resize-port.h"
+#include <ingen/LV2Features.hpp>
+#include <lv2/resize-port/resize-port.h>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
struct ResizeFeature : public ingen::LV2Features::Feature {
static LV2_Resize_Port_Status resize_port(
@@ -62,7 +61,6 @@ struct ResizeFeature : public ingen::LV2Features::Feature {
}
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_LV2RESIZEFEATURE_HPP
diff --git a/src/server/Load.hpp b/src/server/Load.hpp
index 4a30dd58..a5216f7e 100644
--- a/src/server/Load.hpp
+++ b/src/server/Load.hpp
@@ -21,8 +21,7 @@
#include <cstdint>
#include <limits>
-namespace ingen {
-namespace server {
+namespace ingen::server {
struct Load {
void update(uint64_t time, uint64_t available) {
@@ -39,8 +38,8 @@ struct Load {
mean = load;
changed = true;
} else {
- const float a = mean + (static_cast<float>(load) - mean) /
- static_cast<float>(++n);
+ const float a = mean + ((static_cast<float>(load) - mean) /
+ static_cast<float>(++n));
if (a != mean) {
changed = floorf(a) != floorf(mean);
@@ -56,7 +55,6 @@ struct Load {
bool changed = false;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_LOAD_HPP
diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp
index 499300a2..e820a44e 100644
--- a/src/server/NodeImpl.cpp
+++ b/src/server/NodeImpl.cpp
@@ -20,15 +20,15 @@
#include "GraphImpl.hpp"
#include "ThreadManager.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Properties.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <raul/Path.hpp>
#include <map>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
NodeImpl::NodeImpl(const ingen::URIs& uris,
NodeImpl* parent,
@@ -54,5 +54,4 @@ NodeImpl::parent_graph() const
return dynamic_cast<GraphImpl*>(reinterpret_cast<BlockImpl*>(_parent));
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp
index 8acce161..fcf2f57f 100644
--- a/src/server/NodeImpl.hpp
+++ b/src/server/NodeImpl.hpp
@@ -17,17 +17,15 @@
#ifndef INGEN_ENGINE_NODEIMPL_HPP
#define INGEN_ENGINE_NODEIMPL_HPP
-#include "ingen/Node.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Node.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <cstdint>
namespace ingen {
-class Atom;
class URIs;
namespace server {
diff --git a/src/server/OutputPort.hpp b/src/server/OutputPort.hpp
index 61fb44f5..b19cd361 100644
--- a/src/server/OutputPort.hpp
+++ b/src/server/OutputPort.hpp
@@ -20,7 +20,7 @@
#include "PortImpl.hpp"
#include "PortType.hpp"
-#include "lv2/urid/urid.h"
+#include <lv2/urid/urid.h>
#include <cstddef>
#include <cstdint>
diff --git a/src/server/PluginImpl.hpp b/src/server/PluginImpl.hpp
index 3184be11..8e3642c0 100644
--- a/src/server/PluginImpl.hpp
+++ b/src/server/PluginImpl.hpp
@@ -17,11 +17,11 @@
#ifndef INGEN_ENGINE_PLUGINIMPL_HPP
#define INGEN_ENGINE_PLUGINIMPL_HPP
-#include "ingen/Atom.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "lilv/lilv.h"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
+#include <lilv/lilv.h>
+#include <raul/Symbol.hpp>
#include <map>
#include <string>
diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp
index c80b25f3..ef893478 100644
--- a/src/server/PortAudioDriver.cpp
+++ b/src/server/PortAudioDriver.cpp
@@ -21,11 +21,12 @@
#include "FrameTimer.hpp"
#include "PortType.hpp"
#include "RunContext.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "raul/Path.hpp"
+
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <raul/Path.hpp>
#include <portaudio.h>
@@ -33,8 +34,7 @@
#include <cstring>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
static bool
pa_error(const char* msg, PaError err)
@@ -282,5 +282,4 @@ PortAudioDriver::process_cb(const void* inputs,
return 0;
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/PortAudioDriver.hpp b/src/server/PortAudioDriver.hpp
index a624ee6e..6c7bfb9e 100644
--- a/src/server/PortAudioDriver.hpp
+++ b/src/server/PortAudioDriver.hpp
@@ -18,41 +18,21 @@
#define INGEN_ENGINE_PORTAUDIODRIVER_HPP
#include "Driver.hpp"
-#include "EnginePort.hpp" // IWYU pragma: keep
+#include "EnginePort.hpp"
#include "types.hpp"
-#include "ingen/URI.hpp"
-#include "raul/Semaphore.hpp"
+#include <raul/Semaphore.hpp>
+#include <boost/intrusive/options.hpp>
#include <boost/intrusive/slist.hpp>
#include <portaudio.h>
#include <atomic>
-#include <cstddef>
#include <cstdint>
#include <memory>
-namespace raul {
-class Path;
-} // namespace raul
+namespace ingen::server {
-namespace boost {
-namespace intrusive {
-
-template <bool Enabled>
-struct cache_last;
-
-} // namespace intrusive
-} // namespace boost
-
-namespace ingen {
-
-class Atom;
-
-namespace server {
-
-class Buffer;
-class DuplexPort;
class Engine;
class FrameTimer;
class RunContext;
@@ -85,7 +65,7 @@ public:
int real_time_priority() override { return 80; }
SampleCount block_length() const override { return _block_length; }
- size_t seq_size() const override { return _seq_size; }
+ uint32_t seq_size() const override { return _seq_size; }
SampleCount sample_rate() const override { return _sample_rate; }
private:
@@ -126,19 +106,18 @@ protected:
Ports _ports;
PaStreamParameters _inputParameters;
PaStreamParameters _outputParameters;
- raul::Semaphore _sem{0};
+ raul::Semaphore _sem{0U};
std::unique_ptr<FrameTimer> _timer;
PaStream* _stream{nullptr};
- size_t _seq_size{4096};
+ uint32_t _seq_size{4096U};
uint32_t _block_length;
- uint32_t _sample_rate{48000};
- uint32_t _n_inputs{0};
- uint32_t _n_outputs{0};
+ uint32_t _sample_rate{48000U};
+ uint32_t _n_inputs{0U};
+ uint32_t _n_outputs{0U};
std::atomic<bool> _flag{false};
bool _is_activated{false};
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_PORTAUDIODRIVER_HPP
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 68613e65..f6eed11f 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -23,15 +23,17 @@
#include "PortType.hpp"
#include "ThreadManager.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
#include <algorithm>
#include <cassert>
@@ -39,8 +41,7 @@
#include <memory>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
static const uint32_t monitor_rate = 25.0; // Hz
@@ -136,13 +137,13 @@ PortImpl::set_type(PortType port_type, LV2_URID buffer_type)
remove_property(uris.rdf_type, uris.lv2_CVPort);
remove_property(uris.rdf_type, uris.lv2_ControlPort);
remove_property(uris.rdf_type, uris.atom_AtomPort);
- add_property(uris.rdf_type, world.forge().make_urid(port_type.uri()));
+ add_property(uris.rdf_type, world.forge().make_urid(port_type_uri(port_type)));
// Update audio thread types
_type = port_type;
_buffer_type = buffer_type;
if (!_buffer_type) {
- switch (_type.id()) {
+ switch (_type) {
case PortType::CONTROL:
_buffer_type = uris.atom_Float;
break;
@@ -238,7 +239,7 @@ PortImpl::set_voice_value(const RunContext& ctx,
FrameTime time,
Sample value)
{
- switch (_type.id()) {
+ switch (_type) {
case PortType::CONTROL:
if (buffer(voice)->value()) {
const_cast<LV2_Atom_Float*>(
@@ -290,9 +291,9 @@ PortImpl::set_voice_value(const RunContext& ctx,
void
PortImpl::update_set_state(const RunContext& ctx, uint32_t v)
{
- Voice& voice = _voices->at(v);
- SetState& state = voice.set_state;
- BufferRef buf = voice.buffer;
+ Voice& voice = _voices->at(v);
+ SetState& state = voice.set_state;
+ const BufferRef buf = voice.buffer;
switch (state.state) {
case SetState::State::SET:
break;
@@ -420,7 +421,7 @@ PortImpl::set_is_driver_port(BufferFactory&)
void
PortImpl::clear_buffers(const RunContext& ctx)
{
- switch (_type.id()) {
+ switch (_type) {
case PortType::AUDIO:
default:
for (uint32_t v = 0; v < _poly; ++v) {
@@ -453,17 +454,17 @@ PortImpl::monitor(RunContext& ctx, bool send_now)
_frames_since_monitor += ctx.nframes();
const bool time_to_send = send_now || _frames_since_monitor >= period;
- const bool is_sequence = (_type.id() == PortType::ATOM &&
+ const bool is_sequence = (_type == PortType::ATOM &&
_buffer_type == _bufs.uris().atom_Sequence);
if (!time_to_send && !(is_sequence && _monitored) && (!is_sequence && buffer(0)->value())) {
return;
}
- Forge& forge = ctx.engine().world().forge();
- URIs& uris = ctx.engine().world().uris();
- LV2_URID key = 0;
- float val = 0.0f;
- switch (_type.id()) {
+ const Forge& forge = ctx.engine().world().forge();
+ const URIs& uris = ctx.engine().world().uris();
+ LV2_URID key = 0;
+ float val = 0.0f;
+ switch (_type) {
case PortType::UNKNOWN:
break;
case PortType::AUDIO:
@@ -536,9 +537,7 @@ PortImpl::next_value_offset(SampleCount offset, SampleCount end) const
SampleCount earliest = end;
for (uint32_t v = 0; v < _poly; ++v) {
const SampleCount o = _voices->at(v).buffer->next_value_offset(offset, end);
- if (o < earliest) {
- earliest = o;
- }
+ earliest = std::min(o, earliest);
}
return earliest;
}
@@ -577,5 +576,4 @@ PortImpl::post_process(RunContext& ctx)
monitor(ctx);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 07904cff..c202d4a0 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -20,17 +20,15 @@
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
#include "NodeImpl.hpp"
-#include "PortType.hpp"
#include "RunContext.hpp"
#include "server.h"
#include "types.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
#include <atomic>
#include <cstdint>
@@ -43,6 +41,8 @@ class Symbol;
namespace ingen {
+enum class PortType;
+
class Properties;
namespace server {
diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp
index 65f87d02..294c056a 100644
--- a/src/server/PortType.hpp
+++ b/src/server/PortType.hpp
@@ -14,81 +14,60 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef INGEN_INTERFACE_PORTTYPE_HPP
-#define INGEN_INTERFACE_PORTTYPE_HPP
+#ifndef INGEN_ENGINE_PORTTYPE_HPP
+#define INGEN_ENGINE_PORTTYPE_HPP
-#include "ingen/URI.hpp"
-
-#include "lv2/atom/atom.h"
-#include "lv2/core/lv2.h"
-
-#include <cassert>
+#include <ingen/URI.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/core/lv2.h>
namespace ingen {
-/** The type of a port.
- *
- * This type refers to the type of the port itself (not necessarily the type
- * of its contents). Ports with different types can contain the same type of
- * data, but may e.g. have different access semantics.
- */
-class PortType
-{
-public:
- enum ID {
- UNKNOWN = 0,
- AUDIO = 1,
- CONTROL = 2,
- CV = 3,
- ATOM = 4
- };
+/// The type of a port
+enum class PortType {
+ UNKNOWN,
+ AUDIO,
+ CONTROL,
+ CV,
+ ATOM,
+};
- explicit PortType(const URI& uri)
- : _id(UNKNOWN)
- {
- if (uri == type_uri(AUDIO)) {
- _id = AUDIO;
- } else if (uri == type_uri(CONTROL)) {
- _id = CONTROL;
- } else if (uri == type_uri(CV)) {
- _id = CV;
- } else if (uri == type_uri(ATOM)) {
- _id = ATOM;
- }
+/// Return the URI for `port_type`
+inline URI
+port_type_uri(const PortType port_type)
+{
+ switch (port_type) {
+ case PortType::UNKNOWN:
+ break;
+ case PortType::AUDIO:
+ return URI{LV2_CORE__AudioPort};
+ case PortType::CONTROL:
+ return URI{LV2_CORE__ControlPort};
+ case PortType::CV:
+ return URI{LV2_CORE__CVPort};
+ case PortType::ATOM:
+ return URI{LV2_ATOM__AtomPort};
}
- PortType(ID id) noexcept : _id(id) {}
-
- const URI& uri() const { return type_uri(_id); }
- ID id() const { return _id; }
+ return URI{"http://www.w3.org/2002/07/owl#Nothing"};
+}
- bool operator==(const ID& id) const { return (_id == id); }
- bool operator!=(const ID& id) const { return (_id != id); }
- bool operator==(const PortType& type) const { return (_id == type._id); }
- bool operator!=(const PortType& type) const { return (_id != type._id); }
- bool operator<(const PortType& type) const { return (_id < type._id); }
-
- bool is_audio() { return _id == AUDIO; }
- bool is_control() { return _id == CONTROL; }
- bool is_cv() { return _id == CV; }
- bool is_atom() { return _id == ATOM; }
-
-private:
- static const URI& type_uri(unsigned id_num) {
- assert(id_num <= ATOM);
- static const URI uris[] = {
- URI("http://www.w3.org/2002/07/owl#Nothing"),
- URI(LV2_CORE__AudioPort),
- URI(LV2_CORE__ControlPort),
- URI(LV2_CORE__CVPort),
- URI(LV2_ATOM__AtomPort)
- };
- return uris[id_num];
- }
-
- ID _id;
-};
+/// Return the type with the given `uri`, or #PortType::UNKNOWN
+inline PortType
+port_type_from_uri(const URI& uri)
+{
+ static const URI lv2_AudioPort = URI{LV2_CORE__AudioPort};
+ static const URI lv2_ControlPort = URI{LV2_CORE__ControlPort};
+ static const URI lv2_CVPort = URI{LV2_CORE__CVPort};
+ static const URI atom_AtomPort = URI{LV2_ATOM__AtomPort};
+
+ return (uri == lv2_AudioPort) ? PortType::AUDIO
+ : (uri == lv2_ControlPort) ? PortType::CONTROL
+ : (uri == lv2_CVPort) ? PortType::CV
+ : (uri == atom_AtomPort) ? PortType::ATOM
+ : PortType::UNKNOWN;
+}
} // namespace ingen
-#endif // INGEN_INTERFACE_PORTTYPE_HPP
+#endif // INGEN_ENGINE_PORTTYPE_HPP
diff --git a/src/server/PostProcessor.cpp b/src/server/PostProcessor.cpp
index 0e94efea..4c071ecd 100644
--- a/src/server/PostProcessor.cpp
+++ b/src/server/PostProcessor.cpp
@@ -21,10 +21,7 @@
#include <cassert>
-namespace ingen {
-namespace server {
-
-class PreProcessContext;
+namespace ingen::server {
class Sentinel : public Event
{
@@ -112,5 +109,4 @@ PostProcessor::process()
_engine.emit_notifications(end_time);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/PostProcessor.hpp b/src/server/PostProcessor.hpp
index a29d60da..7b2a3035 100644
--- a/src/server/PostProcessor.hpp
+++ b/src/server/PostProcessor.hpp
@@ -22,8 +22,7 @@
#include <atomic>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Engine;
class Event;
@@ -67,7 +66,6 @@ private:
std::atomic<FrameTime> _max_time;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_POSTPROCESSOR_HPP
diff --git a/src/server/PreProcessContext.hpp b/src/server/PreProcessContext.hpp
index 72dc64c3..7c97af3c 100644
--- a/src/server/PreProcessContext.hpp
+++ b/src/server/PreProcessContext.hpp
@@ -20,12 +20,10 @@
#include "CompiledGraph.hpp"
#include "GraphImpl.hpp"
-#include "raul/Maid.hpp"
-
+#include <memory>
#include <unordered_set>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** Event pre-processing context.
*
@@ -65,13 +63,9 @@ public:
* This may return null when an atomic bundle is deferring compilation, in
* which case the graph is flagged as dirty for later compilation.
*/
- raul::Maid::managed_ptr<CompiledGraph>
- maybe_compile(raul::Maid& maid, GraphImpl& graph)
+ [[nodiscard]] std::unique_ptr<CompiledGraph> maybe_compile(GraphImpl& graph)
{
- if (must_compile(graph)) {
- return compile(maid, graph);
- }
- return nullptr;
+ return must_compile(graph) ? compile(graph) : nullptr;
}
/** Return all graphs that require compilation after an atomic bundle. */
@@ -83,7 +77,6 @@ private:
bool _in_bundle = false;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_PREPROCESSCONTEXT_HPP
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp
index 7746d1db..b3bad0b2 100644
--- a/src/server/PreProcessor.cpp
+++ b/src/server/PreProcessor.cpp
@@ -24,18 +24,19 @@
#include "ThreadManager.hpp"
#include "UndoStack.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/AtomWriter.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/World.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/AtomWriter.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/World.hpp>
+#include <raul/Semaphore.hpp>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <memory>
+#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
PreProcessor::PreProcessor(Engine& engine)
: _engine(engine)
@@ -56,7 +57,7 @@ PreProcessor::event(Event* const ev, Event::Mode mode)
{
// TODO: Probably possible to make this lock-free with CAS
ThreadManager::assert_not_thread(THREAD_IS_REAL_TIME);
- std::lock_guard<std::mutex> lock(_mutex);
+ const std::lock_guard<std::mutex> lock{_mutex};
assert(!ev->is_prepared());
assert(!ev->next());
@@ -64,7 +65,7 @@ PreProcessor::event(Event* const ev, Event::Mode mode)
/* Note that tail is only used here, not in process(). The head must be
checked first here, since if it is null the tail pointer is junk. */
- Event* const head = _head.load();
+ const Event* const head = _head.load();
if (!head) {
_head = ev;
_tail = ev;
@@ -141,7 +142,7 @@ PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit)
if (n_processed > 0) {
#ifndef NDEBUG
- Engine& engine = ctx.engine();
+ const Engine& engine = ctx.engine();
if (engine.world().conf().option("trace").get<int32_t>()) {
const uint64_t start = engine.cycle_start_time(ctx);
const uint64_t end = engine.current_time();
@@ -150,7 +151,7 @@ PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit)
}
#endif
- auto* next = static_cast<Event*>(last->next());
+ auto* next = last->next();
last->next(nullptr);
dest.append(ctx, head, last);
@@ -242,9 +243,8 @@ PreProcessor::run()
wait_for_block_state(BlockState::UNBLOCKED);
}
- back = static_cast<Event*>(ev->next());
+ back = ev->next();
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/PreProcessor.hpp b/src/server/PreProcessor.hpp
index c17e4d87..03ba5dd7 100644
--- a/src/server/PreProcessor.hpp
+++ b/src/server/PreProcessor.hpp
@@ -19,7 +19,7 @@
#include "Event.hpp"
-#include "raul/Semaphore.hpp"
+#include <raul/Semaphore.hpp>
#include <atomic>
#include <chrono>
@@ -27,8 +27,7 @@
#include <mutex>
#include <thread>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Engine;
class PostProcessor;
@@ -84,7 +83,6 @@ private:
std::thread _thread;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_PREPROCESSOR_HPP
diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp
index f4e9219c..29985ccf 100644
--- a/src/server/RunContext.cpp
+++ b/src/server/RunContext.cpp
@@ -22,23 +22,22 @@
#include "PortImpl.hpp"
#include "Task.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/RingBuffer.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/RingBuffer.hpp>
#include <cerrno>
#include <cstring>
#include <pthread.h>
#include <sched.h>
-namespace ingen {
-namespace server {
+namespace ingen::server {
struct Notification {
explicit Notification(PortImpl* p = nullptr,
@@ -161,9 +160,9 @@ void
RunContext::set_priority(int priority)
{
if (_thread) {
- pthread_t pthread = _thread->native_handle();
- const int policy = (priority > 0) ? SCHED_FIFO : SCHED_OTHER;
- sched_param sp{};
+ const pthread_t pthread = _thread->native_handle();
+ const int policy = (priority > 0) ? SCHED_FIFO : SCHED_OTHER;
+ sched_param sp{};
sp.sched_priority = (priority > 0) ? priority : 0;
if (pthread_setschedparam(pthread, policy, &sp)) {
_engine.log().error(
@@ -194,5 +193,4 @@ RunContext::run()
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp
index 30f87efd..44304c5e 100644
--- a/src/server/RunContext.hpp
+++ b/src/server/RunContext.hpp
@@ -19,15 +19,14 @@
#include "types.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/RingBuffer.hpp"
+#include <lv2/urid/urid.h>
+#include <raul/RingBuffer.hpp>
#include <cstdint>
#include <memory>
#include <thread>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Engine;
class PortImpl;
@@ -157,7 +156,6 @@ protected:
bool _realtime{true}; ///< True iff context is hard realtime
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_RUNCONTEXT_HPP
diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp
index ed874634..fb961ee2 100644
--- a/src/server/SocketListener.cpp
+++ b/src/server/SocketListener.cpp
@@ -19,15 +19,16 @@
#include "Engine.hpp"
#include "SocketServer.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/World.hpp"
-#include "raul/Socket.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <raul/Socket.hpp>
#include <poll.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include <cerrno>
@@ -40,8 +41,7 @@
#include <string>
#include <thread>
-namespace ingen {
-namespace server {
+namespace ingen::server {
static constexpr const char* const unix_scheme = "unix://";
@@ -196,5 +196,4 @@ ingen_listen(Engine* engine, raul::Socket* unix_sock, raul::Socket* net_sock)
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/SocketListener.hpp b/src/server/SocketListener.hpp
index 70a2d46b..a96105ef 100644
--- a/src/server/SocketListener.hpp
+++ b/src/server/SocketListener.hpp
@@ -14,13 +14,12 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "raul/Socket.hpp"
+#include <raul/Socket.hpp>
#include <memory>
#include <thread>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Engine;
@@ -28,7 +27,7 @@ class Engine;
class SocketListener
{
public:
- SocketListener(Engine& engine);
+ explicit SocketListener(Engine& engine);
~SocketListener();
private:
@@ -37,5 +36,4 @@ private:
std::unique_ptr<std::thread> thread;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/SocketServer.hpp b/src/server/SocketServer.hpp
index 0531c44c..608d180d 100644
--- a/src/server/SocketServer.hpp
+++ b/src/server/SocketServer.hpp
@@ -21,24 +21,23 @@
#include "Engine.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/ColorContext.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/SocketReader.hpp"
-#include "ingen/SocketWriter.hpp"
-#include "ingen/StreamWriter.hpp"
-#include "ingen/Tee.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/World.hpp"
-#include "raul/Socket.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/ColorContext.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/SocketReader.hpp>
+#include <ingen/SocketWriter.hpp>
+#include <ingen/StreamWriter.hpp>
+#include <ingen/Tee.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <raul/Socket.hpp>
#include <cstdint>
#include <cstdio>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** The server side of an Ingen socket connection. */
class SocketServer
@@ -86,7 +85,6 @@ private:
std::shared_ptr<SocketWriter> _writer;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_SERVER_SOCKET_SERVER_HPP
diff --git a/src/server/State.hpp b/src/server/State.hpp
index 201c6b86..976cf67d 100644
--- a/src/server/State.hpp
+++ b/src/server/State.hpp
@@ -17,12 +17,11 @@
#ifndef INGEN_ENGINE_STATE_HPP
#define INGEN_ENGINE_STATE_HPP
-#include "lilv/lilv.h"
+#include <lilv/lilv.h>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
struct StateDeleter {
void operator()(LilvState* state) { lilv_state_free(state); }
@@ -30,7 +29,6 @@ struct StateDeleter {
using StatePtr = std::unique_ptr<LilvState, StateDeleter>;
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_STATE_HPP
diff --git a/src/server/Task.cpp b/src/server/Task.cpp
index 089a2f46..345a4711 100644
--- a/src/server/Task.cpp
+++ b/src/server/Task.cpp
@@ -19,13 +19,12 @@
#include "BlockImpl.hpp"
#include "RunContext.hpp"
-#include "raul/Path.hpp"
+#include <raul/Path.hpp>
#include <cstddef>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
void
Task::run(RunContext& ctx)
@@ -163,5 +162,4 @@ Task::dump(const std::function<void(const std::string&)>& sink,
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/Task.hpp b/src/server/Task.hpp
index 0a545655..f2141bd5 100644
--- a/src/server/Task.hpp
+++ b/src/server/Task.hpp
@@ -17,7 +17,6 @@
#ifndef INGEN_ENGINE_TASK_HPP
#define INGEN_ENGINE_TASK_HPP
-#include <algorithm>
#include <atomic>
#include <cassert>
#include <deque>
@@ -26,8 +25,7 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class BlockImpl;
class RunContext;
@@ -41,13 +39,15 @@ public:
PARALLEL ///< Elements may be run in any order in parallel
};
- Task(Mode mode, BlockImpl* block = nullptr)
+ Task(Mode mode, BlockImpl* block)
: _block(block)
, _mode(mode)
{
- assert(!(mode == Mode::SINGLE && !block));
+ assert(mode != Mode::SINGLE || block);
}
+ explicit Task(Mode mode) : Task{mode, nullptr} {}
+
Task(const Task&) = delete;
Task& operator=(const Task&) = delete;
@@ -116,7 +116,6 @@ private:
std::atomic<bool> _done{false}; ///< Completion phase
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_TASK_HPP
diff --git a/src/server/ThreadManager.hpp b/src/server/ThreadManager.hpp
index b25c6eed..2e0ad966 100644
--- a/src/server/ThreadManager.hpp
+++ b/src/server/ThreadManager.hpp
@@ -21,8 +21,7 @@
#include <cassert>
-namespace ingen {
-namespace server {
+namespace ingen::server {
enum ThreadFlag {
THREAD_IS_REAL_TIME = 1,
@@ -36,13 +35,13 @@ class INGEN_SERVER_API ThreadManager
public:
static void set_flag(ThreadFlag f) {
#ifndef NDEBUG
- flags = (static_cast<unsigned>(flags) | f);
+ flags |= static_cast<unsigned>(f);
#endif
}
static void unset_flag(ThreadFlag f) {
#ifndef NDEBUG
- flags = (static_cast<unsigned>(flags) & (~f));
+ flags &= ~static_cast<unsigned>(f);
#endif
}
@@ -61,7 +60,6 @@ public:
static thread_local unsigned flags;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_THREADMANAGER_HPP
diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp
index a88cc778..c6555123 100644
--- a/src/server/UndoStack.cpp
+++ b/src/server/UndoStack.cpp
@@ -16,25 +16,23 @@
#include "UndoStack.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/ingen.h"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/patch/patch.h"
-#include "serd/serd.h"
-#include "sratom/sratom.h"
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/ingen.h>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/patch/patch.h>
+#include <serd/serd.h>
+#include <sratom/sratom.h>
#include <ctime>
#include <iterator>
-#include <memory>
#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
#define USTR(s) reinterpret_cast<const uint8_t*>(s)
-namespace ingen {
-namespace server {
+namespace ingen::server {
int
UndoStack::start_entry()
@@ -42,7 +40,7 @@ UndoStack::start_entry()
if (_depth == 0) {
time_t now = {};
time(&now);
- _stack.emplace_back(Entry(now));
+ _stack.emplace_back(now);
}
return ++_depth;
}
@@ -189,8 +187,8 @@ UndoStack::write_entry(Sratom* sratom,
strftime(time_str, sizeof(time_str), "%FT%T", gmtime(&entry.time));
// entry rdf:type ingen:UndoEntry
- SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "time"));
- SerdNode o = serd_node_from_string(SERD_LITERAL, USTR(time_str));
+ SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "time"));
+ const SerdNode o = serd_node_from_string(SERD_LITERAL, USTR(time_str));
serd_writer_write_statement(writer, SERD_ANON_CONT, nullptr, subject, &p, &o, nullptr, nullptr);
p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "events"));
@@ -246,8 +244,8 @@ UndoStack::save(FILE* stream, const char* name)
reinterpret_cast<SerdEndSink>(serd_writer_end_anon),
writer);
- SerdNode s = serd_node_from_string(SERD_BLANK, USTR(name));
- SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "entries"));
+ const SerdNode s = serd_node_from_string(SERD_BLANK, USTR(name));
+ const SerdNode p = serd_node_from_string(SERD_URI, USTR(INGEN_NS "entries"));
BlankIDs ids('u');
ListContext ctx(ids, 0, &s, &p);
@@ -264,5 +262,4 @@ UndoStack::save(FILE* stream, const char* name)
serd_writer_free(writer);
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/UndoStack.hpp b/src/server/UndoStack.hpp
index 8195920a..443497cc 100644
--- a/src/server/UndoStack.hpp
+++ b/src/server/UndoStack.hpp
@@ -17,14 +17,13 @@
#ifndef INGEN_ENGINE_UNDOSTACK_HPP
#define INGEN_ENGINE_UNDOSTACK_HPP
-#include "ingen/AtomSink.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "serd/serd.h"
-#include "server.h"
-#include "sratom/sratom.h"
-
-#include <algorithm>
+#include <ingen/AtomSink.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <serd/serd.h>
+#include <server.h>
+#include <sratom/sratom.h>
+
#include <cstdint>
#include <cstdio>
#include <cstdlib>
@@ -43,7 +42,8 @@ class INGEN_SERVER_API UndoStack : public AtomSink
{
public:
struct Entry {
- Entry(time_t t = 0) noexcept : time(t) {}
+ explicit Entry(time_t t) noexcept : time{t} {}
+ Entry() noexcept : Entry{0} {}
Entry(const Entry& copy)
: time(copy.time)
diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp
index 5b4da498..1c04bb36 100644
--- a/src/server/Worker.cpp
+++ b/src/server/Worker.cpp
@@ -20,19 +20,17 @@
#include "GraphImpl.hpp"
#include "LV2Block.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Node.hpp"
-#include "lv2/core/lv2.h"
-#include "lv2/worker/worker.h"
+#include <ingen/Log.hpp>
+#include <ingen/Node.hpp>
+#include <lv2/core/lv2.h>
+#include <lv2/worker/worker.h>
+#include <raul/RingBuffer.hpp>
+#include <raul/Semaphore.hpp>
#include <cstdlib>
#include <memory>
-namespace ingen {
-
-class World;
-
-namespace server {
+namespace ingen::server {
/// A message in the Worker::_requests ring
struct MessageHeader {
@@ -46,8 +44,8 @@ schedule(LV2_Worker_Schedule_Handle handle,
uint32_t size,
const void* data)
{
- auto* block = static_cast<LV2Block*>(handle);
- Engine& engine = block->parent_graph()->engine();
+ auto* block = static_cast<LV2Block*>(handle);
+ const Engine& engine = block->parent_graph()->engine();
return engine.worker()->request(block, size, data);
}
@@ -57,8 +55,8 @@ schedule_sync(LV2_Worker_Schedule_Handle handle,
uint32_t size,
const void* data)
{
- auto* block = static_cast<LV2Block*>(handle);
- Engine& engine = block->parent_graph()->engine();
+ auto* block = static_cast<LV2Block*>(handle);
+ const Engine& engine = block->parent_graph()->engine();
return engine.sync_worker()->request(block, size, data);
}
@@ -72,7 +70,7 @@ Worker::request(LV2Block* block,
return block->work(size, data);
}
- Engine& engine = block->parent_graph()->engine();
+ const Engine& engine = block->parent_graph()->engine();
if (_requests.write_space() < sizeof(MessageHeader) + size) {
engine.log().error("Work request ring overflow\n");
return LV2_WORKER_ERR_NO_SPACE;
@@ -164,5 +162,4 @@ Worker::run()
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/Worker.hpp b/src/server/Worker.hpp
index 540347df..08b75509 100644
--- a/src/server/Worker.hpp
+++ b/src/server/Worker.hpp
@@ -17,11 +17,11 @@
#ifndef INGEN_ENGINE_WORKER_HPP
#define INGEN_ENGINE_WORKER_HPP
-#include "ingen/LV2Features.hpp"
-#include "lv2/core/lv2.h"
-#include "lv2/worker/worker.h"
-#include "raul/RingBuffer.hpp"
-#include "raul/Semaphore.hpp"
+#include <ingen/LV2Features.hpp>
+#include <lv2/core/lv2.h>
+#include <lv2/worker/worker.h>
+#include <raul/RingBuffer.hpp>
+#include <raul/Semaphore.hpp>
#include <cstdint>
#include <memory>
@@ -30,8 +30,6 @@
namespace ingen {
class Log;
-class Node;
-class World;
namespace server {
@@ -44,7 +42,7 @@ public:
~Worker();
struct Schedule : public LV2Features::Feature {
- Schedule(bool sync) noexcept : synchronous(sync) {}
+ explicit Schedule(bool sync) noexcept : synchronous(sync) {}
const char* uri() const override { return LV2_WORKER__schedule; }
diff --git a/src/server/events.hpp b/src/server/events.hpp
index 5f77b431..7ab20ca7 100644
--- a/src/server/events.hpp
+++ b/src/server/events.hpp
@@ -17,19 +17,19 @@
#ifndef INGEN_ENGINE_EVENTS_HPP
#define INGEN_ENGINE_EVENTS_HPP
-#include "events/Connect.hpp"
-#include "events/Copy.hpp"
-#include "events/CreateBlock.hpp"
-#include "events/CreateGraph.hpp"
-#include "events/CreatePort.hpp"
-#include "events/Delete.hpp"
-#include "events/Delta.hpp"
-#include "events/Disconnect.hpp"
-#include "events/DisconnectAll.hpp"
-#include "events/Get.hpp"
-#include "events/Mark.hpp"
-#include "events/Move.hpp"
-#include "events/SetPortValue.hpp"
-#include "events/Undo.hpp"
+#include <events/Connect.hpp>
+#include <events/Copy.hpp>
+#include <events/CreateBlock.hpp>
+#include <events/CreateGraph.hpp>
+#include <events/CreatePort.hpp>
+#include <events/Delete.hpp>
+#include <events/Delta.hpp>
+#include <events/Disconnect.hpp>
+#include <events/DisconnectAll.hpp>
+#include <events/Get.hpp>
+#include <events/Mark.hpp>
+#include <events/Move.hpp>
+#include <events/SetPortValue.hpp>
+#include <events/Undo.hpp>
#endif // INGEN_ENGINE_EVENTS_HPP
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 386ed74d..6e20be8f 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -16,6 +16,7 @@
#include "Connect.hpp"
+#include "../internals/BlockDelay.hpp"
#include "ArcImpl.hpp"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
@@ -26,15 +27,16 @@
#include "InputPort.hpp"
#include "PortImpl.hpp"
#include "PreProcessContext.hpp"
-#include "internals/BlockDelay.hpp"
#include "types.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Maid.hpp>
#include <cassert>
#include <memory>
@@ -42,9 +44,7 @@
#include <set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Connect::Connect(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -59,7 +59,7 @@ Connect::~Connect() = default;
bool
Connect::pre_process(PreProcessContext& ctx)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
Node* tail = _engine.store()->get(_msg.tail);
if (!tail) {
@@ -134,7 +134,7 @@ Connect::pre_process(PreProcessContext& ctx)
head_block->providers().insert(tail_block);
if (ctx.must_compile(*_graph)) {
- if (!(_compiled_graph = compile(*_engine.maid(), *_graph))) {
+ if (!(_compiled_graph = compile(*_graph))) {
head_block->providers().erase(tail_block);
tail_block->dependants().erase(head_block);
return Event::pre_process_done(Status::COMPILATION_FAILED);
@@ -167,7 +167,7 @@ Connect::execute(RunContext& ctx)
}
_head->connect_buffers();
if (_compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = _graph->swap_compiled_graph(std::move(_compiled_graph));
}
}
}
@@ -175,7 +175,7 @@ Connect::execute(RunContext& ctx)
void
Connect::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
if (!_tail_remove.empty() || !_tail_add.empty()) {
@@ -195,6 +195,4 @@ Connect::undo(Interface& target)
target.disconnect(_msg.tail, _msg.head);
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index a735b68c..458df0ef 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -21,9 +21,9 @@
#include "PortImpl.hpp"
#include "types.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Properties.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/Properties.hpp>
+#include <raul/Maid.hpp>
#include <memory>
@@ -38,8 +38,6 @@ class CompiledGraph;
class Engine;
class GraphImpl;
class InputPort;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -66,7 +64,7 @@ private:
const ingen::Connect _msg;
GraphImpl* _graph{nullptr};
InputPort* _head{nullptr};
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
std::shared_ptr<ArcImpl> _arc;
raul::managed_ptr<PortImpl::Voices> _voices;
Properties _tail_remove;
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index beb5224c..e75bf1c5 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -14,7 +14,7 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/Copy.hpp"
+#include "Copy.hpp"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
@@ -23,28 +23,28 @@
#include "GraphImpl.hpp"
#include "PreProcessContext.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Parser.hpp"
-#include "ingen/Serialiser.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/World.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Parser.hpp>
+#include <ingen/Serialiser.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <map>
#include <memory>
#include <mutex>
+#include <optional>
#include <string>
+#include <string_view>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Copy::Copy(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -59,7 +59,7 @@ Copy::~Copy() = default;
bool
Copy::pre_process(PreProcessContext& ctx)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
if (uri_is_path(_msg.old_uri)) {
// Old URI is a path within the engine
@@ -126,8 +126,7 @@ Copy::engine_to_engine(PreProcessContext& ctx)
}
// Create new block
- if (!(_block = dynamic_cast<BlockImpl*>(
- _old_block->duplicate(_engine, raul::Symbol(new_path.symbol()), _parent)))) {
+ if (!(_block = _old_block->duplicate(_engine, raul::Symbol(new_path.symbol()), _parent))) {
return Event::pre_process_done(Status::INTERNAL_ERROR);
}
@@ -138,7 +137,7 @@ Copy::engine_to_engine(PreProcessContext& ctx)
_engine.store()->add(_block);
// Compile graph with new block added for insertion in audio thread
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent);
+ _compiled_graph = ctx.maybe_compile(*_parent);
return Event::pre_process_done(Status::SUCCESS);
}
@@ -165,7 +164,7 @@ Copy::engine_to_filesystem(PreProcessContext&)
return Event::pre_process_done(Status::INTERNAL_ERROR);
}
- std::lock_guard<std::mutex> lock(_engine.world().rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_engine.world().rdf_mutex()};
if (ends_with(_msg.new_uri, ".ingen") || ends_with(_msg.new_uri, ".ingen/")) {
_engine.world().serialiser()->write_bundle(graph, URI(_msg.new_uri));
@@ -186,13 +185,13 @@ Copy::filesystem_to_engine(PreProcessContext&)
return Event::pre_process_done(Status::INTERNAL_ERROR);
}
- std::lock_guard<std::mutex> lock(_engine.world().rdf_mutex());
+ const std::lock_guard<std::mutex> lock{_engine.world().rdf_mutex()};
// Old URI is a filesystem path and new URI is a path within the engine
- const std::string src_path(_msg.old_uri.path());
- const raul::Path dst_path = uri_to_path(_msg.new_uri);
- boost::optional<raul::Path> dst_parent;
- boost::optional<raul::Symbol> dst_symbol;
+ const std::string src_path(_msg.old_uri.path());
+ const raul::Path dst_path = uri_to_path(_msg.new_uri);
+ std::optional<raul::Path> dst_parent;
+ std::optional<raul::Symbol> dst_symbol;
if (!dst_path.is_root()) {
dst_parent = dst_path.parent();
dst_symbol = raul::Symbol(dst_path.symbol());
@@ -209,14 +208,15 @@ void
Copy::execute(RunContext&)
{
if (_block && _compiled_graph) {
- _parent->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph =
+ _parent->swap_compiled_graph(std::move(_compiled_graph));
}
}
void
Copy::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -230,6 +230,4 @@ Copy::undo(Interface& target)
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Copy.hpp b/src/server/events/Copy.hpp
index 8460140a..8031bb42 100644
--- a/src/server/events/Copy.hpp
+++ b/src/server/events/Copy.hpp
@@ -20,8 +20,7 @@
#include "Event.hpp"
#include "types.hpp"
-#include "ingen/Message.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Message.hpp>
#include <memory>
@@ -36,7 +35,6 @@ class CompiledGraph;
class Engine;
class GraphImpl;
class PreProcessContext;
-class RunContext;
namespace events {
@@ -67,7 +65,7 @@ private:
std::shared_ptr<BlockImpl> _old_block{nullptr};
GraphImpl* _parent{nullptr};
BlockImpl* _block{nullptr};
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
};
} // namespace events
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index 23a0d35e..55c9b782 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -28,32 +28,27 @@
#include "State.hpp"
#include "types.hpp"
-#include "ingen/FilePath.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/Maid.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/FilePath.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 <map>
#include <memory>
+#include <string>
#include <utility>
-namespace ingen {
-namespace server {
-
-class RunContext;
-
-namespace events {
+namespace ingen::server::events {
CreateBlock::CreateBlock(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -170,7 +165,7 @@ CreateBlock::pre_process(PreProcessContext& ctx)
/* Compile graph with new block added for insertion in audio thread
TODO: Since the block is not connected at this point, a full compilation
could be avoided and the block simply appended. */
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph);
+ _compiled_graph = ctx.maybe_compile(*_graph);
_update.put_block(_block);
@@ -181,14 +176,15 @@ void
CreateBlock::execute(RunContext&)
{
if (_status == Status::SUCCESS && _compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph =
+ _graph->swap_compiled_graph(std::move(_compiled_graph));
}
}
void
CreateBlock::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_update.send(*_engine.broadcaster());
}
@@ -200,6 +196,4 @@ CreateBlock::undo(Interface& target)
target.del(_block->uri());
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp
index 2a7a60ab..0ee6e36f 100644
--- a/src/server/events/CreateBlock.hpp
+++ b/src/server/events/CreateBlock.hpp
@@ -21,8 +21,7 @@
#include "Event.hpp"
#include "types.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <raul/Path.hpp>
#include <cstdint>
#include <memory>
@@ -38,8 +37,6 @@ class BlockImpl;
class CompiledGraph;
class Engine;
class GraphImpl;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -70,7 +67,7 @@ private:
ClientUpdate _update;
GraphImpl* _graph{nullptr};
BlockImpl* _block{nullptr};
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
};
} // namespace events
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index c1a30d4d..5df28afa 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -14,50 +14,49 @@
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 "types.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.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/Maid.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.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 {
+namespace ingen::server::events {
CreateGraph::CreateGraph(Engine& engine,
const std::shared_ptr<Interface>& client,
int32_t id,
SampleCount timestamp,
raul::Path path,
- const Properties& properties)
+ Properties properties)
: Event(engine, client, id, timestamp)
, _path(std::move(path))
- , _properties(properties)
+ , _properties(std::move(properties))
{}
CreateGraph::~CreateGraph() = default;
@@ -194,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());
@@ -221,7 +220,8 @@ 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);
@@ -237,7 +237,7 @@ CreateGraph::execute(RunContext& ctx)
void
CreateGraph::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_update.send(*_engine.broadcaster());
}
@@ -255,6 +255,4 @@ CreateGraph::undo(Interface& target)
target.del(_graph->uri());
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp
index 46ca3266..1d7f04a5 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -21,9 +21,8 @@
#include "Event.hpp"
#include "types.hpp"
-#include "ingen/Properties.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Properties.hpp>
+#include <raul/Path.hpp>
#include <cstdint>
#include <list>
@@ -38,8 +37,6 @@ namespace server {
class CompiledGraph;
class Engine;
class GraphImpl;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -55,7 +52,7 @@ public:
int32_t id,
SampleCount timestamp,
raul::Path path,
- const Properties& properties);
+ Properties properties);
~CreateGraph() override;
@@ -74,7 +71,7 @@ private:
ClientUpdate _update;
GraphImpl* _graph{nullptr};
GraphImpl* _parent{nullptr};
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
std::list<std::unique_ptr<Event>> _child_events;
};
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 6eee6ed7..b42542f8 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -23,31 +23,32 @@
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "PortImpl.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/paths.hpp"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-#include "raul/Symbol.hpp"
+#include "PortType.hpp"
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <map>
#include <memory>
+#include <string>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
CreatePort::CreatePort(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -57,7 +58,6 @@ CreatePort::CreatePort(Engine& engine,
const Properties& properties)
: Event(engine, client, id, timestamp)
, _path(std::move(path))
- , _port_type(PortType::UNKNOWN)
, _properties(properties)
{
const ingen::URIs& uris = _engine.world().uris();
@@ -181,7 +181,7 @@ CreatePort::pre_process(PreProcessContext&)
_update = _graph_port->properties();
assert(_graph_port->index() == static_cast<uint32_t>(index_i->second.get<int32_t>()));
- assert(_graph->num_ports_non_rt() == static_cast<uint32_t>(old_n_ports) + 1u);
+ assert(_graph->num_ports_non_rt() == static_cast<uint32_t>(old_n_ports) + 1U);
assert(_ports_array->size() == _graph->num_ports_non_rt());
assert(_graph_port->index() < _ports_array->size());
return Event::pre_process_done(Status::SUCCESS);
@@ -212,7 +212,7 @@ CreatePort::execute(RunContext& ctx)
void
CreatePort::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->put(path_to_uri(_path), _update);
}
@@ -224,6 +224,4 @@ CreatePort::undo(Interface& target)
target.del(_graph_port->uri());
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 3351adc9..151bf82f 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -22,15 +22,14 @@
#include "PortType.hpp"
#include "types.hpp"
-#include "ingen/Properties.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/Properties.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
#include <cstdint>
#include <memory>
+#include <optional>
namespace ingen {
@@ -42,8 +41,6 @@ class DuplexPort;
class Engine;
class EnginePort;
class GraphImpl;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -73,7 +70,7 @@ private:
};
raul::Path _path;
- PortType _port_type;
+ PortType _port_type{PortType::UNKNOWN};
LV2_URID _buf_type{0};
GraphImpl* _graph{nullptr};
DuplexPort* _graph_port{nullptr};
@@ -81,7 +78,7 @@ private:
EnginePort* _engine_port{nullptr}; ///< Driver port if on the root
Properties _properties;
Properties _update;
- boost::optional<Flow> _flow;
+ std::optional<Flow> _flow;
};
} // namespace events
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index aba49adb..9e940ea7 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -30,31 +30,27 @@
#include "PortImpl.hpp"
#include "PreProcessContext.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.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/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.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/Array.hpp>
+#include <raul/Path.hpp>
#include <cassert>
#include <cstddef>
#include <memory>
#include <mutex>
#include <string>
+#include <string_view>
-namespace ingen {
-namespace server {
-
-class RunContext;
-
-namespace events {
+namespace ingen::server::events {
Delete::Delete(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -104,7 +100,7 @@ Delete::pre_process(PreProcessContext& ctx)
}
// Take a writer lock while we modify the store
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
_engine.store()->remove(iter, _removed_objects);
@@ -113,14 +109,14 @@ Delete::pre_process(PreProcessContext& ctx)
_disconnect_event =
std::make_unique<DisconnectAll>(_engine, parent, _block.get());
_disconnect_event->pre_process(ctx);
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
+ _compiled_graph = ctx.maybe_compile(*parent);
} else if (_port) {
parent->remove_port(*_port);
_disconnect_event =
std::make_unique<DisconnectAll>(_engine, parent, _port.get());
_disconnect_event->pre_process(ctx);
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
+ _compiled_graph = ctx.maybe_compile(*parent);
if (parent->enabled()) {
_ports_array = parent->build_ports_array(*_engine.maid());
assert(_ports_array->size() == parent->num_ports_non_rt());
@@ -182,14 +178,14 @@ Delete::execute(RunContext& ctx)
}
if (parent && _compiled_graph) {
- parent->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = parent->swap_compiled_graph(std::move(_compiled_graph));
}
}
void
Delete::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS && (_block || _port)) {
if (_block) {
_block->deactivate();
@@ -225,12 +221,10 @@ Delete::undo(Interface& target)
if (c.first != _msg.uri.path()) {
target.set_property(path_to_uri(c.first),
uris.lv2_index,
- forge.make(int32_t(c.second.first)));
+ forge.make(static_cast<int32_t>(c.second.first)));
}
}
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 7dfb5681..7e901f4b 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -17,35 +17,36 @@
#ifndef INGEN_EVENTS_DELETE_HPP
#define INGEN_EVENTS_DELETE_HPP
-#include "BlockImpl.hpp"
#include "ControlBindings.hpp"
#include "Event.hpp"
#include "GraphImpl.hpp"
#include "types.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/Store.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
#include <cstdint>
#include <map>
#include <memory>
+#include <string>
#include <utility>
#include <vector>
+// IWYU pragma: no_include <iterator>
+
namespace ingen {
class Interface;
namespace server {
+class BlockImpl;
class CompiledGraph;
class DuplexPort;
class Engine;
class EnginePort;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -79,7 +80,7 @@ private:
std::shared_ptr<DuplexPort> _port; ///< Non-null iff a port
EnginePort* _engine_port{nullptr};
raul::managed_ptr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph
- raul::managed_ptr<CompiledGraph> _compiled_graph; ///< Graph's new process order
+ std::unique_ptr<CompiledGraph> _compiled_graph; ///< Graph's new process order
std::unique_ptr<DisconnectAll> _disconnect_event;
Store::Objects _removed_objects;
IndexChanges _port_index_changes;
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 71d4b48f..cba21214 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -32,36 +32,33 @@
#include "PortType.hpp"
#include "SetPortValue.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/paths.hpp"
-#include "lilv/lilv.h"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-
-#include <algorithm>
+#include <ingen/Atom.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Message.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 <lilv/lilv.h>
+#include <raul/Path.hpp>
+
#include <memory>
#include <mutex>
#include <set>
#include <string>
+#include <string_view>
#include <utility>
#include <vector>
-namespace ingen {
-namespace server {
-
-class PreProcessContext;
-
-namespace events {
+namespace ingen::server::events {
Delta::Delta(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -213,7 +210,7 @@ Delta::pre_process(PreProcessContext& ctx)
return Event::pre_process_done(Status::FAILURE);
}
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
_object = is_graph_object
? static_cast<ingen::Resource*>(_engine.store()->get(uri_to_path(_subject)))
@@ -225,7 +222,7 @@ Delta::pre_process(PreProcessContext& ctx)
}
if (is_graph_object && !_object) {
- raul::Path path(uri_to_path(_subject));
+ const raul::Path path{uri_to_path(_subject)};
bool is_graph = false;
bool is_block = false;
@@ -318,8 +315,8 @@ Delta::pre_process(PreProcessContext& ctx)
const Property& value = p.second;
SpecialType op = SpecialType::NONE;
if (obj) {
- Resource& resource = *obj;
if (value != uris.patch_wildcard) {
+ Resource& resource = *obj;
if (resource.add_property(key, value, value.context())) {
_added.emplace(key, value);
}
@@ -397,7 +394,7 @@ Delta::pre_process(PreProcessContext& ctx)
op = SpecialType::ENABLE;
// FIXME: defer until all other data has been processed
if (value.get<int32_t>() && !_graph->enabled()) {
- if (!(_compiled_graph = compile(*_engine.maid(), *_graph))) {
+ if (!(_compiled_graph = compile(*_graph))) {
_status = Status::COMPILATION_FAILED;
}
}
@@ -516,7 +513,7 @@ Delta::execute(RunContext& ctx)
if (_graph) {
if (value.get<int32_t>()) {
if (_compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = _graph->swap_compiled_graph(std::move(_compiled_graph));
}
_graph->enable();
} else {
@@ -594,7 +591,7 @@ Delta::post_process()
_state.reset();
}
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (_create_event) {
_create_event->post_process();
@@ -673,6 +670,4 @@ Delta::get_execution() const
return _block ? Execution::ATOMIC : Execution::NORMAL;
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index 7f79ae94..befbdcc7 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -18,25 +18,22 @@
#define INGEN_EVENTS_DELTA_HPP
#include "ClientUpdate.hpp"
+#include "CompiledGraph.hpp"
#include "ControlBindings.hpp"
#include "Event.hpp"
#include "SetPortValue.hpp"
#include "State.hpp"
#include "types.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/Resource.hpp"
-#include "ingen/URI.hpp"
-#include "raul/Maid.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
#include <cstdint>
#include <memory>
+#include <optional>
#include <vector>
-// IWYU pragma: no_include <algorithm>
-
namespace ingen {
class Interface;
@@ -46,11 +43,8 @@ struct SetProperty;
namespace server {
-class CompiledGraph;
class Engine;
class GraphImpl;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -118,7 +112,7 @@ private:
ClientUpdate _update;
ingen::Resource* _object{nullptr};
GraphImpl* _graph{nullptr};
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
ControlBindings::Binding* _binding{nullptr};
StatePtr _state;
Resource::Graph _context;
@@ -129,7 +123,7 @@ private:
std::vector<ControlBindings::Binding*> _removed_bindings;
- boost::optional<Resource> _preset;
+ std::optional<Resource> _preset;
bool _block{false};
};
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 3526ac83..7189fdd0 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -14,7 +14,7 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/Disconnect.hpp"
+#include "Disconnect.hpp"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
@@ -30,14 +30,15 @@
#include "PreProcessContext.hpp"
#include "ThreadManager.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
#include <cassert>
#include <cstdint>
@@ -47,8 +48,7 @@
#include <string>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class RunContext;
@@ -118,7 +118,7 @@ Disconnect::Impl::Impl(Engine& e,
bool
Disconnect::pre_process(PreProcessContext& ctx)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
if (_msg.tail.parent().parent() != _msg.head.parent().parent()
&& _msg.tail.parent() != _msg.head.parent().parent()
@@ -169,10 +169,10 @@ Disconnect::pre_process(PreProcessContext& ctx)
_impl = std::make_unique<Impl>(_engine,
_graph,
- dynamic_cast<PortImpl*>(tail),
+ tail,
dynamic_cast<InputPort*>(head));
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph);
+ _compiled_graph = ctx.maybe_compile(*_graph);
return Event::pre_process_done(Status::SUCCESS);
}
@@ -209,7 +209,8 @@ Disconnect::execute(RunContext& ctx)
if (_status == Status::SUCCESS) {
if (_impl->execute(ctx, true)) {
if (_compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph =
+ _graph->swap_compiled_graph(std::move(_compiled_graph));
}
} else {
_status = Status::NOT_FOUND;
@@ -220,7 +221,7 @@ Disconnect::execute(RunContext& ctx)
void
Disconnect::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -233,5 +234,4 @@ Disconnect::undo(Interface& target)
}
} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index 71ad4204..92dd81d3 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -21,8 +21,8 @@
#include "PortImpl.hpp"
#include "types.hpp"
-#include "ingen/Message.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Message.hpp>
+#include <raul/Maid.hpp>
#include <memory>
@@ -37,7 +37,6 @@ class CompiledGraph;
class Engine;
class GraphImpl;
class InputPort;
-class PreProcessContext;
class RunContext;
namespace events {
@@ -83,7 +82,7 @@ private:
const ingen::Disconnect _msg;
GraphImpl* _graph{nullptr};
std::unique_ptr<Impl> _impl;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
};
} // namespace events
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 7ae17632..8e7bfbbe 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -14,34 +14,35 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/DisconnectAll.hpp"
+#include "DisconnectAll.hpp"
#include "ArcImpl.hpp"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
#include "CompiledGraph.hpp"
+#include "Disconnect.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "InputPort.hpp"
#include "NodeImpl.hpp"
#include "PortImpl.hpp"
#include "PreProcessContext.hpp"
-#include "events/Disconnect.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <raul/Path.hpp>
+#include <algorithm>
+#include <iterator>
#include <memory>
#include <mutex>
#include <set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
DisconnectAll::DisconnectAll(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -70,7 +71,7 @@ DisconnectAll::DisconnectAll(Engine& engine,
DisconnectAll::~DisconnectAll()
{
- for (auto& i : _impls) {
+ for (auto* i : _impls) {
delete i;
}
}
@@ -111,28 +112,35 @@ DisconnectAll::pre_process(PreProcessContext& ctx)
}
// Create disconnect events to erase adjacent arcs in parent
- for (const auto& a : adjacent_arcs(_parent)) {
- _impls.push_back(
- new Disconnect::Impl(_engine,
- _parent,
- dynamic_cast<PortImpl*>(a->tail()),
- dynamic_cast<InputPort*>(a->head())));
- }
+ const auto& arcs = adjacent_arcs(_parent);
+ std::transform(arcs.begin(),
+ arcs.end(),
+ std::back_inserter(_impls),
+ [this](const auto& a) {
+ return new Disconnect::Impl(_engine,
+ _parent,
+ a->tail(),
+ dynamic_cast<InputPort*>(a->head()));
+ });
// Create disconnect events to erase adjacent arcs in parent's parent
if (_port && _parent->parent()) {
- auto* const parent_parent = dynamic_cast<GraphImpl*>(_parent->parent());
- for (const auto& a : adjacent_arcs(parent_parent)) {
- _impls.push_back(
- new Disconnect::Impl(_engine,
- parent_parent,
- dynamic_cast<PortImpl*>(a->tail()),
- dynamic_cast<InputPort*>(a->head())));
- }
+ auto* const grandparent = dynamic_cast<GraphImpl*>(_parent->parent());
+ const auto& parent_arcs = adjacent_arcs(grandparent);
+
+ std::transform(parent_arcs.begin(),
+ parent_arcs.end(),
+ std::back_inserter(_impls),
+ [this, grandparent](const auto& a) {
+ return new Disconnect::Impl(_engine,
+ grandparent,
+ a->tail(),
+ dynamic_cast<InputPort*>(a->head()));
+ });
}
if (!_deleting && ctx.must_compile(*_parent)) {
- if (!(_compiled_graph = compile(*_engine.maid(), *_parent))) {
+ if (!(_compiled_graph = compile(*_parent))) {
return Event::pre_process_done(Status::COMPILATION_FAILED);
}
}
@@ -151,14 +159,14 @@ DisconnectAll::execute(RunContext& ctx)
}
if (_compiled_graph) {
- _parent->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = _parent->swap_compiled_graph(std::move(_compiled_graph));
}
}
void
DisconnectAll::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -193,6 +201,4 @@ DisconnectAll::adjacent_arcs(GraphImpl* const graph)
return arcs;
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp
index 70da5dd6..0eeda6f8 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -21,8 +21,7 @@
#include "Event.hpp"
#include "types.hpp"
-#include "ingen/Message.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Message.hpp>
#include <list>
#include <memory>
@@ -41,8 +40,6 @@ class CompiledGraph;
class Engine;
class GraphImpl;
class PortImpl;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -79,7 +76,7 @@ private:
BlockImpl* _block;
PortImpl* _port;
Impls _impls;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
bool _deleting;
};
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 389d9e48..45e7ea94 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -22,24 +22,24 @@
#include "GraphImpl.hpp"
#include "PortImpl.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Properties.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 <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.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 <cstdint>
#include <memory>
#include <mutex>
+#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Get::Get(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -52,7 +52,7 @@ Get::Get(Engine& engine,
bool
Get::pre_process(PreProcessContext&)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
const auto& uri = _msg.subject;
if (uri == "ingen:/plugins") {
@@ -98,7 +98,7 @@ Get::execute(RunContext&)
void
Get::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS && _request_client) {
if (_msg.subject == "ingen:/plugins") {
_engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins);
@@ -107,11 +107,11 @@ Get::post_process()
URIs& uris = _engine.world().uris();
Properties props = {
{ uris.param_sampleRate,
- uris.forge.make(int32_t(_engine.sample_rate())) },
+ uris.forge.make(static_cast<int32_t>(_engine.sample_rate())) },
{ uris.bufsz_maxBlockLength,
- uris.forge.make(int32_t(_engine.block_length())) },
+ uris.forge.make(static_cast<int32_t>(_engine.block_length())) },
{ uris.ingen_numThreads,
- uris.forge.make(int32_t(_engine.n_threads())) } };
+ uris.forge.make(static_cast<int32_t>(_engine.n_threads())) } };
const Properties load_props = _engine.load_properties();
props.insert(load_props.begin(), load_props.end());
@@ -122,6 +122,4 @@ Get::post_process()
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp
index 1ec49bfa..0f5ed235 100644
--- a/src/server/events/Get.hpp
+++ b/src/server/events/Get.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_EVENTS_GET_HPP
#define INGEN_EVENTS_GET_HPP
-#include "ingen/Message.hpp"
+#include <ingen/Message.hpp>
#include "BlockFactory.hpp"
#include "ClientUpdate.hpp"
@@ -35,8 +35,6 @@ namespace server {
class Engine;
class PluginImpl;
-class PreProcessContext;
-class RunContext;
namespace events {
diff --git a/src/server/events/Mark.cpp b/src/server/events/Mark.cpp
index 27ca6630..b60b0432 100644
--- a/src/server/events/Mark.cpp
+++ b/src/server/events/Mark.cpp
@@ -14,10 +14,7 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/Mark.hpp"
-
-#include "ingen/Message.hpp"
-#include "ingen/Status.hpp"
+#include "Mark.hpp"
#include "CompiledGraph.hpp"
#include "Engine.hpp"
@@ -25,14 +22,15 @@
#include "PreProcessContext.hpp"
#include "UndoStack.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/Status.hpp>
+
#include <cassert>
#include <memory>
#include <unordered_set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Mark::Mark(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -86,7 +84,7 @@ Mark::pre_process(PreProcessContext& ctx)
ctx.set_in_bundle(false);
if (!ctx.dirty_graphs().empty()) {
for (GraphImpl* g : ctx.dirty_graphs()) {
- auto cg = compile(*_engine.maid(), *g);
+ auto cg = compile(*g);
if (cg) {
_compiled_graphs.emplace(g, std::move(cg));
}
@@ -103,7 +101,7 @@ void
Mark::execute(RunContext&)
{
for (auto& g : _compiled_graphs) {
- g.first->set_compiled_graph(std::move(g.second));
+ g.second = g.first->swap_compiled_graph(std::move(g.second));
}
}
@@ -136,6 +134,4 @@ Mark::get_execution() const
return Execution::NORMAL;
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Mark.hpp b/src/server/events/Mark.hpp
index 7ebab080..e7180764 100644
--- a/src/server/events/Mark.hpp
+++ b/src/server/events/Mark.hpp
@@ -17,11 +17,10 @@
#ifndef INGEN_EVENTS_MARK_HPP
#define INGEN_EVENTS_MARK_HPP
+#include "CompiledGraph.hpp"
#include "Event.hpp"
#include "types.hpp"
-#include "raul/Maid.hpp"
-
#include <map>
#include <memory>
@@ -33,11 +32,8 @@ struct BundleEnd;
namespace server {
-class CompiledGraph;
class Engine;
class GraphImpl;
-class PreProcessContext;
-class RunContext;
namespace events {
@@ -73,8 +69,7 @@ public:
private:
enum class Type { BUNDLE_BEGIN, BUNDLE_END };
- using CompiledGraphs =
- std::map<GraphImpl*, raul::managed_ptr<CompiledGraph>>;
+ using CompiledGraphs = std::map<GraphImpl*, std::unique_ptr<CompiledGraph>>;
CompiledGraphs _compiled_graphs;
Type _type;
diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp
index 8b7ee655..80ae5a11 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -14,23 +14,23 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/Move.hpp"
+#include "Move.hpp"
#include "Broadcaster.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <raul/Path.hpp>
#include <map>
#include <memory>
#include <mutex>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class EnginePort;
@@ -47,7 +47,7 @@ Move::Move(Engine& engine,
bool
Move::pre_process(PreProcessContext&)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
if (!_msg.old_path.parent().is_parent_of(_msg.new_path)) {
return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.new_path);
@@ -79,7 +79,7 @@ Move::execute(RunContext&)
void
Move::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -92,5 +92,4 @@ Move::undo(Interface& target)
}
} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp
index 3940e825..cca4d310 100644
--- a/src/server/events/Move.hpp
+++ b/src/server/events/Move.hpp
@@ -20,7 +20,7 @@
#include "Event.hpp"
#include "types.hpp"
-#include "ingen/Message.hpp"
+#include <ingen/Message.hpp>
#include <memory>
@@ -31,8 +31,6 @@ class Interface;
namespace server {
class Engine;
-class PreProcessContext;
-class RunContext;
namespace events {
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index 8b425571..ba6859dd 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -24,18 +24,17 @@
#include "PortImpl.hpp"
#include "RunContext.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Status.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "lv2/atom/atom.h"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/atom/atom.h>
#include <cassert>
#include <memory>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
/** Internal */
SetPortValue::SetPortValue(Engine& engine,
@@ -56,7 +55,7 @@ SetPortValue::SetPortValue(Engine& engine,
bool
SetPortValue::pre_process(PreProcessContext&)
{
- ingen::URIs& uris = _engine.world().uris();
+ const ingen::URIs& uris = _engine.world().uris();
if (_port->is_output()) {
return Event::pre_process_done(Status::DIRECTION_MISMATCH, _port->path());
}
@@ -94,8 +93,8 @@ SetPortValue::apply(RunContext& ctx)
return;
}
- ingen::URIs& uris = _engine.world().uris();
- Buffer* buf = _port->buffer(0).get();
+ const ingen::URIs& uris = _engine.world().uris();
+ Buffer* buf = _port->buffer(0).get();
if (_buffer) {
if (_port->user_buffer(ctx)) {
@@ -129,7 +128,7 @@ SetPortValue::apply(RunContext& ctx)
void
SetPortValue::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS && !_activity) {
_engine.broadcaster()->set_property(
_port->uri(),
@@ -138,6 +137,4 @@ SetPortValue::post_process()
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/SetPortValue.hpp b/src/server/events/SetPortValue.hpp
index 69d742b8..32a8b761 100644
--- a/src/server/events/SetPortValue.hpp
+++ b/src/server/events/SetPortValue.hpp
@@ -22,7 +22,7 @@
#include "Event.hpp"
#include "types.hpp"
-#include "ingen/Atom.hpp"
+#include <ingen/Atom.hpp>
#include <cstdint>
#include <memory>
@@ -35,7 +35,6 @@ namespace server {
class Engine;
class PortImpl;
-class PreProcessContext;
class RunContext;
namespace events {
diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp
index 9d6fcfaa..db7c1c86 100644
--- a/src/server/events/Undo.cpp
+++ b/src/server/events/Undo.cpp
@@ -19,18 +19,16 @@
#include "Engine.hpp"
#include "EventWriter.hpp"
-#include "ingen/AtomReader.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Message.hpp"
-#include "ingen/Status.hpp"
-#include "lv2/atom/atom.h"
+#include <ingen/AtomReader.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Status.hpp>
+#include <lv2/atom/atom.h>
#include <deque>
#include <memory>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Undo::Undo(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -89,6 +87,4 @@ Undo::post_process()
respond();
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Undo.hpp b/src/server/events/Undo.hpp
index eb9cb70a..818dc754 100644
--- a/src/server/events/Undo.hpp
+++ b/src/server/events/Undo.hpp
@@ -32,8 +32,6 @@ struct Undo;
namespace server {
class Engine;
-class PreProcessContext;
-class RunContext;
namespace events {
diff --git a/src/server/ingen_engine.cpp b/src/server/ingen_engine.cpp
index fd4a8ced..48955143 100644
--- a/src/server/ingen_engine.cpp
+++ b/src/server/ingen_engine.cpp
@@ -14,13 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-// IWYU pragma: no_include "ingen/Atom.hpp"
-
#include "Engine.hpp"
#include "util.hpp"
-#include "ingen/Module.hpp"
-#include "ingen/World.hpp"
+#include <ingen/Module.hpp>
+#include <ingen/World.hpp>
#include <memory>
diff --git a/src/server/ingen_jack.cpp b/src/server/ingen_jack.cpp
index 0d3263be..16369d0c 100644
--- a/src/server/ingen_jack.cpp
+++ b/src/server/ingen_jack.cpp
@@ -17,17 +17,16 @@
#include "Engine.hpp"
#include "JackDriver.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Module.hpp"
-#include "ingen/World.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Module.hpp>
+#include <ingen/World.hpp>
#include <memory>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Driver;
@@ -53,8 +52,7 @@ struct JackModule : public Module {
}
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
extern "C" {
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 851a83fb..658f759b 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -15,7 +15,6 @@
*/
#include "Buffer.hpp"
-#include "BufferRef.hpp"
#include "Driver.hpp"
#include "DuplexPort.hpp"
#include "Engine.hpp"
@@ -26,46 +25,47 @@
#include "ThreadManager.hpp"
#include "types.hpp"
-#include "ingen/AtomReader.hpp"
-#include "ingen/AtomSink.hpp"
-#include "ingen/AtomWriter.hpp"
-#include "ingen/Configuration.hpp"
-#include "ingen/EngineBase.hpp"
-#include "ingen/FilePath.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Parser.hpp"
-#include "ingen/Serialiser.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/ingen.h"
-#include "ingen/memory.hpp"
-#include "ingen/runtime_paths.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/buf-size/buf-size.h"
-#include "lv2/core/lv2.h"
-#include "lv2/log/log.h"
-#include "lv2/log/logger.h"
-#include "lv2/options/options.h"
-#include "lv2/state/state.h"
-#include "lv2/urid/urid.h"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-#include "raul/RingBuffer.hpp"
-#include "raul/Semaphore.hpp"
-#include "raul/Symbol.hpp"
-#include "serd/serd.h"
-#include "sord/sordmm.hpp"
+#include <ingen/AtomReader.hpp>
+#include <ingen/AtomSink.hpp>
+#include <ingen/AtomWriter.hpp>
+#include <ingen/Configuration.hpp>
+#include <ingen/EngineBase.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Parser.hpp>
+#include <ingen/Serialiser.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/ingen.h>
+#include <ingen/memory.hpp>
+#include <ingen/runtime_paths.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/buf-size/buf-size.h>
+#include <lv2/core/lv2.h>
+#include <lv2/log/log.h>
+#include <lv2/log/logger.h>
+#include <lv2/options/options.h>
+#include <lv2/state/state.h>
+#include <lv2/urid/urid.h>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
+#include <raul/RingBuffer.hpp>
+#include <raul/Semaphore.hpp>
+#include <raul/Symbol.hpp>
+#include <serd/serd.h>
+#include <sord/sordmm.hpp>
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <cstring>
+#include <iterator>
#include <memory>
#include <mutex>
#include <set>
@@ -74,11 +74,9 @@
#include <utility>
#include <vector>
-namespace ingen {
+// #define CLEAR_GRAPH_ON_RESTORE 1
-class Atom;
-
-namespace server {
+namespace ingen::server {
class GraphImpl;
@@ -100,19 +98,23 @@ public:
Graphs graphs;
};
+namespace {
+
inline size_t
ui_ring_size(SampleCount block_length)
{
- return std::max(static_cast<size_t>(8192u),
- static_cast<size_t>(block_length) * 16u);
+ return std::max(static_cast<size_t>(8192U),
+ static_cast<size_t>(block_length) * 16U);
}
+} // namespace
+
class LV2Driver : public Driver, public ingen::AtomSink
{
public:
LV2Driver(Engine& engine,
SampleCount block_length,
- size_t seq_size,
+ uint32_t seq_size,
SampleCount sample_rate)
: _engine(engine)
, _main_sem(0)
@@ -215,13 +217,12 @@ public:
virtual GraphImpl* root_graph() { return _root_graph; }
EnginePort* get_port(const raul::Path& path) override {
- for (auto& p : _ports) {
- if (p->graph_port()->path() == path) {
- return p;
- }
- }
+ const auto i =
+ std::find_if(_ports.begin(), _ports.end(), [&path](const auto& p) {
+ return p->graph_port()->path() == path;
+ });
- return nullptr;
+ return i == _ports.end() ? nullptr : *i;
}
/** Add a port. Called only during init or restore. */
@@ -317,7 +318,13 @@ public:
break;
}
- buf = realloc(buf, sizeof(LV2_Atom) + atom.size);
+ void* const new_buf = realloc(buf, sizeof(LV2_Atom) + atom.size);
+ if (!new_buf) {
+ _engine.log().rt_error("Failed to allocate for from-UI ring\n");
+ break;
+ }
+
+ buf = new_buf;
memcpy(buf, &atom, sizeof(LV2_Atom));
if (!_from_ui.read(atom.size,
@@ -387,7 +394,7 @@ public:
}
SampleCount block_length() const override { return _block_length; }
- size_t seq_size() const override { return _seq_size; }
+ uint32_t seq_size() const override { return _seq_size; }
SampleCount sample_rate() const override { return _sample_rate; }
SampleCount frame_time() const override { return _frame_time; }
@@ -411,7 +418,7 @@ private:
GraphImpl* _root_graph{nullptr};
uint32_t _notify_capacity{0};
SampleCount _block_length;
- size_t _seq_size;
+ uint32_t _seq_size;
SampleCount _sample_rate;
SampleCount _frame_time{0};
raul::Semaphore _to_ui_overflow_sem{0};
@@ -460,9 +467,10 @@ find_graphs(const URI& manifest_uri)
URI(INGEN__Graph));
Lib::Graphs graphs;
- for (const auto& r : resources) {
- graphs.push_back(std::make_shared<LV2Graph>(r));
- }
+ std::transform(resources.begin(),
+ resources.end(),
+ std::back_inserter(graphs),
+ [](const auto& r) { return std::make_shared<LV2Graph>(r); });
return graphs;
}
@@ -512,16 +520,16 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
nullptr,
true);
- Lib::Graphs graphs = find_graphs(URI(reinterpret_cast<const char*>(manifest_node.buf)));
+ const Lib::Graphs graphs = find_graphs(URI(reinterpret_cast<const char*>(manifest_node.buf)));
serd_node_free(&manifest_node);
- const LV2Graph* graph = nullptr;
- for (const auto& g : graphs) {
- if (g->uri == descriptor->URI) {
- graph = g.get();
- break;
- }
- }
+ const auto g = std::find_if(graphs.begin(),
+ graphs.end(),
+ [&descriptor](const auto& graph) {
+ return graph->uri == descriptor->URI;
+ });
+
+ const LV2Graph* const graph = g == graphs.end() ? nullptr : g->get();
if (!graph) {
lv2_log_error(&logger, "could not find graph <%s>\n", descriptor->URI);
@@ -533,11 +541,11 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
plugin->world = std::make_unique<ingen::World>(map, unmap, log);
plugin->world->load_configuration(plugin->argc, plugin->argv);
- LV2_URID bufsz_max = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength);
- LV2_URID bufsz_seq = map->map(map->handle, LV2_BUF_SIZE__sequenceSize);
- LV2_URID atom_Int = map->map(map->handle, LV2_ATOM__Int);
- int32_t block_length = 0;
- int32_t seq_size = 0;
+ const LV2_URID bufsz_max = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength);
+ const LV2_URID bufsz_seq = map->map(map->handle, LV2_BUF_SIZE__sequenceSize);
+ const LV2_URID atom_Int = map->map(map->handle, LV2_ATOM__Int);
+ int32_t block_length = 0;
+ int32_t seq_size = 0;
if (options) {
for (const LV2_Options_Option* o = options; o->key; ++o) {
if (o->key == bufsz_max && o->type == atom_Int) {
@@ -551,7 +559,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
block_length = 4096;
plugin->world->log().warn("No maximum block length given\n");
}
- if (seq_size == 0) {
+ if (seq_size < 1) {
seq_size = 16384;
plugin->world->log().warn("No maximum sequence size given\n");
}
@@ -567,20 +575,21 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
plugin->engine = engine;
plugin->world->set_engine(engine);
- std::shared_ptr<Interface> interface = engine->interface();
+ const std::shared_ptr<Interface> interface = engine->interface();
plugin->world->set_interface(interface);
ThreadManager::set_flag(THREAD_PRE_PROCESS);
ThreadManager::single_threaded = true;
- auto* driver = new LV2Driver(*engine, block_length, seq_size, rate);
+ auto* driver = new LV2Driver(
+ *engine, block_length, static_cast<uint32_t>(seq_size), rate);
engine->set_driver(std::shared_ptr<Driver>(driver));
engine->activate();
ThreadManager::single_threaded = true;
- std::lock_guard<std::mutex> lock(plugin->world->rdf_mutex());
+ const std::lock_guard<std::mutex> lock{plugin->world->rdf_mutex()};
// Locate to time 0 to process initialization events
engine->locate(0, block_length);
@@ -602,7 +611,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
/* Register client after loading graph so the to-ui ring does not overflow.
Since we are not yet rolling, it won't be drained, causing a deadlock. */
- std::shared_ptr<Interface> client(&driver->writer(), NullDeleter<Interface>);
+ const std::shared_ptr<Interface> client{&driver->writer(), NullDeleter<Interface>};
interface->set_respondee(client);
engine->register_client(client);
@@ -613,8 +622,8 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
static void
ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- auto* me = static_cast<IngenPlugin*>(instance);
- Engine* engine = static_cast<Engine*>(me->world->engine().get());
+ auto* me = static_cast<IngenPlugin*>(instance);
+ const Engine* engine = static_cast<Engine*>(me->world->engine().get());
const auto driver = std::static_pointer_cast<LV2Driver>(engine->driver());
if (port < driver->ports().size()) {
driver->ports().at(port)->set_buffer(data);
@@ -670,6 +679,7 @@ ingen_cleanup(LV2_Handle instance)
auto world = std::move(me->world);
delete me;
+ world.reset();
}
static void
@@ -703,9 +713,9 @@ ingen_save(LV2_Handle instance,
return LV2_STATE_ERR_NO_FEATURE;
}
- LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
- LV2_URID atom_Path = plugin->map->map(plugin->map->handle,
- LV2_ATOM__Path);
+ const LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
+ const LV2_URID atom_Path = plugin->map->map(plugin->map->handle,
+ LV2_ATOM__Path);
char* real_path = make_path->path(make_path->handle, "main.ttl");
char* state_path = map_path->abstract_path(map_path->handle, real_path);
@@ -713,7 +723,7 @@ ingen_save(LV2_Handle instance,
auto root = plugin->world->store()->find(raul::Path("/"));
{
- std::lock_guard<std::mutex> lock(plugin->world->rdf_mutex());
+ const std::lock_guard<std::mutex> lock{plugin->world->rdf_mutex()};
plugin->world->serialiser()->start_to_file(
root->second->path(), FilePath{real_path});
@@ -749,10 +759,10 @@ ingen_restore(LV2_Handle instance,
return LV2_STATE_ERR_NO_FEATURE;
}
- LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
- size_t size = 0;
- uint32_t type = 0;
- uint32_t valflags = 0;
+ const LV2_URID ingen_file = plugin->map->map(plugin->map->handle, INGEN__file);
+ size_t size = 0;
+ uint32_t type = 0;
+ uint32_t valflags = 0;
// Get abstract path to graph file
const char* path = static_cast<const char*>(
@@ -767,7 +777,7 @@ ingen_restore(LV2_Handle instance,
return LV2_STATE_ERR_UNKNOWN;
}
-#if 0
+#ifdef CLEAR_GRAPH_ON_RESTORE
// Remove existing root graph contents
std::shared_ptr<Engine> engine = plugin->engine;
for (const auto& b : engine->root_graph()->blocks()) {
@@ -784,7 +794,7 @@ ingen_restore(LV2_Handle instance,
#endif
// Load new graph
- std::lock_guard<std::mutex> lock(plugin->world->rdf_mutex());
+ const std::lock_guard<std::mutex> lock{plugin->world->rdf_mutex()};
plugin->world->parser()->parse_file(
*plugin->world, *plugin->world->interface(), real_path);
@@ -847,8 +857,8 @@ lib_get_plugin(LV2_Lib_Handle handle, uint32_t index)
}
} // extern "C"
-} // namespace server
-} // namespace ingen
+
+} // namespace ingen::server
extern "C" {
diff --git a/src/server/ingen_portaudio.cpp b/src/server/ingen_portaudio.cpp
index 86fc76d9..68b1b0bc 100644
--- a/src/server/ingen_portaudio.cpp
+++ b/src/server/ingen_portaudio.cpp
@@ -14,19 +14,16 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-// IWYU pragma: no_include "ingen/FilePath.hpp"
-
#include "Engine.hpp"
#include "PortAudioDriver.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Module.hpp"
-#include "ingen/World.hpp"
+#include <ingen/Log.hpp>
+#include <ingen/Module.hpp>
+#include <ingen/World.hpp>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Driver;
@@ -46,8 +43,7 @@ struct PortAudioModule : public Module {
}
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
extern "C" {
diff --git a/src/server/internals/BlockDelay.cpp b/src/server/internals/BlockDelay.cpp
index 68252fe4..acc68851 100644
--- a/src/server/internals/BlockDelay.cpp
+++ b/src/server/internals/BlockDelay.cpp
@@ -14,7 +14,7 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "internals/BlockDelay.hpp"
+#include "BlockDelay.hpp"
#include "BlockImpl.hpp"
#include "Buffer.hpp"
@@ -24,21 +24,16 @@
#include "OutputPort.hpp"
#include "PortType.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Symbol.hpp>
#include <memory>
-namespace ingen {
-namespace server {
-
-class RunContext;
-
-namespace internals {
+namespace ingen::server::internals {
InternalPlugin* BlockDelayNode::internal_plugin(URIs& uris) {
return new InternalPlugin(
@@ -91,6 +86,4 @@ BlockDelayNode::run(RunContext& ctx)
_buffer->copy(ctx, _in_port->buffer(0).get());
}
-} // namespace internals
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::internals
diff --git a/src/server/internals/BlockDelay.hpp b/src/server/internals/BlockDelay.hpp
index 78a03c28..a9667fa0 100644
--- a/src/server/internals/BlockDelay.hpp
+++ b/src/server/internals/BlockDelay.hpp
@@ -36,7 +36,6 @@ class GraphImpl;
class InputPort;
class InternalPlugin;
class OutputPort;
-class RunContext;
namespace internals {
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp
index ccc6df01..9103649e 100644
--- a/src/server/internals/Controller.cpp
+++ b/src/server/internals/Controller.cpp
@@ -14,7 +14,8 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "BlockImpl.hpp"
+#include "Controller.hpp"
+
#include "Buffer.hpp"
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
@@ -24,25 +25,23 @@
#include "PortType.hpp"
#include "RunContext.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "internals/Controller.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/midi/midi.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/midi/midi.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <cmath>
#include <initializer_list>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class GraphImpl;
@@ -173,7 +172,7 @@ ControllerNode::control(RunContext& ctx, uint8_t control_num, uint8_t val, Frame
}
const Sample min = logf(min_port_val + 1 + log_offset);
const Sample max = logf(max_port_val + 1 + log_offset);
- scaled_value = expf(nval * (max - min) + min) - 1 - log_offset;
+ scaled_value = expf((nval * (max - min)) + min) - 1 - log_offset;
} else {
scaled_value = ((nval) * (max_port_val - min_port_val)) + min_port_val;
}
@@ -184,5 +183,4 @@ ControllerNode::control(RunContext& ctx, uint8_t control_num, uint8_t val, Frame
}
} // namespace internals
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index 976e43f9..960bca85 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -14,28 +14,27 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "internals/Note.hpp"
+#include "Note.hpp"
#include "BlockImpl.hpp"
#include "Buffer.hpp"
#include "BufferFactory.hpp"
-#include "BufferRef.hpp"
#include "InputPort.hpp"
#include "InternalPlugin.hpp"
#include "OutputPort.hpp"
#include "PortType.hpp"
#include "RunContext.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/midi/midi.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/midi/midi.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <cmath>
@@ -44,8 +43,7 @@
// #define NOTE_DEBUG 1
-namespace ingen {
-namespace server {
+namespace ingen::server {
class GraphImpl;
@@ -436,5 +434,4 @@ NoteNode::channel_pressure(RunContext& ctx, FrameTime time, float amount)
}
} // namespace internals
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/internals/Note.hpp b/src/server/internals/Note.hpp
index 3aa3217e..2cf6c1e2 100644
--- a/src/server/internals/Note.hpp
+++ b/src/server/internals/Note.hpp
@@ -20,8 +20,8 @@
#include "InternalBlock.hpp"
#include "types.hpp"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
#include <cstdint>
diff --git a/src/server/internals/Time.cpp b/src/server/internals/Time.cpp
index 651a2f36..2ea09b0b 100644
--- a/src/server/internals/Time.cpp
+++ b/src/server/internals/Time.cpp
@@ -14,9 +14,8 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "internals/Time.hpp"
+#include "Time.hpp"
-#include "BlockImpl.hpp"
#include "Buffer.hpp"
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
@@ -27,19 +26,18 @@
#include "PortType.hpp"
#include "RunContext.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/atom/atom.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/atom/atom.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Symbol.hpp>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class GraphImpl;
@@ -73,8 +71,8 @@ TimeNode::TimeNode(InternalPlugin* plugin,
void
TimeNode::run(RunContext& ctx)
{
- BufferRef buf = _notify_port->buffer(0);
- auto* seq = buf->get<LV2_Atom_Sequence>();
+ const BufferRef buf = _notify_port->buffer(0);
+ auto* const seq = buf->get<LV2_Atom_Sequence>();
// Initialise output to the empty sequence
seq->atom.type = _notify_port->bufs().uris().atom_Sequence;
@@ -87,5 +85,4 @@ TimeNode::run(RunContext& ctx)
}
} // namespace internals
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/internals/Time.hpp b/src/server/internals/Time.hpp
index fa3e90e5..228e67a8 100644
--- a/src/server/internals/Time.hpp
+++ b/src/server/internals/Time.hpp
@@ -34,7 +34,6 @@ class BufferFactory;
class GraphImpl;
class InternalPlugin;
class OutputPort;
-class RunContext;
namespace internals {
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 89a970fc..f033a345 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -14,9 +14,8 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "internals/Trigger.hpp"
+#include "Trigger.hpp"
-#include "BlockImpl.hpp"
#include "Buffer.hpp"
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
@@ -26,23 +25,22 @@
#include "PortType.hpp"
#include "RunContext.hpp"
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/midi/midi.h"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Symbol.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/midi/midi.h>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
#include <cmath>
#include <memory>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class GraphImpl;
@@ -198,5 +196,4 @@ TriggerNode::note_off(RunContext& ctx, uint8_t note_num, FrameTime time)
}
} // namespace internals
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/meson.build b/src/server/meson.build
index c2e5b761..c1fccf5e 100644
--- a/src/server/meson.build
+++ b/src/server/meson.build
@@ -6,6 +6,25 @@
##########
server_sources = files(
+ 'events/Connect.cpp',
+ 'events/Copy.cpp',
+ 'events/CreateBlock.cpp',
+ 'events/CreateGraph.cpp',
+ 'events/CreatePort.cpp',
+ 'events/Delete.cpp',
+ 'events/Delta.cpp',
+ 'events/Disconnect.cpp',
+ 'events/DisconnectAll.cpp',
+ 'events/Get.cpp',
+ 'events/Mark.cpp',
+ 'events/Move.cpp',
+ 'events/SetPortValue.cpp',
+ 'events/Undo.cpp',
+ 'internals/BlockDelay.cpp',
+ 'internals/Controller.cpp',
+ 'internals/Note.cpp',
+ 'internals/Time.cpp',
+ 'internals/Trigger.cpp',
'ArcImpl.cpp',
'BlockFactory.cpp',
'BlockImpl.cpp',
@@ -33,26 +52,7 @@ server_sources = files(
'Task.cpp',
'UndoStack.cpp',
'Worker.cpp',
- 'events/Connect.cpp',
- 'events/Copy.cpp',
- 'events/CreateBlock.cpp',
- 'events/CreateGraph.cpp',
- 'events/CreatePort.cpp',
- 'events/Delete.cpp',
- 'events/Delta.cpp',
- 'events/Disconnect.cpp',
- 'events/DisconnectAll.cpp',
- 'events/Get.cpp',
- 'events/Mark.cpp',
- 'events/Move.cpp',
- 'events/SetPortValue.cpp',
- 'events/Undo.cpp',
'ingen_engine.cpp',
- 'internals/BlockDelay.cpp',
- 'internals/Controller.cpp',
- 'internals/Note.cpp',
- 'internals/Time.cpp',
- 'internals/Trigger.cpp',
'mix.cpp',
)
diff --git a/src/server/mix.cpp b/src/server/mix.cpp
index 9c578d11..32500f97 100644
--- a/src/server/mix.cpp
+++ b/src/server/mix.cpp
@@ -20,11 +20,10 @@
#include "RunContext.hpp"
#include "types.hpp"
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
-namespace ingen {
-namespace server {
+namespace ingen::server {
static inline bool
is_end(const Buffer* buf, const LV2_Atom_Event* ev)
@@ -111,5 +110,4 @@ mix(const RunContext& ctx,
}
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/mix.hpp b/src/server/mix.hpp
index 75e139d3..11a9a1d2 100644
--- a/src/server/mix.hpp
+++ b/src/server/mix.hpp
@@ -19,8 +19,7 @@
#include <cstdint>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Buffer;
class RunContext;
@@ -31,7 +30,6 @@ mix(const RunContext& ctx,
const Buffer*const* srcs,
uint32_t num_srcs);
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_MIX_HPP
diff --git a/src/server/util.hpp b/src/server/util.hpp
index 3c8d2058..abfa06b6 100644
--- a/src/server/util.hpp
+++ b/src/server/util.hpp
@@ -17,10 +17,10 @@
#ifndef INGEN_ENGINE_UTIL_HPP
#define INGEN_ENGINE_UTIL_HPP
-#include "ingen/Log.hpp"
+#include <ingen/Log.hpp>
#ifdef __SSE__
-#include <xmmintrin.h> // IWYU pragma: keep
+#include <xmmintrin.h>
#endif
#ifdef __clang__
@@ -29,8 +29,7 @@
# define REALTIME
#endif
-namespace ingen {
-namespace server {
+namespace ingen::server {
/** Set flags to disable denormal processing.
*/
@@ -43,7 +42,6 @@ set_denormal_flags(ingen::Log& log)
#endif
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_UTIL_HPP