From ba1f169967f64b9657074fba2de803b29829345c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 19 Aug 2012 02:57:26 +0000 Subject: GraphObject => Node git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4722 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/Builder.hpp | 6 +-- ingen/GraphObject.hpp | 96 ---------------------------------- ingen/LV2Features.hpp | 10 ++-- ingen/Node.hpp | 104 +++++++++++++++++++++++++++++++++++++ ingen/Store.hpp | 12 ++--- ingen/URIMap.hpp | 2 +- ingen/client/BlockModel.hpp | 8 +-- ingen/client/ClientStore.hpp | 2 +- ingen/client/GraphModel.hpp | 10 ++-- ingen/client/ObjectModel.hpp | 8 +-- ingen/client/PortModel.hpp | 2 +- ingen/serialisation/Parser.hpp | 4 +- ingen/serialisation/Serialiser.hpp | 20 +++---- 13 files changed, 146 insertions(+), 138 deletions(-) delete mode 100644 ingen/GraphObject.hpp create mode 100644 ingen/Node.hpp (limited to 'ingen') diff --git a/ingen/Builder.hpp b/ingen/Builder.hpp index 168ab841..96096b3d 100644 --- a/ingen/Builder.hpp +++ b/ingen/Builder.hpp @@ -21,8 +21,8 @@ namespace Ingen { -class GraphObject; class Interface; +class Node; class URIs; /** Wrapper for Interface to create existing objects/models. @@ -35,8 +35,8 @@ public: Builder(URIs& uris, Interface& interface); virtual ~Builder() {} - void build(SharedPtr object); - void connect(SharedPtr object); + void build(SharedPtr object); + void connect(SharedPtr object); private: URIs& _uris; diff --git a/ingen/GraphObject.hpp b/ingen/GraphObject.hpp deleted file mode 100644 index cca3af45..00000000 --- a/ingen/GraphObject.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - 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 . -*/ - -#ifndef INGEN_GRAPHOBJECT_HPP -#define INGEN_GRAPHOBJECT_HPP - -#include "raul/Path.hpp" -#include "raul/SharedPtr.hpp" -#include "ingen/Resource.hpp" - -namespace Raul { -class Atom; -class Path; -class Symbol; -} - -namespace Ingen { - -class Edge; -class Plugin; -class Store; - -/** An object on the audio graph - Graph, Block, Port, etc. - * - * @ingroup Ingen - */ -class GraphObject : public Resource -{ -public: - enum GraphType { - GRAPH, - BLOCK, - PORT - }; - - typedef std::pair EdgesKey; - typedef std::map< EdgesKey, SharedPtr > Edges; - - // Graphs only - Edges& edges() { return _edges; } - const Edges& edges() const { return _edges; } - - // Blocks and graphs only - virtual uint32_t num_ports() const { return 0; } - virtual GraphObject* port(uint32_t index) const { return NULL; } - virtual const Plugin* plugin() const { return NULL; } - - // All objects - virtual GraphType graph_type() const = 0; - virtual const Raul::Path& path() const = 0; - virtual const Raul::Symbol& symbol() const = 0; - virtual GraphObject* graph_parent() const = 0; - - static Raul::URI root_uri() { return Raul::URI("ingen:root"); } - - static bool uri_is_path(const Raul::URI& uri) { - return uri.substr(0, root_uri().length()) == root_uri(); - } - - static Raul::Path uri_to_path(const Raul::URI& uri) { - return (uri == root_uri()) - ? Raul::Path("/") - : Raul::Path(uri.substr(root_uri().length())); - } - - static Raul::URI path_to_uri(const Raul::Path& path) { - return Raul::URI(root_uri() + path.c_str()); - } - -protected: - friend class Store; - virtual void set_path(const Raul::Path& p) = 0; - - GraphObject(URIs& uris, const Raul::Path& path) - : Resource(uris, path_to_uri(path)) - {} - - Edges _edges; ///< Graphs only -}; - -} // namespace Ingen - -#endif // INGEN_GRAPHOBJECT_HPP diff --git a/ingen/LV2Features.hpp b/ingen/LV2Features.hpp index 34c43a79..80339c84 100644 --- a/ingen/LV2Features.hpp +++ b/ingen/LV2Features.hpp @@ -26,7 +26,7 @@ namespace Ingen { -class GraphObject; +class Node; class World; /** Features for use by LV2 plugins. @@ -40,8 +40,8 @@ public: public: virtual ~Feature() {} - virtual SharedPtr feature(World* world, - GraphObject* block) = 0; + virtual SharedPtr feature(World* world, + Node* block) = 0; }; class FeatureArray : public Raul::Noncopyable { @@ -61,8 +61,8 @@ public: void add_feature(SharedPtr feature); - SharedPtr lv2_features(World* world, - GraphObject* block) const; + SharedPtr lv2_features(World* world, + Node* block) const; private: typedef std::vector< SharedPtr > Features; diff --git a/ingen/Node.hpp b/ingen/Node.hpp new file mode 100644 index 00000000..9ec6abd1 --- /dev/null +++ b/ingen/Node.hpp @@ -0,0 +1,104 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + 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 . +*/ + +#ifndef INGEN_NODE_HPP +#define INGEN_NODE_HPP + +#include "raul/Path.hpp" +#include "raul/SharedPtr.hpp" +#include "ingen/Resource.hpp" + +namespace Raul { +class Atom; +class Path; +class Symbol; +} + +namespace Ingen { + +class Edge; +class Plugin; +class Store; + +/** An object on the audio graph. + * + * The key property of nodes is that all nodes have a path and a symbol, as + * well as a URI. + * + * To avoid ugly inheritance issues and the need for excessive use of + * dynamic_cast, this class contains some members which are only applicable to + * certain types of node. There is a type tag which can be used to determine + * the type of any Node. + * + * @ingroup Ingen + */ +class Node : public Resource +{ +public: + enum GraphType { + GRAPH, + BLOCK, + PORT + }; + + typedef std::pair EdgesKey; + typedef std::map< EdgesKey, SharedPtr > Edges; + + // Graphs only + Edges& edges() { return _edges; } + const Edges& edges() const { return _edges; } + + // Blocks and graphs only + virtual uint32_t num_ports() const { return 0; } + virtual Node* port(uint32_t index) const { return NULL; } + virtual const Plugin* plugin() const { return NULL; } + + // All objects + virtual GraphType graph_type() const = 0; + virtual const Raul::Path& path() const = 0; + virtual const Raul::Symbol& symbol() const = 0; + virtual Node* graph_parent() const = 0; + + static Raul::URI root_uri() { return Raul::URI("ingen:root"); } + + static bool uri_is_path(const Raul::URI& uri) { + return uri.substr(0, root_uri().length()) == root_uri(); + } + + static Raul::Path uri_to_path(const Raul::URI& uri) { + return (uri == root_uri()) + ? Raul::Path("/") + : Raul::Path(uri.substr(root_uri().length())); + } + + static Raul::URI path_to_uri(const Raul::Path& path) { + return Raul::URI(root_uri() + path.c_str()); + } + +protected: + friend class Store; + virtual void set_path(const Raul::Path& p) = 0; + + Node(URIs& uris, const Raul::Path& path) + : Resource(uris, path_to_uri(path)) + {} + + Edges _edges; ///< Graphs only +}; + +} // namespace Ingen + +#endif // INGEN_NODE_HPP diff --git a/ingen/Store.hpp b/ingen/Store.hpp index 1f329484..c176cdd3 100644 --- a/ingen/Store.hpp +++ b/ingen/Store.hpp @@ -22,7 +22,7 @@ #undef nil #include -#include "ingen/GraphObject.hpp" +#include "ingen/Node.hpp" #include "raul/Deletable.hpp" #include "raul/Noncopyable.hpp" @@ -33,23 +33,23 @@ namespace Ingen { */ class Store : public Raul::Noncopyable , public Raul::Deletable - , public std::map< const Raul::Path, SharedPtr > { + , public std::map< const Raul::Path, SharedPtr > { public: - void add(GraphObject* o); + void add(Node* o); - GraphObject* get(const Raul::Path& path) { + Node* get(const Raul::Path& path) { const iterator i = find(path); return (i == end()) ? NULL : i->second.get(); } typedef std::pair const_range; - typedef std::map< Raul::Path, SharedPtr > Objects; + typedef std::map< Raul::Path, SharedPtr > Objects; iterator find_descendants_end(Store::iterator parent); const_iterator find_descendants_end(Store::const_iterator parent) const; - const_range children_range(SharedPtr o) const; + const_range children_range(SharedPtr o) const; /** Remove the object at @p top and all its children from the store. * diff --git a/ingen/URIMap.hpp b/ingen/URIMap.hpp index d519b564..5f3aca63 100644 --- a/ingen/URIMap.hpp +++ b/ingen/URIMap.hpp @@ -46,7 +46,7 @@ public: _feature.data = data; } - SharedPtr feature(World*, GraphObject*) { + SharedPtr feature(World*, Node*) { return SharedPtr(&_feature, NullDeleter); } diff --git a/ingen/client/BlockModel.hpp b/ingen/client/BlockModel.hpp index d0bae8de..65d632d5 100644 --- a/ingen/client/BlockModel.hpp +++ b/ingen/client/BlockModel.hpp @@ -22,10 +22,10 @@ #include #include "raul/SharedPtr.hpp" -#include "ingen/GraphObject.hpp" +#include "ingen/Node.hpp" #include "ingen/client/ObjectModel.hpp" -#include "ingen/client/PortModel.hpp" #include "ingen/client/PluginModel.hpp" +#include "ingen/client/PortModel.hpp" namespace Raul { class Path; } @@ -48,13 +48,13 @@ public: BlockModel(const BlockModel& copy); virtual ~BlockModel(); - GraphType graph_type() const { return GraphObject::GRAPH; } + GraphType graph_type() const { return Node::GRAPH; } typedef std::vector< SharedPtr > Ports; SharedPtr get_port(const Raul::Symbol& symbol) const; - GraphObject* port(uint32_t index) const; + Node* port(uint32_t index) const; const Raul::URI& plugin_uri() const { return _plugin_uri; } const Plugin* plugin() const { return _plugin.get(); } diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp index e7e6105b..2ca25dde 100644 --- a/ingen/client/ClientStore.hpp +++ b/ingen/client/ClientStore.hpp @@ -31,8 +31,8 @@ namespace Raul { class Atom; } namespace Ingen { -class GraphObject; class Log; +class Node; class URIs; namespace Client { diff --git a/ingen/client/GraphModel.hpp b/ingen/client/GraphModel.hpp index 03a41891..d527eb82 100644 --- a/ingen/client/GraphModel.hpp +++ b/ingen/client/GraphModel.hpp @@ -35,10 +35,10 @@ class GraphModel : public BlockModel public: /* WARNING: Copy constructor creates a shallow copy WRT connections */ - GraphType graph_type() const { return GraphObject::GRAPH; } + GraphType graph_type() const { return Node::GRAPH; } - SharedPtr get_edge(const Ingen::GraphObject* tail, - const Ingen::GraphObject* head); + SharedPtr get_edge(const Ingen::Node* tail, + const Ingen::Node* head); bool enabled() const; bool polyphonic() const; @@ -62,8 +62,8 @@ private: bool remove_child(SharedPtr c); void add_edge(SharedPtr cm); - void remove_edge(const Ingen::GraphObject* tail, - const Ingen::GraphObject* head); + void remove_edge(const Ingen::Node* tail, + const Ingen::Node* head); }; } // namespace Client diff --git a/ingen/client/ObjectModel.hpp b/ingen/client/ObjectModel.hpp index c9f4e6d1..60e873e4 100644 --- a/ingen/client/ObjectModel.hpp +++ b/ingen/client/ObjectModel.hpp @@ -29,7 +29,7 @@ #include "raul/SharedPtr.hpp" #include "raul/URI.hpp" -#include "ingen/GraphObject.hpp" +#include "ingen/Node.hpp" #include "ingen/Resource.hpp" #include "ingen/client/signal.hpp" @@ -41,7 +41,7 @@ namespace Client { class ClientStore; -/** Base class for all GraphObject models (BlockModel, GraphModel, PortModel). +/** Base class for all Node models (BlockModel, GraphModel, PortModel). * * There are no non-const public methods intentionally, models are not allowed * to be manipulated directly by anything (but the Store) because of the @@ -52,7 +52,7 @@ class ClientStore; * * @ingroup IngenClient */ -class ObjectModel : public GraphObject +class ObjectModel : public Node { public: virtual ~ObjectModel(); @@ -68,7 +68,7 @@ public: SharedPtr parent() const { return _parent; } bool polyphonic() const; - GraphObject* graph_parent() const { return _parent.get(); } + Node* graph_parent() const { return _parent.get(); } // Signals INGEN_SIGNAL(new_child, void, SharedPtr); diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp index bfc56a9d..675cc827 100644 --- a/ingen/client/PortModel.hpp +++ b/ingen/client/PortModel.hpp @@ -41,7 +41,7 @@ class PortModel : public ObjectModel public: enum Direction { INPUT, OUTPUT }; - GraphType graph_type() const { return GraphObject::PORT; } + GraphType graph_type() const { return Node::PORT; } bool supports(const Raul::URI& value_type) const; diff --git a/ingen/serialisation/Parser.hpp b/ingen/serialisation/Parser.hpp index 666d9acb..6ece6965 100644 --- a/ingen/serialisation/Parser.hpp +++ b/ingen/serialisation/Parser.hpp @@ -27,7 +27,7 @@ #include #include -#include "ingen/GraphObject.hpp" +#include "ingen/Node.hpp" #include "raul/Path.hpp" namespace Ingen { @@ -48,7 +48,7 @@ public: virtual ~Parser() {} - typedef GraphObject::Properties Properties; + typedef Node::Properties Properties; virtual bool parse_file( World* world, diff --git a/ingen/serialisation/Serialiser.hpp b/ingen/serialisation/Serialiser.hpp index ae18693e..a694e800 100644 --- a/ingen/serialisation/Serialiser.hpp +++ b/ingen/serialisation/Serialiser.hpp @@ -25,12 +25,12 @@ #include "sord/sordmm.hpp" -#include "ingen/GraphObject.hpp" +#include "ingen/Node.hpp" namespace Ingen { class Edge; -class GraphObject; +class Node; class Store; class World; @@ -47,21 +47,21 @@ public: explicit Serialiser(World& world); virtual ~Serialiser(); - typedef GraphObject::Properties Properties; + typedef Node::Properties Properties; - virtual void to_file(SharedPtr object, - const std::string& filename); + virtual void to_file(SharedPtr object, + const std::string& filename); - virtual void write_bundle(SharedPtr graph, - const std::string& path); + virtual void write_bundle(SharedPtr graph, + const std::string& path); - virtual std::string to_string(SharedPtr object, - const std::string& base_uri); + virtual std::string to_string(SharedPtr object, + const std::string& base_uri); virtual void start_to_string(const Raul::Path& root, const std::string& base_uri); - virtual void serialise(SharedPtr object) + virtual void serialise(SharedPtr object) throw (std::logic_error); virtual void serialise_edge(const Sord::Node& parent, -- cgit v1.2.1