diff options
author | David Robillard <d@drobilla.net> | 2012-05-10 06:24:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-10 06:24:07 +0000 |
commit | 0c9e861caa8b1eed5068942edc35d5f91bac816e (patch) | |
tree | b241856ddf49e1b1192f8ea442d1733d9d31b2f2 /src/client | |
parent | 8ec295a0f2a40086ed83e8d2ad8ad38c8125bcb4 (diff) | |
download | ingen-0c9e861caa8b1eed5068942edc35d5f91bac816e.tar.gz ingen-0c9e861caa8b1eed5068942edc35d5f91bac816e.tar.bz2 ingen-0c9e861caa8b1eed5068942edc35d5f91bac816e.zip |
Work towards translatable strings and a cleaner log interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4338 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/ClientStore.cpp | 137 | ||||
-rw-r--r-- | src/client/NodeModel.cpp | 17 | ||||
-rw-r--r-- | src/client/ObjectModel.cpp | 9 | ||||
-rw-r--r-- | src/client/PatchModel.cpp | 5 | ||||
-rw-r--r-- | src/client/PluginModel.cpp | 23 | ||||
-rw-r--r-- | src/client/PluginUI.cpp | 11 |
6 files changed, 95 insertions, 107 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 301737ae..ad5c6a60 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -25,12 +25,11 @@ #include "raul/PathTable.hpp" #include "raul/log.hpp" -#define LOG(s) s << "[ClientStore] " +#define LOG(s) (s("[ClientStore] ")) // #define INGEN_CLIENT_STORE_DUMP 1 using namespace std; -using namespace Raul; namespace Ingen { @@ -102,15 +101,15 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) i != object->properties().end(); ++i) object->signal_property().emit(i->first, i->second); - LOG(debug) << "Added " << object->path() << " {" << endl; + LOG(Raul::debug) << "Added " << object->path() << " {" << endl; for (iterator i = begin(); i != end(); ++i) { - LOG(debug) << "\t" << i->first << endl; + LOG(Raul::debug) << "\t" << i->first << endl; } - LOG(debug) << "}" << endl; + LOG(Raul::debug) << "}" << endl; } SharedPtr<ObjectModel> -ClientStore::remove_object(const Path& path) +ClientStore::remove_object(const Raul::Path& path) { iterator i = find(path); @@ -120,11 +119,11 @@ ClientStore::remove_object(const Path& path) iterator end = find_descendants_end(i); SharedPtr<Store::Objects> removed = yank(i, end); - LOG(debug) << "Removing " << i->first << " {" << endl; + LOG(Raul::debug) << "Removing " << i->first << " {" << endl; for (iterator i = removed->begin(); i != removed->end(); ++i) { - LOG(debug) << "\t" << i->first << endl; + LOG(Raul::debug) << "\t" << i->first << endl; } - LOG(debug) << "}" << endl; + LOG(Raul::debug) << "}" << endl; if (result) result->signal_destroyed().emit(); @@ -148,7 +147,7 @@ ClientStore::remove_object(const Path& path) } SharedPtr<PluginModel> -ClientStore::_plugin(const URI& uri) +ClientStore::_plugin(const Raul::URI& uri) { assert(uri.length() > 0); Plugins::iterator i = _plugins->find(uri); @@ -165,7 +164,7 @@ ClientStore::plugin(const Raul::URI& uri) const } SharedPtr<ObjectModel> -ClientStore::_object(const Path& path) +ClientStore::_object(const Raul::Path& path) { assert(path.length() > 0); iterator i = find(path); @@ -180,15 +179,15 @@ ClientStore::_object(const Path& path) } SharedPtr<const ObjectModel> -ClientStore::object(const Path& path) const +ClientStore::object(const Raul::Path& path) const { return const_cast<ClientStore*>(this)->_object(path); } SharedPtr<Resource> -ClientStore::_resource(const URI& uri) +ClientStore::_resource(const Raul::URI& uri) { - if (Path::is_path(uri)) + if (Raul::Path::is_path(uri)) return _object(uri.str()); else return _plugin(uri); @@ -215,7 +214,7 @@ ClientStore::add_plugin(SharedPtr<PluginModel> pm) /* ****** Signal Handlers ******** */ void -ClientStore::del(const URI& uri) +ClientStore::del(const Raul::URI& uri) { if (!Raul::Path::is_path(uri)) return; @@ -223,16 +222,13 @@ ClientStore::del(const URI& uri) const Raul::Path path(uri.str()); SharedPtr<ObjectModel> removed = remove_object(path); removed.reset(); - LOG(debug) << "Removed object " << path - << ", count: " << removed.use_count(); + LOG(Raul::debug) << "Removed object " << path + << ", count: " << removed.use_count(); } void -ClientStore::move(const Path& old_path_str, const Path& new_path_str) +ClientStore::move(const Raul::Path& old_path, const Raul::Path& new_path) { - Path old_path(old_path_str); - Path new_path(new_path_str); - iterator parent = find(old_path); if (parent == end()) { LOG(Raul::error) << "Failed to find object " << old_path @@ -240,27 +236,27 @@ ClientStore::move(const Path& old_path_str, const Path& new_path_str) return; } - typedef Table<Path, SharedPtr<GraphObject> > Removed; + typedef Table<Raul::Path, SharedPtr<GraphObject> > Removed; iterator end = find_descendants_end(parent); SharedPtr<Removed> removed = yank(parent, end); assert(removed->size() > 0); - typedef Table<Path, SharedPtr<GraphObject> > PathTable; + typedef Table<Raul::Path, SharedPtr<GraphObject> > PathTable; for (PathTable::iterator i = removed->begin(); i != removed->end(); ++i) { - const Path& child_old_path = i->first; - assert(Path::descendant_comparator(old_path, child_old_path)); + const Raul::Path& child_old_path = i->first; + assert(Raul::Path::descendant_comparator(old_path, child_old_path)); - Path child_new_path; + Raul::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); - LOG(info) << "Renamed " << child_old_path - << " -> " << child_new_path << endl; + LOG(Raul::info)(Raul::fmt("Renamed %1% to %2%\n") + % child_old_path % child_new_path); PtrCast<ObjectModel>(i->second)->set_path(child_new_path); i->first = child_new_path; } @@ -269,17 +265,17 @@ ClientStore::move(const Path& old_path_str, const Path& new_path_str) } void -ClientStore::put(const URI& uri, +ClientStore::put(const Raul::URI& uri, const Resource::Properties& properties, Resource::Graph ctx) { typedef Resource::Properties::const_iterator Iterator; #ifdef INGEN_CLIENT_STORE_DUMP - LOG(info) << "PUT " << uri << " {" << endl; + LOG(Raul::info) << "PUT " << uri << " {" << endl; for (Iterator i = properties.begin(); i != properties.end(); ++i) - LOG(info) << '\t' << i->first << " = " << _uris->forge.str(i->second) + LOG(Raul::info) << '\t' << i->first << " = " << _uris->forge.str(i->second) << " :: " << i->second.type() << endl; - LOG(info) << "}" << endl; + LOG(Raul::info) << "}" << endl; #endif bool is_patch, is_node, is_port, is_output; @@ -289,8 +285,8 @@ ClientStore::put(const URI& uri, // Check if uri is a plugin Iterator t = properties.find(_uris->rdf_type); if (t != properties.end() && t->second.type() == _uris->forge.URI) { - const Atom& type = t->second; - const URI& type_uri = type.get_uri(); + const Raul::Atom& type = t->second; + const Raul::URI& type_uri = type.get_uri(); const Plugin::Type plugin_type = Plugin::type_from_uri(type_uri); if (plugin_type == Plugin::Patch) { is_patch = true; @@ -302,12 +298,12 @@ ClientStore::put(const URI& uri, } } - if (!Path::is_valid(uri.str())) { + if (!Raul::Path::is_valid(uri.str())) { LOG(Raul::error) << "Bad path `" << uri.str() << "'" << endl; return; } - const Path path(uri.str()); + const Raul::Path path(uri.str()); SharedPtr<ObjectModel> obj = PtrCast<ObjectModel>(_object(path)); if (obj) { @@ -328,8 +324,8 @@ ClientStore::put(const URI& uri, SharedPtr<PluginModel> plug; if (p->second.is_valid() && p->second.type() == _uris->forge.URI) { if (!(plug = _plugin(p->second.get_uri()))) { - LOG(warn) << "Unable to find plugin " - << p->second.get_uri() << endl; + LOG(Raul::warn)(Raul::fmt("Unable to find plugin <%1%>\n") + % p->second.get_uri()); plug = SharedPtr<PluginModel>( new PluginModel(uris(), p->second.get_uri(), @@ -342,7 +338,7 @@ ClientStore::put(const URI& uri, n->set_properties(properties); add_object(n); } else { - LOG(warn) << "Node " << path << " has no plugin" << endl; + LOG(Raul::warn)(Raul::fmt("Node %1% has no plugin\n") % path); } } else if (is_port) { PortModel::Direction pdir = (is_output) @@ -359,54 +355,54 @@ ClientStore::put(const URI& uri, LOG(Raul::error) << "Port " << path << " has no index" << endl; } } else { - LOG(warn) << "Ignoring object " << path << " with unknown type " - << is_patch << " " << is_node << " " << is_port << endl; + LOG(Raul::warn)(Raul::fmt("Ignoring object %1% with unknown type\n") + % path); } } void -ClientStore::delta(const URI& uri, +ClientStore::delta(const Raul::URI& uri, const Resource::Properties& remove, const Resource::Properties& add) { typedef Resource::Properties::const_iterator iterator; #ifdef INGEN_CLIENT_STORE_DUMP - LOG(info) << "DELTA " << uri << " {" << endl; + LOG(Raul::info) << "DELTA " << uri << " {" << endl; for (iterator i = remove.begin(); i != remove.end(); ++i) - LOG(info) << " - " << i->first - << " = " << _uris->forge.str(i->second) - << " :: " << i->second.type() << endl; + LOG(Raul::info) << " - " << i->first + << " = " << _uris->forge.str(i->second) + << " :: " << i->second.type() << endl; for (iterator i = add.begin(); i != add.end(); ++i) - LOG(info) << " + " << i->first - << " = " << _uris->forge.str(i->second) - << " :: " << i->second.type() << endl; - LOG(info) << "}" << endl; + LOG(Raul::info) << " + " << i->first + << " = " << _uris->forge.str(i->second) + << " :: " << i->second.type() << endl; + LOG(Raul::info) << "}" << endl; #endif - if (!Path::is_valid(uri.str())) { + if (!Raul::Path::is_valid(uri.str())) { LOG(Raul::error) << "Bad path `" << uri.str() << "'" << endl; return; } - const Path path(uri.str()); + const Raul::Path path(uri.str()); SharedPtr<ObjectModel> obj = _object(path); if (obj) { obj->remove_properties(remove); obj->add_properties(add); } else { - LOG(warn) << "Failed to find object `" << path << "'" << endl; + LOG(Raul::warn)(Raul::fmt("Failed to find object `%1%'\n") % path); } } void -ClientStore::set_property(const URI& subject_uri, - const URI& predicate, - const Atom& value) +ClientStore::set_property(const Raul::URI& subject_uri, + const Raul::URI& predicate, + const Raul::Atom& value) { if (subject_uri == _uris->ingen_engine) { - LOG(info) << "Engine property " << predicate - << " = " << _uris->forge.str(value) << endl; + LOG(Raul::info)(Raul::fmt("Engine property <%1%> = %2%\n") + % predicate % _uris->forge.str(value)); return; } SharedPtr<Resource> subject = _resource(subject_uri); @@ -417,13 +413,14 @@ ClientStore::set_property(const URI& subject_uri, if (plugin) plugin->set_property(predicate, value); else - LOG(warn) << "Property '" << predicate << "' for unknown object " - << subject_uri << endl; + LOG(Raul::warn)(Raul::fmt("Property <%1%> for unknown object %2%\n") + % predicate % subject_uri); } } SharedPtr<PatchModel> -ClientStore::connection_patch(const Path& tail_path, const Path& head_path) +ClientStore::connection_patch(const Raul::Path& tail_path, + const Raul::Path& head_path) { SharedPtr<PatchModel> patch; @@ -447,8 +444,8 @@ ClientStore::connection_patch(const Path& tail_path, const Path& head_path) } bool -ClientStore::attempt_connection(const Path& tail_path, - const Path& head_path) +ClientStore::attempt_connection(const Raul::Path& tail_path, + const Raul::Path& head_path) { SharedPtr<PortModel> tail = PtrCast<PortModel>(_object(tail_path)); SharedPtr<PortModel> head = PtrCast<PortModel>(_object(head_path)); @@ -468,24 +465,24 @@ ClientStore::attempt_connection(const Path& tail_path, } void -ClientStore::connect(const Path& src_path, - const Path& dst_path) +ClientStore::connect(const Raul::Path& src_path, + const Raul::Path& dst_path) { attempt_connection(src_path, dst_path); } void -ClientStore::disconnect(const Path& src, - const Path& dst) +ClientStore::disconnect(const Raul::Path& src, + const Raul::Path& dst) { - if (!Path::is_path(src) && !Path::is_path(dst)) { + if (!Raul::Path::is_path(src) && !Raul::Path::is_path(dst)) { std::cerr << "Bad disconnect notification " << src << " => " << dst << std::endl; return; } - const Path src_path(src.str()); - const Path dst_path(dst.str()); + const Raul::Path src_path(src.str()); + const Raul::Path dst_path(dst.str()); SharedPtr<PortModel> tail = PtrCast<PortModel>(_object(src_path)); SharedPtr<PortModel> head = PtrCast<PortModel>(_object(dst_path)); diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp index 652ed318..f80aa68d 100644 --- a/src/client/NodeModel.cpp +++ b/src/client/NodeModel.cpp @@ -22,15 +22,12 @@ #include "ingen/shared/URIs.hpp" #include "ingen/shared/World.hpp" -using namespace std; -using namespace Raul; - namespace Ingen { namespace Client { NodeModel::NodeModel(Shared::URIs& uris, SharedPtr<PluginModel> plugin, - const Path& path) + const Raul::Path& path) : Node() , ObjectModel(uris, path) , _plugin_uri(plugin->uri()) @@ -41,9 +38,9 @@ NodeModel::NodeModel(Shared::URIs& uris, { } -NodeModel::NodeModel(Shared::URIs& uris, - const URI& plugin_uri, - const Path& path) +NodeModel::NodeModel(Shared::URIs& uris, + const Raul::URI& plugin_uri, + const Raul::Path& path) : Node() , ObjectModel(uris, path) , _plugin_uri(plugin_uri) @@ -83,7 +80,7 @@ NodeModel::remove_port(SharedPtr<PortModel> port) } void -NodeModel::remove_port(const Path& port_path) +NodeModel::remove_port(const Raul::Path& port_path) { for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { if ((*i)->path() == port_path) { @@ -204,8 +201,8 @@ NodeModel::port_value_range(SharedPtr<const PortModel> port, default_port_value_range(port, min, max); // Possibly overriden - const Atom& min_atom = port->get_property(_uris.lv2_minimum); - const Atom& max_atom = port->get_property(_uris.lv2_maximum); + const Raul::Atom& min_atom = port->get_property(_uris.lv2_minimum); + const Raul::Atom& max_atom = port->get_property(_uris.lv2_maximum); if (min_atom.type() == _uris.forge.Float) min = min_atom.get_float(); if (max_atom.type() == _uris.forge.Float) diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 452a6a3b..271d0b66 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -19,9 +19,6 @@ #include "ingen/shared/URIs.hpp" #include "raul/TableImpl.hpp" -using namespace std; -using namespace Raul; - namespace Ingen { namespace Client { @@ -29,7 +26,7 @@ ObjectModel::ObjectModel(Shared::URIs& uris, const Raul::Path& path) : ResourceImpl(uris, path) , _meta(uris, Raul::URI("http://example.org/FIXME")) , _path(path) - , _symbol((path == Path::root()) ? "root" : path.symbol()) + , _symbol((path == Raul::Path::root()) ? "root" : path.symbol()) { } @@ -58,10 +55,10 @@ ObjectModel::on_property(const Raul::URI& uri, const Raul::Atom& value) _signal_property.emit(uri, value); } -const Atom& +const Raul::Atom& ObjectModel::get_property(const Raul::URI& key) const { - static const Atom null_atom; + static const Raul::Atom null_atom; Resource::Properties::const_iterator i = properties().find(key); return (i != properties().end()) ? i->second : null_atom; } diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index 91c0c7f1..e52e4eea 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -25,7 +25,6 @@ #include "ingen/shared/URIs.hpp" using namespace std; -using namespace Raul; namespace Ingen { namespace Client { @@ -148,8 +147,8 @@ PatchModel::remove_connection(const Port* tail, const Ingen::Port* head) _signal_removed_connection.emit(c); _connections->erase(i); } else { - warn << "[PatchModel::remove_connection] Failed to find connection " << - tail->path() << " -> " << head->path() << endl; + Raul::warn(Raul::fmt("Failed to remove patch connection %1% => %2%\n") + % tail->path() % head->path()); } } diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 1612be45..e6ac0a52 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -28,7 +28,6 @@ #include "ingen_config.h" using namespace std; -using namespace Raul; namespace Ingen { namespace Client { @@ -39,8 +38,8 @@ const LilvPlugins* PluginModel::_lilv_plugins = NULL; Sord::World* PluginModel::_rdf_world = NULL; PluginModel::PluginModel(Shared::URIs& uris, - const URI& uri, - const URI& type_uri, + const Raul::URI& uri, + const Raul::URI& type_uri, const Resource::Properties& properties) : ResourceImpl(uris, uri) , _type(type_from_uri(type_uri.str())) @@ -60,17 +59,17 @@ PluginModel::PluginModel(Shared::URIs& uris, } } -const Atom& -PluginModel::get_property(const URI& key) const +const Raul::Atom& +PluginModel::get_property(const Raul::URI& key) const { - static const Atom nil; - const Atom& val = ResourceImpl::get_property(key); + static const Raul::Atom nil; + const Raul::Atom& val = ResourceImpl::get_property(key); if (val.is_valid()) return val; // No lv2:symbol from data or engine, invent one if (key == _uris.lv2_symbol) { - const URI& uri = this->uri(); + const Raul::URI& uri = this->uri(); size_t last_slash = uri.find_last_of('/'); size_t last_hash = uri.find_last_of('#'); string symbol; @@ -150,12 +149,12 @@ PluginModel::set(SharedPtr<PluginModel> p) _signal_changed.emit(); } -Symbol +Raul::Symbol PluginModel::default_node_symbol() const { - const Atom& name_atom = get_property(LV2_CORE__symbol); + const Raul::Atom& name_atom = get_property(LV2_CORE__symbol); if (name_atom.is_valid() && name_atom.type() == _uris.forge.String) - return Symbol::symbolify(name_atom.get_string()); + return Raul::Symbol::symbolify(name_atom.get_string()); else return "_"; } @@ -163,7 +162,7 @@ PluginModel::default_node_symbol() const string PluginModel::human_name() const { - const Atom& name_atom = get_property("http://usefulinc.com/ns/doap#name"); + const Raul::Atom& name_atom = get_property("http://usefulinc.com/ns/doap#name"); if (name_atom.type() == _uris.forge.String) return name_atom.get_string(); else diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index 939716ef..59d4c1b4 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -24,7 +24,6 @@ #include "lv2/lv2plug.in/ns/extensions/ui/ui.h" using namespace std; -using namespace Raul; namespace Ingen { namespace Client { @@ -42,8 +41,8 @@ lv2_ui_write(SuilController controller, const NodeModel::Ports& ports = ui->node()->ports(); if (port_index >= ports.size()) { - error << "UI for " << ui->node()->plugin()->uri() - << " tried to write to non-existent port " << port_index << endl; + Raul::error << (Raul::fmt("%1% UI tried to write to invalid port %2%") + % ui->node()->plugin()->uri() % port_index) << endl; return; } @@ -71,8 +70,8 @@ lv2_ui_write(SuilController controller, val); } else { - warn << "Unknown value format " << format - << " from LV2 UI " << ui->node()->plugin()->uri() << endl; + Raul::warn(Raul::fmt("Unknown value format %1% from LV2 UI\n") + % format % ui->node()->plugin()->uri()); } } @@ -145,7 +144,7 @@ PluginUI::create(Ingen::Shared::World* world, if (instance) { ret->_instance = instance; } else { - error << "Failed to instantiate LV2 UI" << endl; + Raul::error << "Failed to instantiate LV2 UI" << endl; ret.reset(); } |