summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-26 14:58:59 +0200
committerDavid Robillard <d@drobilla.net>2017-03-26 17:02:09 +0200
commit6268bb2accfdc0dcad6cb8b54ba56ec64609d474 (patch)
treebac1e45ab9e31c8cb1e3949b35e13ba03effd8f4 /src
parent470936f0bf3535c688df5551025265916a5dee06 (diff)
downloadingen-6268bb2accfdc0dcad6cb8b54ba56ec64609d474.tar.gz
ingen-6268bb2accfdc0dcad6cb8b54ba56ec64609d474.tar.bz2
ingen-6268bb2accfdc0dcad6cb8b54ba56ec64609d474.zip
Remove NodeImpl class
Diffstat (limited to 'src')
-rw-r--r--src/server/BlockImpl.cpp5
-rw-r--r--src/server/BlockImpl.hpp19
-rw-r--r--src/server/DuplexPort.hpp3
-rw-r--r--src/server/Engine.cpp5
-rw-r--r--src/server/GraphImpl.hpp2
-rw-r--r--src/server/NodeImpl.cpp52
-rw-r--r--src/server/NodeImpl.hpp100
-rw-r--r--src/server/PortImpl.cpp7
-rw-r--r--src/server/PortImpl.hpp17
-rw-r--r--src/server/events/Delta.cpp43
-rw-r--r--src/server/events/DisconnectAll.cpp23
-rw-r--r--src/server/wscript1
12 files changed, 76 insertions, 201 deletions
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index d0f0d646..ceae2df2 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -38,7 +38,10 @@ BlockImpl::BlockImpl(PluginImpl* plugin,
bool polyphonic,
GraphImpl* parent,
SampleRate srate)
- : NodeImpl(plugin->uris(), parent, symbol)
+ : Node(plugin->uris(), parent ? parent->path().child(symbol) : Raul::Path("/"))
+ , _parent(parent)
+ , _path(parent ? parent->path().child(symbol) : Raul::Path("/"))
+ , _symbol(symbol)
, _plugin(plugin)
, _polyphony((polyphonic && parent) ? parent->internal_poly() : 1)
, _mark(Mark::UNVISITED)
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index fc789813..1a794e2d 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -22,12 +22,11 @@
#include <boost/intrusive/slist.hpp>
#include <boost/optional.hpp>
+#include "ingen/Node.hpp"
#include "lilv/lilv.h"
-
#include "raul/Array.hpp"
#include "BufferRef.hpp"
-#include "NodeImpl.hpp"
#include "PluginImpl.hpp"
#include "PortType.hpp"
#include "RunContext.hpp"
@@ -56,7 +55,7 @@ class Worker;
*
* \ingroup engine
*/
-class BlockImpl : public NodeImpl
+class BlockImpl : public Node
, public boost::intrusive::slist_base_hook<> // In GraphImpl
{
public:
@@ -72,6 +71,17 @@ public:
virtual GraphType graph_type() const { return GraphType::BLOCK; }
+ BlockImpl* parent() const { return _parent; }
+ GraphImpl* graph_parent() const { return (GraphImpl*)_parent; }
+ const Raul::Path& path() const { return _path; }
+ const Raul::Symbol& symbol() const { return _symbol; }
+
+ void set_uri(const Raul::URI& uri) override {
+ _path = uri_to_path(uri);
+ _symbol = Raul::Symbol(_path.is_root() ? "main" : _path.symbol());
+ Node::set_uri(uri);
+ }
+
/** Return true iff this is main (the top level graph).
*
* This is sometimes called "the root graph", but the term "main" is used
@@ -200,6 +210,9 @@ public:
protected:
PortImpl* nth_port_by_type(uint32_t n, bool input, PortType type);
+ BlockImpl* _parent;
+ Raul::Path _path;
+ Raul::Symbol _symbol;
PluginImpl* _plugin;
MPtr<Ports> _ports; ///< Access in audio thread only
uint32_t _polyphony;
diff --git a/src/server/DuplexPort.hpp b/src/server/DuplexPort.hpp
index e12841dd..af32d1e8 100644
--- a/src/server/DuplexPort.hpp
+++ b/src/server/DuplexPort.hpp
@@ -26,6 +26,7 @@ namespace Ingen {
namespace Server {
class BlockImpl;
+class GraphImpl;
/** A duplex Port (both an input and output port on a Graph)
*
@@ -53,6 +54,8 @@ public:
virtual ~DuplexPort();
+ GraphImpl* parent_graph() const { return (GraphImpl*)_parent; }
+
DuplexPort* duplicate(Engine& engine,
const Raul::Symbol& symbol,
GraphImpl* parent);
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index e2fb08af..35b71a39 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -167,11 +167,6 @@ Engine::~Engine()
const SPtr<Store> store = this->store();
if (store) {
- for (auto& s : *store.get()) {
- if (!dynamic_ptr_cast<NodeImpl>(s.second)->parent()) {
- s.second.reset();
- }
- }
store->clear();
}
diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp
index 6064624a..8c6e3711 100644
--- a/src/server/GraphImpl.hpp
+++ b/src/server/GraphImpl.hpp
@@ -59,7 +59,7 @@ public:
virtual ~GraphImpl();
- virtual GraphType graph_type() const { return GraphType::GRAPH; }
+ virtual Node::GraphType graph_type() const { return Node::GraphType::GRAPH; }
BlockImpl* duplicate(Engine& engine,
const Raul::Symbol& symbol,
diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp
deleted file mode 100644
index 8f47fd83..00000000
--- a/src/server/NodeImpl.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2015 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 "GraphImpl.hpp"
-#include "NodeImpl.hpp"
-#include "ThreadManager.hpp"
-
-using namespace std;
-
-namespace Ingen {
-namespace Server {
-
-NodeImpl::NodeImpl(const Ingen::URIs& uris,
- BlockImpl* parent,
- const Raul::Symbol& symbol)
- : Node(uris, parent ? parent->path().child(symbol) : Raul::Path("/"))
- , _parent(parent)
- , _path(parent ? parent->path().child(symbol) : Raul::Path("/"))
- , _symbol(symbol)
-{
-}
-
-const Atom&
-NodeImpl::get_property(const Raul::URI& key) const
-{
- ThreadManager::assert_not_thread(THREAD_PROCESS);
- static const Atom null_atom;
- Properties::const_iterator i = properties().find(key);
- return (i != properties().end()) ? i->second : null_atom;
-}
-
-GraphImpl*
-NodeImpl::parent_graph() const
-{
- return dynamic_cast<GraphImpl*>((BlockImpl*)_parent);
-}
-
-} // namespace Server
-} // namespace Ingen
diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp
deleted file mode 100644
index f4de621e..00000000
--- a/src/server/NodeImpl.hpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2015 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/>.
-*/
-
-#ifndef INGEN_ENGINE_NODEIMPL_HPP
-#define INGEN_ENGINE_NODEIMPL_HPP
-
-#include <cassert>
-#include <cstddef>
-#include <map>
-
-#include "ingen/Node.hpp"
-#include "ingen/Resource.hpp"
-#include "raul/Deletable.hpp"
-#include "raul/Path.hpp"
-
-namespace Raul { class Maid; }
-
-namespace Ingen {
-
-namespace Shared { class URIs; }
-
-namespace Server {
-
-class BlockImpl;
-class BufferFactory;
-class GraphImpl;
-class RunContext;
-
-/** An object on the audio graph (a Graph, Block, or Port).
- *
- * Each of these is a Raul::Deletable and so can be deleted in a realtime safe
- * way from anywhere, and they all have a map of variable for clients to store
- * arbitrary values in (which the engine puts no significance to whatsoever).
- *
- * \ingroup engine
- */
-class NodeImpl : public Node
-{
-public:
- virtual ~NodeImpl() {}
-
- const Raul::Symbol& symbol() const { return _symbol; }
- const BlockImpl* parent() const { return _parent; }
- BlockImpl* parent() { return _parent; }
-
- /** Rename */
- void set_uri(const Raul::URI& uri) override {
- _path = uri_to_path(uri);
- _symbol = Raul::Symbol(_path.is_root() ? "main" : _path.symbol());
- Node::set_uri(uri);
- }
-
- const Atom& get_property(const Raul::URI& key) const;
-
- /** The Graph this object is a child of. */
- virtual GraphImpl* parent_graph() const;
-
- const Raul::Path& path() const { return _path; }
-
- /** Prepare for a new (external) polyphony value.
- *
- * Preprocessor thread, poly is actually applied by apply_poly.
- * \return true on success.
- */
- virtual bool prepare_poly(BufferFactory& bufs, uint32_t poly) = 0;
-
- /** Apply a new (external) polyphony value.
- *
- * \param context Process context (process thread only).
- * \param poly Must be <= the most recent value passed to prepare_poly.
- */
- virtual bool apply_poly(RunContext& context, uint32_t poly) = 0;
-
-protected:
- NodeImpl(const Ingen::URIs& uris,
- BlockImpl* parent,
- const Raul::Symbol& symbol);
-
- BlockImpl* _parent;
- Raul::Path _path;
- Raul::Symbol _symbol;
-};
-
-} // namespace Server
-} // namespace Ingen
-
-#endif // INGEN_ENGINE_NODEIMPL_HPP
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 434c6ee0..7b84be17 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -44,7 +44,7 @@ monitor_period(const Engine& engine)
PortImpl::PortImpl(BufferFactory& bufs,
BlockImpl* const block,
- const Raul::Symbol& name,
+ const Raul::Symbol& symbol,
uint32_t index,
uint32_t poly,
PortType type,
@@ -52,8 +52,11 @@ PortImpl::PortImpl(BufferFactory& bufs,
const Atom& value,
size_t buffer_size,
bool is_output)
- : NodeImpl(bufs.uris(), block, name)
+ : Node(bufs.uris(), block->path().child(symbol))
, _bufs(bufs)
+ , _parent(block)
+ , _path(block->path().child(symbol))
+ , _symbol(symbol)
, _index(index)
, _poly(poly)
, _buffer_size(buffer_size)
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index cda6ab68..aac31fc8 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -20,10 +20,10 @@
#include <cstdlib>
#include "ingen/Atom.hpp"
+#include "ingen/Node.hpp"
#include "raul/Array.hpp"
#include "BufferRef.hpp"
-#include "NodeImpl.hpp"
#include "PortType.hpp"
#include "types.hpp"
@@ -44,7 +44,7 @@ class RunContext;
*
* \ingroup engine
*/
-class PortImpl : public NodeImpl
+class PortImpl : public Node
{
public:
struct SetState {
@@ -101,6 +101,16 @@ public:
virtual GraphType graph_type() const { return GraphType::PORT; }
+ BlockImpl* parent() const { return _parent; }
+ const Raul::Path& path() const { return _path; }
+ const Raul::Symbol& symbol() const { return _symbol; }
+
+ void set_uri(const Raul::URI& uri) override {
+ _path = uri_to_path(uri);
+ _symbol = Raul::Symbol(_path.is_root() ? "main" : _path.symbol());
+ Node::set_uri(uri);
+ }
+
/** Set the the voices (buffers) for this port in the audio thread. */
void set_voices(RunContext& context, MPtr<Voices>&& voices);
@@ -278,6 +288,9 @@ protected:
size_t num_in_arcs) const;
BufferFactory& _bufs;
+ BlockImpl* _parent;
+ Raul::Path _path;
+ Raul::Symbol _symbol;
uint32_t _index;
uint32_t _poly;
uint32_t _buffer_size;
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index ecc1830a..5ea00c9f 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -217,8 +217,6 @@ Delta::pre_process(PreProcessContext& ctx)
_types.reserve(_properties.size());
- NodeImpl* obj = dynamic_cast<NodeImpl*>(_object);
-
// Remove any properties removed in delta
for (const auto& r : _remove) {
const Raul::URI& key = r.first;
@@ -277,10 +275,9 @@ Delta::pre_process(PreProcessContext& ctx)
const Raul::URI& key = p.first;
const Property& value = p.second;
SpecialType op = SpecialType::NONE;
- if (obj) {
- Resource& resource = *obj;
+ if (is_graph_object) {
if (value != uris.patch_wildcard) {
- if (resource.add_property(key, value, value.context())) {
+ if (_object->add_property(key, value, value.context())) {
_added.emplace(key, value);
}
}
@@ -375,22 +372,22 @@ Delta::pre_process(PreProcessContext& ctx)
}
if (!_create_event && key == uris.ingen_polyphonic) {
- GraphImpl* parent = dynamic_cast<GraphImpl*>(obj->parent());
+ GraphImpl* parent = dynamic_cast<GraphImpl*>(
+ _engine.store()->get(uri_to_path(_subject).parent()));
if (!parent) {
_status = Status::BAD_OBJECT_TYPE;
} else if (value.type() != uris.forge.Bool) {
_status = Status::BAD_VALUE_TYPE;
} else {
- op = SpecialType::POLYPHONIC;
- obj->set_property(key, value, value.context());
- BlockImpl* block = dynamic_cast<BlockImpl*>(obj);
- if (block) {
- block->set_polyphonic(value.get<int32_t>());
- }
- if (value.get<int32_t>()) {
- obj->prepare_poly(*_engine.buffer_factory(), parent->internal_poly());
- } else {
- obj->prepare_poly(*_engine.buffer_factory(), 1);
+ op = SpecialType::POLYPHONIC;
+ _object->set_property(key, value, value.context());
+ const uint32_t poly = (
+ value.get<int32_t>() ? parent->internal_poly() : 1);
+ if (BlockImpl* block = dynamic_cast<BlockImpl*>(_object)) {
+ block->set_polyphonic(poly);
+ block->prepare_poly(*_engine.buffer_factory(), poly);
+ } else if (PortImpl* port = dynamic_cast<PortImpl*>(_object)) {
+ port->prepare_poly(*_engine.buffer_factory(), poly);
}
}
}
@@ -455,7 +452,6 @@ Delta::execute(RunContext& context)
_engine.control_bindings()->remove(context, _removed_bindings);
}
- NodeImpl* const object = dynamic_cast<NodeImpl*>(_object);
BlockImpl* const block = dynamic_cast<BlockImpl*>(_object);
PortImpl* const port = dynamic_cast<PortImpl*>(_object);
@@ -484,11 +480,14 @@ Delta::execute(RunContext& context)
}
break;
case SpecialType::POLYPHONIC: {
- GraphImpl* parent = reinterpret_cast<GraphImpl*>(object->parent());
- if (value.get<int32_t>()) {
- object->apply_poly(context, parent->internal_poly_process());
- } else {
- object->apply_poly(context, 1);
+ GraphImpl* parent = reinterpret_cast<GraphImpl*>(
+ block ? block->parent() : port->parent());
+ const uint32_t poly = (
+ value.get<int32_t>() ? parent->internal_poly_process() : 1);
+ if (block) {
+ block->apply_poly(context, poly);
+ } else if (port) {
+ port->apply_poly(context, poly);
}
} break;
case SpecialType::POLYPHONY:
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 45fec243..4d5a0958 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -88,23 +88,22 @@ DisconnectAll::pre_process(PreProcessContext& ctx)
_parent_path);
}
- NodeImpl* const object = dynamic_cast<NodeImpl*>(
- _engine.store()->get(_path));
- if (!object) {
+ Node* const node = _engine.store()->get(_path);
+ if (!node) {
return Event::pre_process_done(Status::NOT_FOUND, _path);
}
- if (object->parent_graph() != _parent
- && object->parent()->parent_graph() != _parent) {
- return Event::pre_process_done(Status::INVALID_PARENT, _parent_path);
+ BlockImpl* parent = nullptr;
+ if ((_block = dynamic_cast<BlockImpl*>(node))) {
+ parent = _block->parent();
+ } else if ((_port = dynamic_cast<PortImpl*>(node))) {
+ parent = _port->parent();
+ } else {
+ return Event::pre_process_done(Status::INTERNAL_ERROR, _path);
}
- // Only one of these will succeed
- _block = dynamic_cast<BlockImpl*>(object);
- _port = dynamic_cast<PortImpl*>(object);
-
- if (!_block && !_port) {
- return Event::pre_process_done(Status::INTERNAL_ERROR, _path);
+ if (parent != _parent && parent->parent() != _parent) {
+ return Event::pre_process_done(Status::INVALID_PARENT, _parent_path);
}
}
diff --git a/src/server/wscript b/src/server/wscript
index a8efd2f8..cc6441fc 100644
--- a/src/server/wscript
+++ b/src/server/wscript
@@ -21,7 +21,6 @@ def build(bld):
InternalPlugin.cpp
LV2Block.cpp
LV2Plugin.cpp
- NodeImpl.cpp
PortImpl.cpp
PostProcessor.cpp
PreProcessor.cpp