diff options
author | David Robillard <d@drobilla.net> | 2019-03-08 09:06:55 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-03-08 09:06:55 +0100 |
commit | acb958e95d0e8ca1b0dd912fe8bbf2e14e5f74e9 (patch) | |
tree | a229f986933c8ef9d9c15b36ecf58b04ebeaa7c0 /src/gui | |
parent | 112eb3a668f65547b1757978b02cbafebf97b794 (diff) | |
download | ingen-acb958e95d0e8ca1b0dd912fe8bbf2e14e5f74e9.tar.gz ingen-acb958e95d0e8ca1b0dd912fe8bbf2e14e5f74e9.tar.bz2 ingen-acb958e95d0e8ca1b0dd912fe8bbf2e14e5f74e9.zip |
Pass World everywhere by reference
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/App.cpp | 58 | ||||
-rw-r--r-- | src/gui/App.hpp | 16 | ||||
-rw-r--r-- | src/gui/ConnectWindow.cpp | 43 | ||||
-rw-r--r-- | src/gui/ConnectWindow.hpp | 2 | ||||
-rw-r--r-- | src/gui/GraphBox.cpp | 18 | ||||
-rw-r--r-- | src/gui/GraphCanvas.cpp | 18 | ||||
-rw-r--r-- | src/gui/GraphPortModule.cpp | 4 | ||||
-rw-r--r-- | src/gui/LoadGraphWindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/NodeModule.cpp | 6 | ||||
-rw-r--r-- | src/gui/Port.cpp | 34 | ||||
-rw-r--r-- | src/gui/PropertiesWindow.cpp | 41 | ||||
-rw-r--r-- | src/gui/RDFS.cpp | 76 | ||||
-rw-r--r-- | src/gui/RDFS.hpp | 18 | ||||
-rw-r--r-- | src/gui/ThreadedLoader.cpp | 20 | ||||
-rw-r--r-- | src/gui/URIEntry.cpp | 12 | ||||
-rw-r--r-- | src/gui/ingen_gui.cpp | 20 | ||||
-rw-r--r-- | src/gui/ingen_gui_lv2.cpp | 2 |
17 files changed, 197 insertions, 197 deletions
diff --git a/src/gui/App.cpp b/src/gui/App.cpp index 8a33fe46..df4159a1 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -70,7 +70,7 @@ class Port; Gtk::Main* App::_main = nullptr; -App::App(ingen::World* world) +App::App(ingen::World& world) : _style(new Style(*this)) , _about_dialog(nullptr) , _window_factory(new WindowFactory(*this)) @@ -85,7 +85,7 @@ App::App(ingen::World* world) , _requested_plugins(false) , _is_plugin(false) { - _world->conf().load_default("ingen", "gui.ttl"); + _world.conf().load_default("ingen", "gui.ttl"); WidgetFactory::get_widget_derived("connect_win", _connect_window); WidgetFactory::get_widget_derived("messages_win", _messages_window); @@ -97,11 +97,11 @@ App::App(ingen::World* world) _about_dialog->property_program_name() = "Ingen"; _about_dialog->property_logo_icon_name() = "ingen"; - PluginModel::set_rdf_world(*world->rdf_world()); - PluginModel::set_lilv_world(world->lilv_world()); + PluginModel::set_rdf_world(*world.rdf_world()); + PluginModel::set_lilv_world(world.lilv_world()); using namespace std::placeholders; - world->log().set_sink(std::bind(&MessagesWindow::log, _messages_window, _1, _2, _3)); + world.log().set_sink(std::bind(&MessagesWindow::log, _messages_window, _1, _2, _3)); } App::~App() @@ -111,9 +111,9 @@ App::~App() } SPtr<App> -App::create(ingen::World* world) +App::create(ingen::World& world) { - suil_init(&world->argc(), &world->argv(), SUIL_ARG_NONE); + suil_init(&world.argc(), &world.argv(), SUIL_ARG_NONE); // Add RC file for embedded GUI Gtk style const std::string rc_path = ingen::data_file_path("ingen_style.rc"); @@ -123,10 +123,10 @@ App::create(ingen::World* world) if (!_main) { Glib::set_application_name("Ingen"); gtk_window_set_default_icon_name("ingen"); - _main = new Gtk::Main(&world->argc(), &world->argv()); + _main = new Gtk::Main(&world.argc(), &world.argv()); } - App* app = new App(world); + auto app = SPtr<App>{new App(world)}; // Load configuration settings app->style()->load_settings(); @@ -137,7 +137,7 @@ App::create(ingen::World* world) app->_about_dialog->property_logo_icon_name() = "ingen"; gtk_window_set_default_icon_name("ingen"); - return SPtr<App>(app); + return app; } void @@ -164,20 +164,20 @@ App::attach(SPtr<ingen::Interface> client) assert(!_store); assert(!_loader); - if (_world->engine()) { - _world->engine()->register_client(client); + if (_world.engine()) { + _world.engine()->register_client(client); } _client = client; - _store = SPtr<ClientStore>(new ClientStore(_world->uris(), _world->log(), sig_client())); - _loader = SPtr<ThreadedLoader>(new ThreadedLoader(*this, _world->interface())); - if (!_world->store()) { - _world->set_store(_store); + _store = SPtr<ClientStore>(new ClientStore(_world.uris(), _world.log(), sig_client())); + _loader = SPtr<ThreadedLoader>(new ThreadedLoader(*this, _world.interface())); + if (!_world.store()) { + _world.set_store(_store); } - if (_world->conf().option("dump").get<int32_t>()) { - _dumper = SPtr<StreamWriter>(new StreamWriter(_world->uri_map(), - _world->uris(), + if (_world.conf().option("dump").get<int32_t>()) { + _dumper = SPtr<StreamWriter>(new StreamWriter(_world.uri_map(), + _world.uris(), URI("ingen:/client"), stderr, ColorContext::Color::CYAN)); @@ -193,14 +193,14 @@ App::attach(SPtr<ingen::Interface> client) void App::detach() { - if (_world->interface()) { + if (_world.interface()) { _window_factory->clear(); _store->clear(); _loader.reset(); _store.reset(); _client.reset(); - _world->set_interface(SPtr<Interface>()); + _world.set_interface(SPtr<Interface>()); } } @@ -208,7 +208,7 @@ void App::request_plugins_if_necessary() { if (!_requested_plugins) { - _world->interface()->get(URI("ingen:/plugins")); + _world.interface()->get(URI("ingen:/plugins")); _requested_plugins = true; } } @@ -226,7 +226,7 @@ App::sig_client() SPtr<Serialiser> App::serialiser() { - return _world->serialiser(); + return _world.serialiser(); } void @@ -323,7 +323,7 @@ App::property_change(const URI& subject, } else if (key == uris().ingen_maxRunLoad && value.type() == forge().Float) { _max_run_load = value.get<float>(); } else { - _world->log().warn(fmt("Unknown engine property %1%\n") % key); + _world.log().warn(fmt("Unknown engine property %1%\n") % key); return; } @@ -421,8 +421,8 @@ App::gtk_main_iteration() } _enable_signal = false; - if (_world->engine()) { - if (!_world->engine()->main_iteration()) { + if (_world.engine()) { + if (!_world.engine()->main_iteration()) { Gtk::Main::quit(); return false; } @@ -448,7 +448,7 @@ bool App::quit(Gtk::Window* dialog_parent) { bool quit = true; - if (_world->engine() && _connect_window->attached()) { + if (_world.engine() && _connect_window->attached()) { Gtk::MessageDialog d( "The engine is running in this process. Quitting will terminate Ingen." "\n\n" "Are you sure you want to quit?", @@ -468,8 +468,8 @@ App::quit(Gtk::Window* dialog_parent) Gtk::Main::quit(); try { - const std::string path = _world->conf().save( - _world->uri_map(), "ingen", "gui.ttl", Configuration::GUI); + const std::string path = _world.conf().save( + _world.uri_map(), "ingen", "gui.ttl", Configuration::GUI); std::cout << (fmt("Saved GUI settings to %1%\n") % path); } catch (const std::exception& e) { std::cerr << (fmt("Error saving GUI settings (%1%)\n") diff --git a/src/gui/App.hpp b/src/gui/App.hpp index 76465bfb..1aa5cbc1 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -118,8 +118,8 @@ public: Style* style() const { return _style; } WindowFactory* window_factory() const { return _window_factory; } - ingen::Forge& forge() const { return _world->forge(); } - SPtr<ingen::Interface> interface() const { return _world->interface(); } + ingen::Forge& forge() const { return _world.forge(); } + SPtr<ingen::Interface> interface() const { return _world.interface(); } SPtr<ingen::Interface> client() const { return _client; } SPtr<client::ClientStore> store() const { return _store; } SPtr<ThreadedLoader> loader() const { return _loader; } @@ -128,7 +128,7 @@ public: SPtr<Serialiser> serialiser(); - static SPtr<App> create(ingen::World* world); + static SPtr<App> create(ingen::World& world); void run(); @@ -136,12 +136,12 @@ public: sigc::signal<void, const std::string&> signal_status_text_changed; - inline ingen::World* world() const { return _world; } - inline ingen::URIs& uris() const { return _world->uris(); } - inline ingen::Log& log() const { return _world->log(); } + inline ingen::World& world() const { return _world; } + inline ingen::URIs& uris() const { return _world.uris(); } + inline ingen::Log& log() const { return _world.log(); } protected: - explicit App(ingen::World* world); + explicit App(ingen::World& world); void message(const ingen::Message& msg); @@ -172,7 +172,7 @@ protected: Gtk::AboutDialog* _about_dialog; WindowFactory* _window_factory; - ingen::World* _world; + ingen::World& _world; int32_t _sample_rate; int32_t _block_length; diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index e76fbc06..e2968ea2 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -96,22 +96,22 @@ ConnectWindow::error(const std::string& msg) _progress_label->set_text(msg); } - if (_app && _app->world()) { - _app->world()->log().error(msg + "\n"); + if (_app) { + _app->world().log().error(msg + "\n"); } } void -ConnectWindow::start(App& app, ingen::World* world) +ConnectWindow::start(App& app, ingen::World& world) { _app = &app; - if (world->engine()) { + if (world.engine()) { _mode = Mode::INTERNAL; } - set_connected_to(world->interface()); - connect(bool(world->interface())); + set_connected_to(world.interface()); + connect(bool(world.interface())); } void @@ -131,7 +131,7 @@ ConnectWindow::ingen_response(int32_t id, void ConnectWindow::set_connected_to(SPtr<ingen::Interface> engine) { - _app->world()->set_interface(engine); + _app->world().set_interface(engine); if (!_widgets_loaded) { return; @@ -193,14 +193,14 @@ ConnectWindow::set_connecting_widget_states() bool ConnectWindow::connect_remote(const URI& uri) { - ingen::World* world = _app->world(); + ingen::World& world = _app->world(); SPtr<SigClientInterface> sci(new SigClientInterface()); SPtr<QueuedInterface> qi(new QueuedInterface(sci)); - SPtr<ingen::Interface> iface(world->new_interface(uri, qi)); + SPtr<ingen::Interface> iface(world.new_interface(uri, qi)); if (iface) { - world->set_interface(iface); + world.set_interface(iface); _app->attach(qi); _app->register_callbacks(); return true; @@ -223,14 +223,15 @@ ConnectWindow::connect(bool existing) set_connecting_widget_states(); _connect_stage = 0; - ingen::World* world = _app->world(); + ingen::World& world = _app->world(); if (_mode == Mode::CONNECT_REMOTE) { - std::string uri_str = world->conf().option("connect").ptr<char>(); + std::string uri_str = world.conf().option("connect").ptr<char>(); if (existing) { - uri_str = world->interface()->uri(); + uri_str = world.interface()->uri(); _connect_stage = 1; - SPtr<client::SocketClient> client = dynamic_ptr_cast<client::SocketClient>(world->interface()); + SPtr<client::SocketClient> client = dynamic_ptr_cast<client::SocketClient>( + world.interface()); if (client) { _app->attach(client->respondee()); _app->register_callbacks(); @@ -261,14 +262,14 @@ ConnectWindow::connect(bool existing) _connect_uri = URI(std::string("tcp://localhost:") + port); } else if (_mode == Mode::INTERNAL) { - if (!world->engine()) { - if (!world->load_module("server")) { + if (!world.engine()) { + if (!world.load_module("server")) { error("Failed to load server module"); return; - } else if (!world->load_module("jack")) { + } else if (!world.load_module("jack")) { error("Failed to load jack module"); return; - } else if (!world->engine()->activate()) { + } else if (!world.engine()->activate()) { error("Failed to activate engine"); return; } @@ -376,7 +377,7 @@ ConnectWindow::load_widgets() _quit_button->signal_clicked().connect( sigc::mem_fun(this, &ConnectWindow::quit_clicked)); - _url_entry->set_text(_app->world()->conf().option("connect").ptr<char>()); + _url_entry->set_text(_app->world().conf().option("connect").ptr<char>()); if (URI::is_valid(_url_entry->get_text())) { _connect_uri = URI(_url_entry->get_text()); } @@ -384,7 +385,7 @@ ConnectWindow::load_widgets() _port_spinbutton->set_range(1, std::numeric_limits<uint16_t>::max()); _port_spinbutton->set_increments(1, 100); _port_spinbutton->set_value( - _app->world()->conf().option("engine-port").get<int32_t>()); + _app->world().conf().option("engine-port").get<int32_t>()); _progress_bar->set_pulse_step(0.01); _widgets_loaded = true; @@ -485,7 +486,7 @@ ConnectWindow::gtk_callback() last = now; if (_mode == Mode::INTERNAL) { SPtr<SigClientInterface> client(new SigClientInterface()); - _app->world()->interface()->set_respondee(client); + _app->world().interface()->set_respondee(client); _app->attach(client); _app->register_callbacks(); next_stage(); diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp index 151b8e92..093fafc0 100644 --- a/src/gui/ConnectWindow.hpp +++ b/src/gui/ConnectWindow.hpp @@ -50,7 +50,7 @@ public: Glib::RefPtr<Gtk::Builder> xml); void set_connected_to(SPtr<ingen::Interface> engine); - void start(App& app, ingen::World* world); + void start(App& app, ingen::World& world); bool attached() const { return _finished_connecting; } bool quit_flag() const { return _quit_flag; } diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 966e8b9c..cb9edf98 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -345,9 +345,9 @@ GraphBox::set_graph(SPtr<const GraphModel> graph, _alignment->show_all(); _menu_human_names->set_active( - _app->world()->conf().option("human-names").get<int32_t>()); + _app->world().conf().option("human-names").get<int32_t>()); _menu_show_port_names->set_active( - _app->world()->conf().option("port-labels").get<int32_t>()); + _app->world().conf().option("port-labels").get<int32_t>()); _doc_paned->set_position(std::numeric_limits<int>::max()); _doc_scrolledwindow->hide(); @@ -576,7 +576,7 @@ GraphBox::event_save_as() // Set current folder to most sensible default const Atom& document = _graph->get_property(uris.ingen_file); - const Atom& dir = _app->world()->conf().option("graph-directory"); + const Atom& dir = _app->world().conf().option("graph-directory"); if (document.type() == uris.forge.URI) { dialog.set_uri(document.ptr<char>()); } else if (dir.is_valid()) { @@ -649,9 +649,9 @@ GraphBox::event_save_as() _app->forge().alloc_uri(uri.c_str())); } - _app->world()->conf().set( + _app->world().conf().set( "graph-directory", - _app->world()->forge().alloc(dialog.get_current_folder())); + _app->world().forge().alloc(dialog.get_current_folder())); break; } @@ -898,17 +898,17 @@ void GraphBox::event_human_names_toggled() { _view->canvas()->show_human_names(_menu_human_names->get_active()); - _app->world()->conf().set( + _app->world().conf().set( "human-names", - _app->world()->forge().make(_menu_human_names->get_active())); + _app->world().forge().make(_menu_human_names->get_active())); } void GraphBox::event_port_names_toggled() { - _app->world()->conf().set( + _app->world().conf().set( "port-labels", - _app->world()->forge().make(_menu_show_port_names->get_active())); + _app->world().forge().make(_menu_show_port_names->get_active())); if (_menu_show_port_names->get_active()) { _view->canvas()->set_direction(GANV_DIRECTION_RIGHT); _view->canvas()->show_port_names(true); diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 6ff2abed..47a0abcf 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -171,8 +171,8 @@ GraphCanvas::GraphCanvas(App& app, _menu_properties->signal_activate().connect( sigc::mem_fun(this, &GraphCanvas::menu_properties)); - show_human_names(app.world()->conf().option("human-names").get<int32_t>()); - show_port_names(app.world()->conf().option("port-labels").get<int32_t>()); + show_human_names(app.world().conf().option("human-names").get<int32_t>()); + show_port_names(app.world().conf().option("port-labels").get<int32_t>()); set_port_order(port_order, nullptr); } @@ -213,7 +213,7 @@ GraphCanvas::build_menus() if (_plugin_menu) { _plugin_menu->clear(); } else { - _plugin_menu = Gtk::manage(new PluginMenu(*_app.world())); + _plugin_menu = Gtk::manage(new PluginMenu(_app.world())); _menu->items().push_back( Gtk::Menu_Helpers::ImageMenuElem( "_Plugin", @@ -280,7 +280,7 @@ void GraphCanvas::show_human_names(bool b) { _human_names = b; - _app.world()->conf().set("human-names", _app.forge().make(b)); + _app.world().conf().set("human-names", _app.forge().make(b)); for_each_node(show_module_human_names, &b); } @@ -643,9 +643,9 @@ serialise_arc(GanvEdge* arc, void* data) void GraphCanvas::copy_selection() { - std::lock_guard<std::mutex> lock(_app.world()->rdf_mutex()); + std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); - Serialiser serialiser(*_app.world()); + Serialiser serialiser(_app.world()); serialiser.start_to_string(_graph->path(), _graph->base_uri()); for_each_selected_node(serialise_node, &serialiser); @@ -661,7 +661,7 @@ GraphCanvas::paste() { typedef Properties::const_iterator PropIter; - std::lock_guard<std::mutex> lock(_app.world()->rdf_mutex()); + std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); const Glib::ustring str = Gtk::Clipboard::get()->wait_for_text(); SPtr<Parser> parser = _app.loader()->parser(); @@ -678,14 +678,14 @@ GraphCanvas::paste() ++_paste_count; // Make a client store to serve as clipboard - ClientStore clipboard(_app.world()->uris(), _app.log()); + ClientStore clipboard(_app.world().uris(), _app.log()); clipboard.set_plugins(_app.store()->plugins()); clipboard.put(main_uri(), {{uris.rdf_type, Property(uris.ingen_Graph)}}); // Parse clipboard text into clipboard store boost::optional<URI> base_uri = parser->parse_string( - *_app.world(), clipboard, str, main_uri()); + _app.world(), clipboard, str, main_uri()); // Figure out the copy graph base path Raul::Path copy_root("/"); diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp index b5b234c4..a1ea6ce2 100644 --- a/src/gui/GraphPortModule.cpp +++ b/src/gui/GraphPortModule.cpp @@ -141,10 +141,10 @@ GraphPortModule::property_changed(const URI& key, const Atom& value) } } else if (value.type() == uris.forge.String) { if (key == uris.lv2_name && - app().world()->conf().option("human-names").get<int32_t>()) { + app().world().conf().option("human-names").get<int32_t>()) { set_name(value.ptr<char>()); } else if (key == uris.lv2_symbol && - !app().world()->conf().option("human-names").get<int32_t>()) { + !app().world().conf().option("human-names").get<int32_t>()) { set_name(value.ptr<char>()); } } else if (value.type() == uris.forge.Bool) { diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp index a8bbd94a..d5ffa16e 100644 --- a/src/gui/LoadGraphWindow.cpp +++ b/src/gui/LoadGraphWindow.cpp @@ -126,7 +126,7 @@ LoadGraphWindow::set_graph(SPtr<const GraphModel> graph) void LoadGraphWindow::on_show() { - const Atom& dir = _app->world()->conf().option("graph-directory"); + const Atom& dir = _app->world().conf().option("graph-directory"); if (dir.is_valid()) { set_current_folder(dir.ptr<char>()); } @@ -201,9 +201,9 @@ LoadGraphWindow::ok_clicked() _graph.reset(); hide(); - _app->world()->conf().set( + _app->world().conf().set( "graph-directory", - _app->world()->forge().alloc(get_current_folder())); + _app->world().forge().alloc(get_current_folder())); } void diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 8605e91d..ae030067 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -295,8 +295,8 @@ NodeModule::embed_gui(bool embed) void NodeModule::rename() { - if (app().world()->conf().option("port-labels").get<int32_t>() && - !app().world()->conf().option("human-names").get<int32_t>()) { + if (app().world().conf().option("port-labels").get<int32_t>() && + !app().world().conf().option("human-names").get<int32_t>()) { set_label(_block->path().symbol()); } } @@ -484,7 +484,7 @@ NodeModule::property_changed(const URI& key, const Atom& value) } } else if (value.type() == uris.forge.String) { if (key == uris.lv2_name - && app().world()->conf().option("human-names").get<int32_t>()) { + && app().world().conf().option("human-names").get<int32_t>()) { set_label(value.ptr<char>()); } } diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 60e11471..82db9a0a 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -117,8 +117,8 @@ Port::port_label(App& app, SPtr<const PortModel> pm) } std::string label; - if (app.world()->conf().option("port-labels").get<int32_t>()) { - if (app.world()->conf().option("human-names").get<int32_t>()) { + if (app.world().conf().option("port-labels").get<int32_t>()) { + if (app.world().conf().option("human-names").get<int32_t>()) { const Atom& name = pm->get_property(app.uris().lv2_name); if (name.type() == app.forge().String) { label = name.ptr<char>(); @@ -178,8 +178,8 @@ Port::show_menu(GdkEventButton* ev) void Port::moved() { - if (_app.world()->conf().option("port-labels").get<int32_t>() && - !_app.world()->conf().option("human-names").get<int32_t>()) { + if (_app.world().conf().option("port-labels").get<int32_t>() && + !_app.world().conf().option("human-names").get<int32_t>()) { set_label(model()->symbol().c_str()); } } @@ -199,7 +199,7 @@ Port::on_value_changed(double value) const Atom atom = _app.forge().make(float(value)); _app.set_property(model()->uri(), - _app.world()->uris().ingen_value, + _app.world().uris().ingen_value, atom); if (_entered) { @@ -222,8 +222,8 @@ void Port::on_scale_point_activated(float f) { _app.set_property(model()->uri(), - _app.world()->uris().ingen_value, - _app.world()->forge().make(f)); + _app.world().uris().ingen_value, + _app.world().forge().make(f)); } Gtk::Menu* @@ -249,15 +249,15 @@ void Port::on_uri_activated(const URI& uri) { _app.set_property(model()->uri(), - _app.world()->uris().ingen_value, - _app.world()->forge().make_urid( - _app.world()->uri_map().map_uri(uri.c_str()))); + _app.world().uris().ingen_value, + _app.world().forge().make_urid( + _app.world().uri_map().map_uri(uri.c_str()))); } Gtk::Menu* Port::build_uri_menu() { - World* world = _app.world(); + World& world = _app.world(); SPtr<const BlockModel> block = dynamic_ptr_cast<BlockModel>(model()->parent()); Gtk::Menu* menu = Gtk::manage(new Gtk::Menu()); @@ -269,14 +269,14 @@ Port::build_uri_menu() } LilvNode* designation = lilv_new_uri( - world->lilv_world(), world->forge().str(designation_atom, false).c_str()); + world.lilv_world(), world.forge().str(designation_atom, false).c_str()); LilvNode* rdfs_range = lilv_new_uri( - world->lilv_world(), LILV_NS_RDFS "range"); + world.lilv_world(), LILV_NS_RDFS "range"); // Get every class in the range of the port's property rdfs::URISet ranges; LilvNodes* range = lilv_world_find_nodes( - world->lilv_world(), designation, rdfs_range, nullptr); + world.lilv_world(), designation, rdfs_range, nullptr); LILV_FOREACH(nodes, r, range) { ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(range, r)))); } @@ -288,7 +288,7 @@ Port::build_uri_menu() // Add a menu item for each such class for (const auto& v : values) { if (!v.first.empty()) { - const std::string qname = world->rdf_world()->prefixes().qualify(v.second); + const std::string qname = world.rdf_world()->prefixes().qualify(v.second); const std::string label = qname + " - " + v.first; menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label)); Gtk::MenuItem* menu_item = &(menu->items().back()); @@ -482,8 +482,8 @@ Port::property_changed(const URI& key, const Atom& value) port_properties_changed(); } else if (key == uris.lv2_name) { if (value.type() == uris.forge.String && - _app.world()->conf().option("port-labels").get<int32_t>() && - _app.world()->conf().option("human-names").get<int32_t>()) { + _app.world().conf().option("port-labels").get<int32_t>() && + _app.world().conf().option("human-names").get<int32_t>()) { set_label(value.ptr<char>()); } } else if (key == uris.rdf_type || key == uris.atom_bufferType) { diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index 80565dd5..994ed224 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -102,16 +102,16 @@ PropertiesWindow::present(SPtr<const ObjectModel> model) void PropertiesWindow::add_property(const URI& key, const Atom& value) { - World* world = _app->world(); + World& world = _app->world(); const unsigned n_rows = _table->property_n_rows() + 1; _table->property_n_rows() = n_rows; // Column 0: Property - LilvNode* prop = lilv_new_uri(world->lilv_world(), key.c_str()); + LilvNode* prop = lilv_new_uri(world.lilv_world(), key.c_str()); std::string name = rdfs::label(world, prop); if (name.empty()) { - name = world->rdf_world()->prefixes().qualify(key); + name = world.rdf_world()->prefixes().qualify(key); } Gtk::Label* label = new Gtk::Label( std::string("<a href=\"") + key.string() + "\">" + name + "</a>", @@ -125,7 +125,7 @@ PropertiesWindow::add_property(const URI& key, const Atom& value) // Column 1: Value Gtk::Alignment* align = manage(new Gtk::Alignment(0.0, 0.5, 1.0, 1.0)); Gtk::CheckButton* present = manage(new Gtk::CheckButton()); - const char* type = _app->world()->uri_map().unmap_uri(value.type()); + const char* type = _app->world().uri_map().unmap_uri(value.type()); Gtk::Widget* val_widget = create_value_widget(key, type, value); present->set_active(); @@ -171,14 +171,13 @@ PropertiesWindow::datatype_supported(const rdfs::URISet& types, bool PropertiesWindow::class_supported(const rdfs::URISet& types) { - World* world = _app->world(); - LilvNode* rdf_type = lilv_new_uri( - world->lilv_world(), LILV_NS_RDF "type"); + World& world = _app->world(); + LilvNode* rdf_type = lilv_new_uri(world.lilv_world(), LILV_NS_RDF "type"); for (const auto& t : types) { - LilvNode* range = lilv_new_uri(world->lilv_world(), t.c_str()); + LilvNode* range = lilv_new_uri(world.lilv_world(), t.c_str()); LilvNodes* instances = lilv_world_find_nodes( - world->lilv_world(), nullptr, rdf_type, range); + world.lilv_world(), nullptr, rdf_type, range); const bool has_instance = (lilv_nodes_size(instances) > 0); @@ -205,18 +204,18 @@ PropertiesWindow::set_object(SPtr<const ObjectModel> model) set_title(model->path() + " Properties - Ingen"); - World* world = _app->world(); + World& world = _app->world(); LilvNode* rdf_type = lilv_new_uri( - world->lilv_world(), LILV_NS_RDF "type"); + world.lilv_world(), LILV_NS_RDF "type"); LilvNode* rdfs_DataType = lilv_new_uri( - world->lilv_world(), LILV_NS_RDFS "Datatype"); + world.lilv_world(), LILV_NS_RDFS "Datatype"); // Populate key combo const URISet props = rdfs::properties(world, model); std::map<std::string, URI> entries; for (const auto& p : props) { - LilvNode* prop = lilv_new_uri(world->lilv_world(), p.c_str()); + LilvNode* prop = lilv_new_uri(world.lilv_world(), p.c_str()); const std::string label = rdfs::label(world, prop); URISet ranges = rdfs::range(world, prop, true); @@ -226,7 +225,7 @@ PropertiesWindow::set_object(SPtr<const ObjectModel> model) continue; } - LilvNode* range = lilv_new_uri(world->lilv_world(), (*ranges.begin()).c_str()); + LilvNode* range = lilv_new_uri(world.lilv_world(), (*ranges.begin()).c_str()); if (rdfs::is_a(world, range, rdfs_DataType)) { // Range is a datatype, show if type or any subtype is supported rdfs::datatypes(_app->world(), ranges, false); @@ -274,18 +273,18 @@ PropertiesWindow::create_value_widget(const URI& key, } URI type(type_uri); - ingen::World* world = _app->world(); - LilvWorld* lworld = world->lilv_world(); + ingen::World& world = _app->world(); + LilvWorld* lworld = world.lilv_world(); // See if type is a datatype we support std::set<URI> types{type}; - rdfs::datatypes(_app->world(), types, false); + rdfs::datatypes(world, types, false); URI widget_type("urn:nothing"); const bool supported = datatype_supported(types, &widget_type); if (supported) { type = widget_type; - _value_type = _app->world()->uri_map().map_uri(type); + _value_type = world.uri_map().map_uri(type); } if (type == _app->uris().atom_Int) { @@ -329,7 +328,7 @@ PropertiesWindow::create_value_widget(const URI& key, return widget; } else if (type == _app->uris().atom_URID) { const char* str = (value.is_valid() - ? world->uri_map().unmap_uri(value.get<int32_t>()) + ? world.uri_map().unmap_uri(value.get<int32_t>()) : ""); LilvNode* pred = lilv_new_uri(lworld, key.c_str()); @@ -402,7 +401,7 @@ PropertiesWindow::change_property(const URI& key, const Atom& value) } Record& record = r->second; - const char* type = _app->world()->uri_map().unmap_uri(value.type()); + const char* type = _app->world().uri_map().unmap_uri(value.type()); Gtk::Widget* val_widget = create_value_widget(key, type, value); if (val_widget) { @@ -505,7 +504,7 @@ PropertiesWindow::key_changed() return; } - LilvWorld* lworld = _app->world()->lilv_world(); + LilvWorld* lworld = _app->world().lilv_world(); const Gtk::ListStore::Row key_row = *(_key_combo->get_active()); const Glib::ustring key_uri = key_row[_combo_columns.uri_col]; LilvNode* prop = lilv_new_uri(lworld, key_uri.c_str()); diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index 4ff26914..1ce3618d 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -28,12 +28,12 @@ namespace gui { namespace rdfs { std::string -label(World* world, const LilvNode* node) +label(World& world, const LilvNode* node) { LilvNode* rdfs_label = lilv_new_uri( - world->lilv_world(), LILV_NS_RDFS "label"); + world.lilv_world(), LILV_NS_RDFS "label"); LilvNodes* labels = lilv_world_find_nodes( - world->lilv_world(), node, rdfs_label, nullptr); + world.lilv_world(), node, rdfs_label, nullptr); const LilvNode* first = lilv_nodes_get_first(labels); std::string label = first ? lilv_node_as_string(first) : ""; @@ -44,12 +44,12 @@ label(World* world, const LilvNode* node) } std::string -comment(World* world, const LilvNode* node) +comment(World& world, const LilvNode* node) { LilvNode* rdfs_comment = lilv_new_uri( - world->lilv_world(), LILV_NS_RDFS "comment"); + world.lilv_world(), LILV_NS_RDFS "comment"); LilvNodes* comments = lilv_world_find_nodes( - world->lilv_world(), node, rdfs_comment, nullptr); + world.lilv_world(), node, rdfs_comment, nullptr); const LilvNode* first = lilv_nodes_get_first(comments); std::string comment = first ? lilv_node_as_string(first) : ""; @@ -60,19 +60,19 @@ comment(World* world, const LilvNode* node) } static void -closure(World* world, const LilvNode* pred, URISet& types, bool super) +closure(World& world, const LilvNode* pred, URISet& types, bool super) { unsigned added = 0; do { added = 0; URISet klasses; for (const auto& t : types) { - LilvNode* type = lilv_new_uri(world->lilv_world(), t.c_str()); + LilvNode* type = lilv_new_uri(world.lilv_world(), t.c_str()); LilvNodes* matches = (super) ? lilv_world_find_nodes( - world->lilv_world(), type, pred, nullptr) + world.lilv_world(), type, pred, nullptr) : lilv_world_find_nodes( - world->lilv_world(), nullptr, pred, type); + world.lilv_world(), nullptr, pred, type); LILV_FOREACH(nodes, m, matches) { const LilvNode* klass_node = lilv_nodes_get(matches, m); if (lilv_node_is_uri(klass_node)) { @@ -91,10 +91,10 @@ closure(World* world, const LilvNode* pred, URISet& types, bool super) } void -classes(World* world, URISet& types, bool super) +classes(World& world, URISet& types, bool super) { LilvNode* rdfs_subClassOf = lilv_new_uri( - world->lilv_world(), LILV_NS_RDFS "subClassOf"); + world.lilv_world(), LILV_NS_RDFS "subClassOf"); closure(world, rdfs_subClassOf, types, super); @@ -102,10 +102,10 @@ classes(World* world, URISet& types, bool super) } void -datatypes(World* world, URISet& types, bool super) +datatypes(World& world, URISet& types, bool super) { LilvNode* owl_onDatatype = lilv_new_uri( - world->lilv_world(), LILV_NS_OWL "onDatatype"); + world.lilv_world(), LILV_NS_OWL "onDatatype"); closure(world, owl_onDatatype, types, super); @@ -113,7 +113,7 @@ datatypes(World* world, URISet& types, bool super) } URISet -types(World* world, SPtr<const client::ObjectModel> model) +types(World& world, SPtr<const client::ObjectModel> model) { typedef Properties::const_iterator PropIter; typedef std::pair<PropIter, PropIter> PropRange; @@ -121,18 +121,18 @@ types(World* world, SPtr<const client::ObjectModel> model) // Start with every rdf:type URISet types; types.insert(URI(LILV_NS_RDFS "Resource")); - PropRange range = model->properties().equal_range(world->uris().rdf_type); + PropRange range = model->properties().equal_range(world.uris().rdf_type); for (auto t = range.first; t != range.second; ++t) { - if (t->second.type() == world->forge().URI || - t->second.type() == world->forge().URID) { - const URI type(world->forge().str(t->second, false)); + if (t->second.type() == world.forge().URI || + t->second.type() == world.forge().URID) { + const URI type(world.forge().str(t->second, false)); types.insert(type); - if (world->uris().ingen_Graph == type) { + if (world.uris().ingen_Graph == type) { // Add lv2:Plugin as a type for graphs so plugin properties show up - types.insert(world->uris().lv2_Plugin); + types.insert(world.uris().lv2_Plugin); } } else { - world->log().error(fmt("<%1%> has non-URI type\n") % model->uri()); + world.log().error(fmt("<%1%> has non-URI type\n") % model->uri()); } } @@ -143,25 +143,25 @@ types(World* world, SPtr<const client::ObjectModel> model) } URISet -properties(World* world, SPtr<const client::ObjectModel> model) +properties(World& world, SPtr<const client::ObjectModel> model) { URISet properties; URISet types = rdfs::types(world, model); - LilvNode* rdf_type = lilv_new_uri(world->lilv_world(), + LilvNode* rdf_type = lilv_new_uri(world.lilv_world(), LILV_NS_RDF "type"); - LilvNode* rdf_Property = lilv_new_uri(world->lilv_world(), + LilvNode* rdf_Property = lilv_new_uri(world.lilv_world(), LILV_NS_RDF "Property"); - LilvNode* rdfs_domain = lilv_new_uri(world->lilv_world(), + LilvNode* rdfs_domain = lilv_new_uri(world.lilv_world(), LILV_NS_RDFS "domain"); LilvNodes* props = lilv_world_find_nodes( - world->lilv_world(), nullptr, rdf_type, rdf_Property); + world.lilv_world(), nullptr, rdf_type, rdf_Property); LILV_FOREACH(nodes, p, props) { const LilvNode* prop = lilv_nodes_get(props, p); if (lilv_node_is_uri(prop)) { LilvNodes* domains = lilv_world_find_nodes( - world->lilv_world(), prop, rdfs_domain, nullptr); + world.lilv_world(), prop, rdfs_domain, nullptr); unsigned n_matching_domains = 0; LILV_FOREACH(nodes, d, domains) { const LilvNode* domain_node = lilv_nodes_get(domains, d); @@ -194,16 +194,16 @@ properties(World* world, SPtr<const client::ObjectModel> model) } Objects -instances(World* world, const URISet& types) +instances(World& world, const URISet& types) { LilvNode* rdf_type = lilv_new_uri( - world->lilv_world(), LILV_NS_RDF "type"); + world.lilv_world(), LILV_NS_RDF "type"); Objects result; for (const auto& t : types) { - LilvNode* type = lilv_new_uri(world->lilv_world(), t.c_str()); + LilvNode* type = lilv_new_uri(world.lilv_world(), t.c_str()); LilvNodes* objects = lilv_world_find_nodes( - world->lilv_world(), nullptr, rdf_type, type); + world.lilv_world(), nullptr, rdf_type, type); LILV_FOREACH(nodes, o, objects) { const LilvNode* object = lilv_nodes_get(objects, o); if (!lilv_node_is_uri(object)) { @@ -220,13 +220,13 @@ instances(World* world, const URISet& types) } URISet -range(World* world, const LilvNode* prop, bool recursive) +range(World& world, const LilvNode* prop, bool recursive) { LilvNode* rdfs_range = lilv_new_uri( - world->lilv_world(), LILV_NS_RDFS "range"); + world.lilv_world(), LILV_NS_RDFS "range"); LilvNodes* nodes = lilv_world_find_nodes( - world->lilv_world(), prop, rdfs_range, nullptr); + world.lilv_world(), prop, rdfs_range, nullptr); URISet ranges; LILV_FOREACH(nodes, n, nodes) { @@ -243,12 +243,12 @@ range(World* world, const LilvNode* prop, bool recursive) } bool -is_a(World* world, const LilvNode* inst, const LilvNode* klass) +is_a(World& world, const LilvNode* inst, const LilvNode* klass) { - LilvNode* rdf_type = lilv_new_uri(world->lilv_world(), LILV_NS_RDF "type"); + LilvNode* rdf_type = lilv_new_uri(world.lilv_world(), LILV_NS_RDF "type"); const bool is_instance = lilv_world_ask( - world->lilv_world(), inst, rdf_type, klass); + world.lilv_world(), inst, rdf_type, klass); lilv_node_free(rdf_type); return is_instance; diff --git a/src/gui/RDFS.hpp b/src/gui/RDFS.hpp index 8de9076d..ee1133f5 100644 --- a/src/gui/RDFS.hpp +++ b/src/gui/RDFS.hpp @@ -41,37 +41,37 @@ typedef std::set<URI> URISet; typedef std::map<std::string, URI> Objects; /** Return the label of `node`. */ -std::string label(World* world, const LilvNode* node); +std::string label(World& world, const LilvNode* node); /** Return the comment of `node`. */ -std::string comment(World* world, const LilvNode* node); +std::string comment(World& world, const LilvNode* node); /** Set `types` to its super/sub class closure. * @param super If true, find all superclasses, otherwise all subclasses */ -void classes(World* world, URISet& types, bool super); +void classes(World& world, URISet& types, bool super); /** Set `types` to its super/sub datatype closure. * @param super If true, find all supertypes, otherwise all subtypes. */ -void datatypes(World* world, URISet& types, bool super); +void datatypes(World& world, URISet& types, bool super); /** Get all instances of any class in `types`. */ -Objects instances(World* world, const URISet& types); +Objects instances(World& world, const URISet& types); /** Get all the types which `model` is an instance of. */ -URISet types(World* world, SPtr<const client::ObjectModel> model); +URISet types(World& world, SPtr<const client::ObjectModel> model); /** Get all the properties with domains appropriate for `model`. */ -URISet properties(World* world, SPtr<const client::ObjectModel> model); +URISet properties(World& world, SPtr<const client::ObjectModel> model); /** Return the range (value types) of `prop`. * @param recursive If true, include all subclasses. */ -URISet range(World* world, const LilvNode* prop, bool recursive); +URISet range(World& world, const LilvNode* prop, bool recursive); /** Return true iff `inst` is-a `klass`. */ -bool is_a(World* world, const LilvNode* inst, const LilvNode* klass); +bool is_a(World& world, const LilvNode* inst, const LilvNode* klass); } // namespace rdfs } // namespace gui diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index a7115de6..c9d30c31 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -54,7 +54,7 @@ ThreadedLoader::~ThreadedLoader() SPtr<Parser> ThreadedLoader::parser() { - return _app.world()->parser(); + return _app.world().parser(); } void @@ -103,14 +103,14 @@ ThreadedLoader::load_graph_event(const FilePath& file_path, optional<Raul::Symbol> engine_symbol, optional<Properties> engine_data) { - std::lock_guard<std::mutex> lock(_app.world()->rdf_mutex()); - - _app.world()->parser()->parse_file(*_app.world(), - *_app.world()->interface(), - file_path, - engine_parent, - engine_symbol, - engine_data); + std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); + + _app.world().parser()->parse_file(_app.world(), + *_app.world().interface(), + file_path, + engine_parent, + engine_symbol, + engine_data); } void @@ -132,7 +132,7 @@ ThreadedLoader::save_graph_event(SPtr<const client::GraphModel> model, { assert(uri.scheme() == "file"); if (_app.serialiser()) { - std::lock_guard<std::mutex> lock(_app.world()->rdf_mutex()); + std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); if (uri.string().find(".ingen") != std::string::npos) { _app.serialiser()->write_bundle(model, uri); diff --git a/src/gui/URIEntry.cpp b/src/gui/URIEntry.cpp index 97099b46..0004839f 100644 --- a/src/gui/URIEntry.cpp +++ b/src/gui/URIEntry.cpp @@ -42,8 +42,8 @@ URIEntry::URIEntry(App* app, std::set<URI> types, const std::string& value) Gtk::Menu* URIEntry::build_value_menu() { - World* world = _app->world(); - LilvWorld* lworld = world->lilv_world(); + World& world = _app->world(); + LilvWorld* lworld = world.lilv_world(); Gtk::Menu* menu = new Gtk::Menu(); LilvNode* owl_onDatatype = lilv_new_uri(lworld, LILV_NS_OWL "onDatatype"); @@ -62,8 +62,8 @@ URIEntry::build_value_menu() label = lilv_node_as_string(inst); } - if (lilv_world_ask(world->lilv_world(), inst, rdf_type, rdfs_Class) || - lilv_world_ask(world->lilv_world(), inst, rdf_type, rdfs_Datatype)) { + if (lilv_world_ask(world.lilv_world(), inst, rdf_type, rdfs_Class) || + lilv_world_ask(world.lilv_world(), inst, rdf_type, rdfs_Datatype)) { // This value is a class or datatype... if (!lilv_world_ask(lworld, inst, rdfs_subClassOf, nullptr) && !lilv_world_ask(lworld, inst, owl_onDatatype, nullptr)) { @@ -93,8 +93,8 @@ URIEntry::build_value_menu() Gtk::Menu* URIEntry::build_subclass_menu(const LilvNode* klass) { - World* world = _app->world(); - LilvWorld* lworld = world->lilv_world(); + World& world = _app->world(); + LilvWorld* lworld = world.lilv_world(); LilvNode* owl_onDatatype = lilv_new_uri(lworld, LILV_NS_OWL "onDatatype"); LilvNode* rdfs_subClassOf = lilv_new_uri(lworld, LILV_NS_RDFS "subClassOf"); diff --git a/src/gui/ingen_gui.cpp b/src/gui/ingen_gui.cpp index 441993f7..4504d3fe 100644 --- a/src/gui/ingen_gui.cpp +++ b/src/gui/ingen_gui.cpp @@ -27,26 +27,26 @@ namespace gui { struct GUIModule : public Module { using SigClientInterface = client::SigClientInterface; - void load(World* world) override { - URI uri(world->conf().option("connect").ptr<char>()); - if (!world->interface()) { - world->set_interface( - world->new_interface(URI(uri), make_client(world))); + void load(World& world) override { + URI uri(world.conf().option("connect").ptr<char>()); + if (!world.interface()) { + world.set_interface( + world.new_interface(URI(uri), make_client(world))); } else if (!dynamic_ptr_cast<SigClientInterface>( - world->interface()->respondee())) { - world->interface()->set_respondee(make_client(world)); + world.interface()->respondee())) { + world.interface()->set_respondee(make_client(world)); } app = gui::App::create(world); } - void run(World* world) override { + void run(World& world) override { app->run(); } - SPtr<Interface> make_client(World* const world) { + SPtr<Interface> make_client(World& world) { SPtr<SigClientInterface> sci(new SigClientInterface()); - return world->engine() ? sci : SPtr<Interface>(new QueuedInterface(sci)); + return world.engine() ? sci : SPtr<Interface>(new QueuedInterface(sci)); } SPtr<gui::App> app; diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp index 251c75e1..f89e0436 100644 --- a/src/gui/ingen_gui_lv2.cpp +++ b/src/gui/ingen_gui_lv2.cpp @@ -131,7 +131,7 @@ instantiate(const LV2UI_Descriptor* descriptor, ui->world->set_interface(ui->engine); // Create App and client - ui->app = ingen::gui::App::create(ui->world); + ui->app = ingen::gui::App::create(*ui->world); ui->client = SPtr<ingen::client::SigClientInterface>( new ingen::client::SigClientInterface()); ui->app->set_is_plugin(true); |