diff options
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/client/ObjectModel.hpp | 2 | ||||
-rw-r--r-- | src/libs/client/PatchModel.cpp | 2 | ||||
-rw-r--r-- | src/libs/client/Serializer.hpp | 4 | ||||
-rw-r--r-- | src/libs/client/Store.cpp | 55 | ||||
-rw-r--r-- | src/libs/client/Store.hpp | 8 | ||||
-rw-r--r-- | src/libs/engine/events/ConnectionEvent.cpp | 1 | ||||
-rw-r--r-- | src/libs/engine/events/DisconnectionEvent.cpp | 1 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.cpp | 8 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.hpp | 2 | ||||
-rw-r--r-- | src/libs/gui/PatchPortModule.cpp | 1 | ||||
-rw-r--r-- | src/libs/gui/RenameWindow.cpp | 4 |
11 files changed, 66 insertions, 22 deletions
diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp index fe0f223c..429f5359 100644 --- a/src/libs/client/ObjectModel.hpp +++ b/src/libs/client/ObjectModel.hpp @@ -81,7 +81,7 @@ protected: ObjectModel(const Path& path); - virtual void set_path(const Path& p) { _path = p; } + virtual void set_path(const Path& p) { _path = p; renamed_sig.emit(); } virtual void set_parent(SharedPtr<ObjectModel> p) { assert(p); _parent = p; } virtual void add_child(SharedPtr<ObjectModel> c); virtual bool remove_child(SharedPtr<ObjectModel> c); diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 615ae562..f67c7706 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -30,7 +30,7 @@ namespace Client { void PatchModel::set_path(const Path& new_path) { - throw; + ObjectModel::set_path(new_path); #if 0 // FIXME: haack if (new_path == "") { diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp index 837d7333..23f93df6 100644 --- a/src/libs/client/Serializer.hpp +++ b/src/libs/client/Serializer.hpp @@ -28,7 +28,7 @@ #include <raul/Atom.hpp> #include <raul/RDFWorld.hpp> #include <raul/RDFModel.hpp> -#include <raul/Table.hpp> +#include <raul/PathTable.hpp> #include "ObjectModel.hpp" namespace Ingen { @@ -72,7 +72,7 @@ private: Raul::RDF::Node path_to_node_id(const Path& path); - typedef Raul::Table<Path, Raul::RDF::Node> NodeMap; + typedef Raul::PathTable<Raul::RDF::Node> NodeMap; Mode _mode; NodeMap _node_map; diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index a2c9bf6f..674fc24e 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -24,11 +24,13 @@ #include "PatchModel.hpp" #include "SigClientInterface.hpp" +using namespace std; +using Raul::Path; + namespace Ingen { namespace Client { - Store::Store(SharedPtr<EngineInterface> engine, SharedPtr<SigClientInterface> emitter) : _engine(engine) , _emitter(emitter) @@ -146,7 +148,7 @@ Store::add_orphan(SharedPtr<ObjectModel> child) { cerr << "WARNING: Orphan object " << child->path() << " received." << endl; - Raul::Table<Path, list<SharedPtr<ObjectModel> > >::iterator children + Raul::PathTable<list<SharedPtr<ObjectModel> > >::iterator children = _orphans.find(child->path().parent()); _engine->request_object(child->path().parent()); @@ -164,7 +166,7 @@ Store::add_orphan(SharedPtr<ObjectModel> child) void Store::add_metadata_orphan(const Path& subject_path, const string& predicate, const Atom& value) { - Raul::Table<Path, list<std::pair<string, Atom> > >::iterator orphans + Raul::PathTable<list<std::pair<string, Atom> > >::iterator orphans = _metadata_orphans.find(subject_path); _engine->request_object(subject_path); @@ -182,7 +184,7 @@ Store::add_metadata_orphan(const Path& subject_path, const string& predicate, co void Store::resolve_metadata_orphans(SharedPtr<ObjectModel> subject) { - Raul::Table<Path, list<std::pair<string, Atom> > >::iterator v + Raul::PathTable<list<std::pair<string, Atom> > >::iterator v = _metadata_orphans.find(subject->path()); if (v != _metadata_orphans.end()) { @@ -202,7 +204,7 @@ Store::resolve_metadata_orphans(SharedPtr<ObjectModel> subject) void Store::resolve_orphans(SharedPtr<ObjectModel> parent) { - Raul::Table<Path, list<SharedPtr<ObjectModel> > >::iterator c + Raul::PathTable<list<SharedPtr<ObjectModel> > >::iterator c = _orphans.find(parent->path()); if (c != _orphans.end()) { @@ -257,7 +259,7 @@ Store::add_object(SharedPtr<ObjectModel> object) } - //cout << "[Store] Added " << object->path() << endl; + cout << "[Store] Added " << object->path() << endl; } @@ -348,14 +350,41 @@ Store::destruction_event(const Path& path) void Store::rename_event(const Path& old_path, const Path& new_path) { - SharedPtr<ObjectModel> object = remove_object(old_path); - if (object) { - object->set_path(new_path); - add_object(object); - object->renamed_sig.emit(); - cerr << "[Store] Renamed " << old_path << " -> " << new_path << endl; - } else { + Objects::iterator parent = _objects.find(old_path); + if (parent == _objects.end()) { cerr << "[Store] Failed to find object " << old_path << " to rename." << endl; + return; + } + + Objects::iterator descendants_end = _objects.find_descendants_end(parent); + + vector<pair<Path, SharedPtr<ObjectModel> > > objs = _objects.yank(parent, descendants_end); + + assert(objs.size() > 0); + + for (vector<pair<Path, SharedPtr<ObjectModel> > >::iterator i = objs.begin(); i != objs.end(); ++i) { + const Path& child_old_path = i->first; + assert(Path::descendant_comparator(old_path, child_old_path)); + + Path child_new_path; + if (child_old_path == old_path) + child_new_path = new_path; + else + child_new_path = new_path.base() + child_old_path.substr(old_path.length()+1); + + cerr << "[Store] Renamed " << child_old_path << " -> " << child_new_path << endl; + i->second->set_path(child_new_path); + i->first = child_new_path; + } + + _objects.cram(objs); + + cerr << "[Store] Table:" << endl; + //for (size_t i=0; i < objs.size(); ++i) { + // cerr << objs[i].first << "\t\t: " << objs[i].second << endl; + //} + for (Objects::iterator i = _objects.begin(); i != _objects.end(); ++i) { + cerr << i->first << "\t\t: " << i->second << endl; } } diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp index 627d6f8a..25398eaa 100644 --- a/src/libs/client/Store.hpp +++ b/src/libs/client/Store.hpp @@ -25,7 +25,7 @@ #include <sigc++/sigc++.h> #include <raul/Path.hpp> #include <raul/Atom.hpp> -#include <raul/Table.hpp> +#include <raul/PathTable.hpp> #include <raul/TableImpl.hpp> #include "interface/EngineInterface.hpp" using std::string; using std::list; @@ -63,7 +63,7 @@ public: typedef Raul::Table<string, SharedPtr<PluginModel> > Plugins; const Plugins& plugins() const { return _plugins; } - typedef Raul::Table<Path, SharedPtr<ObjectModel> > Objects; + typedef Raul::PathTable<SharedPtr<ObjectModel> > Objects; const Objects& objects() const { return _objects; } sigc::signal<void, SharedPtr<ObjectModel> > new_object_sig; @@ -113,14 +113,14 @@ private: /** Objects we've received, but depend on the existance of another unknown object. * Keyed by the path of the depended-on object (for tolerance of orderless comms) */ - Raul::Table<Path, list<SharedPtr<ObjectModel> > > _orphans; + Raul::PathTable<list<SharedPtr<ObjectModel> > > _orphans; /** Same idea, except with plugins instead of parents. * It's unfortunate everything doesn't just have a URI and this was the same.. ahem.. */ Raul::Table<string, list<SharedPtr<NodeModel> > > _plugin_orphans; /** Not orphans OF metadata like the above, but orphans which are metadata */ - Raul::Table<Path, list<std::pair<string, Atom> > > _metadata_orphans; + Raul::PathTable<list<std::pair<string, Atom> > > _metadata_orphans; /** Ditto */ list<SharedPtr<ConnectionModel> > _connection_orphans; diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index c1fd3180..554a974f 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -170,6 +170,7 @@ ConnectionEvent::post_process() // FIXME: better error messages string msg = "Unable to make connection "; msg.append(_src_port_path + " -> " + _dst_port_path); + cerr << "CONNECTION ERROR " << (unsigned)_error << endl; _responder->respond_error(msg); } } diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp index ba35f84e..dc78a118 100644 --- a/src/libs/engine/events/DisconnectionEvent.cpp +++ b/src/libs/engine/events/DisconnectionEvent.cpp @@ -192,6 +192,7 @@ DisconnectionEvent::post_process() // FIXME: better error messages string msg = "Unable to disconnect "; msg.append(_src_port_path + " -> " + _dst_port_path); + cerr << "DISCONNECTION ERROR " << (unsigned)_error << endl; _responder->respond_error(msg); } } diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index 3c319344..cf4f1409 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -51,6 +51,7 @@ NodeModule::NodeModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeMode node->metadata_update_sig.connect(sigc::mem_fun(this, &NodeModule::metadata_update)); signal_clicked.connect(sigc::mem_fun(this, &NodeModule::on_click)); + node->renamed_sig.connect(sigc::mem_fun(this, &NodeModule::renamed)); } @@ -89,6 +90,13 @@ NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> n void +NodeModule::renamed() +{ + set_name(_node->path().name()); +} + + +void NodeModule::add_port(SharedPtr<PortModel> port, bool resize_to_fit) { Module::add_port(boost::shared_ptr<Port>(new Port( diff --git a/src/libs/gui/NodeModule.hpp b/src/libs/gui/NodeModule.hpp index b68d1143..b554a64c 100644 --- a/src/libs/gui/NodeModule.hpp +++ b/src/libs/gui/NodeModule.hpp @@ -79,6 +79,8 @@ protected: void add_port(SharedPtr<PortModel> port, bool resize=true); void remove_port(SharedPtr<PortModel> port); + void renamed(); + SharedPtr<NodeModel> _node; NodeMenu _menu; }; diff --git a/src/libs/gui/PatchPortModule.cpp b/src/libs/gui/PatchPortModule.cpp index bf63e9b6..15ce9ac4 100644 --- a/src/libs/gui/PatchPortModule.cpp +++ b/src/libs/gui/PatchPortModule.cpp @@ -76,6 +76,7 @@ PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortMod sigc::bind( sigc::mem_fun(App::instance().window_factory(), &WindowFactory::present_rename), port))); + ret->add_port(ret->_patch_port); for (MetadataMap::const_iterator m = port->metadata().begin(); m != port->metadata().end(); ++m) diff --git a/src/libs/gui/RenameWindow.cpp b/src/libs/gui/RenameWindow.cpp index 04ffdd9f..6567799e 100644 --- a/src/libs/gui/RenameWindow.cpp +++ b/src/libs/gui/RenameWindow.cpp @@ -71,7 +71,9 @@ RenameWindow::name_changed() if (name.find("/") != string::npos) { _message_label->set_text("Name may not contain '/'"); _ok_button->property_sensitive() = false; - //} else if (_object->parent()->patch_model()->get_node(name) != NULL) { + } else if (!Path::is_valid_name(name)) { + _message_label->set_text("Name contains invalid characters"); + _ok_button->property_sensitive() = false; } else if (App::instance().store()->object(_object->parent()->path().base() + name)) { _message_label->set_text("An object already exists with that name."); _ok_button->property_sensitive() = false; |