summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-14 21:37:20 +0000
committerDavid Robillard <d@drobilla.net>2012-08-14 21:37:20 +0000
commit76b602f1f834cb2c255848c5ba887b3d7c47171a (patch)
treecbe6588c70f2df4384231d9cbdfd06fb0aa7e45f /ingen
parenta8312be2d849b73ff0acc80a226095bcfee3556c (diff)
downloadingen-76b602f1f834cb2c255848c5ba887b3d7c47171a.tar.gz
ingen-76b602f1f834cb2c255848c5ba887b3d7c47171a.tar.bz2
ingen-76b602f1f834cb2c255848c5ba887b3d7c47171a.zip
Replace use of old Raul Table stuff with std::map.
Move most Store functionality into Ingen::Store and eliminate EngineStore. Much cleaner delete and move implementations. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4696 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'ingen')
-rw-r--r--ingen/GraphObject.hpp4
-rw-r--r--ingen/Store.hpp40
-rw-r--r--ingen/client/ClientStore.hpp6
-rw-r--r--ingen/client/NodeModel.hpp2
4 files changed, 36 insertions, 16 deletions
diff --git a/ingen/GraphObject.hpp b/ingen/GraphObject.hpp
index 048aaebd..25d6ea75 100644
--- a/ingen/GraphObject.hpp
+++ b/ingen/GraphObject.hpp
@@ -31,6 +31,7 @@ namespace Ingen {
class Edge;
class Plugin;
+class Store;
/** An object on the audio graph - Patch, Node, Port, etc.
*
@@ -80,6 +81,9 @@ public:
}
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))
{}
diff --git a/ingen/Store.hpp b/ingen/Store.hpp
index f35c8368..87f6f7e0 100644
--- a/ingen/Store.hpp
+++ b/ingen/Store.hpp
@@ -17,32 +17,52 @@
#ifndef INGEN_STORE_HPP
#define INGEN_STORE_HPP
-#include <string>
+#include <map>
#undef nil
#include <glibmm/thread.h>
-#include "raul/PathTable.hpp"
-
#include "ingen/GraphObject.hpp"
+#include "raul/Deletable.hpp"
+#include "raul/Noncopyable.hpp"
namespace Ingen {
/** Store of objects in the patch hierarchy.
* @ingroup IngenShared
*/
-class Store : public Raul::PathTable< SharedPtr<GraphObject> > {
+class Store : public Raul::Noncopyable
+ , public Raul::Deletable
+ , public std::map< const Raul::Path, SharedPtr<GraphObject> > {
public:
- virtual ~Store() {}
-
- virtual void add(GraphObject* o);
+ void add(GraphObject* o);
- typedef Raul::Table< Raul::Path, SharedPtr<GraphObject> > Objects;
+ GraphObject* get(const Raul::Path& path) {
+ const iterator i = find(path);
+ return (i == end()) ? NULL : i->second.get();
+ }
typedef std::pair<const_iterator, const_iterator> const_range;
- const_range
- children_range(SharedPtr<const GraphObject> o) const;
+ typedef std::map< Raul::Path, SharedPtr<GraphObject> > Objects;
+
+ iterator find_descendants_end(Store::iterator parent);
+ const_iterator find_descendants_end(Store::const_iterator parent) const;
+
+ const_range children_range(SharedPtr<const GraphObject> o) const;
+
+ /** Remove the object at @p top and all its children from the store.
+ *
+ * @param removed Filled with all the removed objects. Note this may be
+ * many objects since any children will be removed as well.
+ */
+ void remove(iterator top, Objects& removed);
+
+ /** Rename (move) the object at @p top to @p new_path.
+ *
+ * Note this invalidates @p i.
+ */
+ void rename(iterator i, const Raul::Path& new_path);
unsigned child_name_offset(const Raul::Path& parent,
const Raul::Symbol& symbol,
diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp
index 3762dcb0..cfa9df12 100644
--- a/ingen/client/ClientStore.hpp
+++ b/ingen/client/ClientStore.hpp
@@ -25,9 +25,7 @@
#include "ingen/client/signal.hpp"
#include "ingen/Store.hpp"
#include "raul/Path.hpp"
-#include "raul/PathTable.hpp"
#include "raul/SharedPtr.hpp"
-#include "raul/TableImpl.hpp"
namespace Raul { class Atom; }
@@ -67,7 +65,7 @@ public:
void clear();
- typedef Raul::Table<Raul::URI, SharedPtr<PluginModel> > Plugins;
+ typedef std::map< const Raul::URI, SharedPtr<PluginModel> > Plugins;
SharedPtr<const Plugins> plugins() const { return _plugins; }
SharedPtr<Plugins> plugins() { return _plugins; }
void set_plugins(SharedPtr<Plugins> p) { _plugins = p; }
@@ -109,8 +107,6 @@ public:
INGEN_SIGNAL(new_plugin, void, SharedPtr<PluginModel>);
private:
- void add(GraphObject* o) { throw; }
-
SharedPtr<ObjectModel> _object(const Raul::Path& path);
SharedPtr<PluginModel> _plugin(const Raul::URI& uri);
SharedPtr<Resource> _resource(const Raul::URI& uri);
diff --git a/ingen/client/NodeModel.hpp b/ingen/client/NodeModel.hpp
index 93a512f0..9f2fab6e 100644
--- a/ingen/client/NodeModel.hpp
+++ b/ingen/client/NodeModel.hpp
@@ -96,7 +96,7 @@ protected:
virtual void clear();
- Ports _ports; ///< Vector of ports (not a Table to preserve order)
+ Ports _ports; ///< Vector of ports
Raul::URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown)
SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of