summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-11 03:01:26 +0000
committerDavid Robillard <d@drobilla.net>2012-05-11 03:01:26 +0000
commit7be6d5d05756a7dea20c494d56f364b4dc064c88 (patch)
tree4e1bd5d2c9a1d3b23a88b3a4960349c389d1f89a /src/shared
parente77d4fcf31bfdad0b34e184e4743b4750848472c (diff)
downloadingen-7be6d5d05756a7dea20c494d56f364b4dc064c88.tar.gz
ingen-7be6d5d05756a7dea20c494d56f364b4dc064c88.tar.bz2
ingen-7be6d5d05756a7dea20c494d56f364b4dc064c88.zip
Clean up and better document World interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4344 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/Builder.cpp17
-rw-r--r--src/shared/World.cpp92
2 files changed, 49 insertions, 60 deletions
diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp
index 68d7ab08..c79181ff 100644
--- a/src/shared/Builder.cpp
+++ b/src/shared/Builder.cpp
@@ -30,7 +30,7 @@ using namespace std;
namespace Ingen {
namespace Shared {
-Builder::Builder(SharedPtr<Shared::URIs> uris, Interface& interface)
+Builder::Builder(Shared::URIs& uris, Interface& interface)
: _uris(uris)
, _interface(interface)
{
@@ -39,15 +39,14 @@ Builder::Builder(SharedPtr<Shared::URIs> uris, Interface& interface)
void
Builder::build(SharedPtr<const GraphObject> object)
{
- const URIs& uris = *_uris.get();
SharedPtr<const Patch> patch = PtrCast<const Patch>(object);
if (patch) {
if (!object->path().is_root()) {
Resource::Properties props;
- props.insert(make_pair(uris.rdf_type,
- _uris->forge.alloc_uri(uris.ingen_Patch.str())));
- props.insert(make_pair(uris.ingen_polyphony,
- _uris->forge.make(int32_t(patch->internal_poly()))));
+ props.insert(make_pair(_uris.rdf_type,
+ _uris.forge.alloc_uri(_uris.ingen_Patch.str())));
+ props.insert(make_pair(_uris.ingen_polyphony,
+ _uris.forge.make(int32_t(patch->internal_poly()))));
_interface.put(object->path(), props);
}
@@ -62,9 +61,9 @@ Builder::build(SharedPtr<const GraphObject> object)
SharedPtr<const Node> node = PtrCast<const Node>(object);
if (node) {
Resource::Properties props;
- props.insert(make_pair(uris.rdf_type, uris.ingen_Node));
- props.insert(make_pair(uris.ingen_prototype,
- _uris->forge.alloc_uri(node->plugin()->uri().str())));
+ props.insert(make_pair(_uris.rdf_type, _uris.ingen_Node));
+ props.insert(make_pair(_uris.ingen_prototype,
+ _uris.forge.alloc_uri(node->plugin()->uri().str())));
_interface.put(node->path(), props);
build_object(object);
return;
diff --git a/src/shared/World.cpp b/src/shared/World.cpp
index 1012a157..9873246f 100644
--- a/src/shared/World.cpp
+++ b/src/shared/World.cpp
@@ -14,25 +14,23 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <boost/utility.hpp>
-
-#include <glibmm/module.h>
-#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
+#include <glibmm/miscutils.h>
+#include <glibmm/module.h>
-#include "lilv/lilv.h"
-#include "raul/log.hpp"
-#include "raul/Atom.hpp"
-#include "sord/sordmm.hpp"
-
-#include "ingen/Interface.hpp"
#include "ingen/EngineBase.hpp"
-#include "ingen/shared/Module.hpp"
-#include "ingen/shared/World.hpp"
-#include "ingen/shared/runtime_paths.hpp"
+#include "ingen/Interface.hpp"
+#include "ingen/shared/Configuration.hpp"
#include "ingen/shared/LV2Features.hpp"
+#include "ingen/shared/Module.hpp"
#include "ingen/shared/URIMap.hpp"
#include "ingen/shared/URIs.hpp"
+#include "ingen/shared/World.hpp"
+#include "ingen/shared/runtime_paths.hpp"
+#include "lilv/lilv.h"
+#include "raul/Atom.hpp"
+#include "raul/log.hpp"
+#include "sord/sordmm.hpp"
#define LOG(s) (s("[World] "))
@@ -96,19 +94,19 @@ ingen_load_module(const string& name)
}
}
-class World::Pimpl {
+class World::Impl {
public:
- Pimpl(int& a_argc,
- char**& a_argv,
- LV2_URID_Map* map,
- LV2_URID_Unmap* unmap)
+ Impl(int& a_argc,
+ char**& a_argv,
+ LV2_URID_Map* map,
+ LV2_URID_Unmap* unmap)
: argc(a_argc)
, argv(a_argv)
, lv2_features(NULL)
, rdf_world(new Sord::World())
- , uri_map(new Ingen::Shared::URIMap(map, unmap))
, forge(new Ingen::Forge(*uri_map))
- , uris(new Shared::URIs(*forge, uri_map.get()))
+ , uri_map(new Ingen::Shared::URIMap(map, unmap))
+ , uris(new Shared::URIs(*forge, uri_map))
, lilv_world(lilv_world_new())
{
conf.parse(argc, argv);
@@ -130,7 +128,7 @@ public:
rdf_world->add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
}
- virtual ~Pimpl()
+ virtual ~Impl()
{
serialiser.reset();
parser.reset();
@@ -143,17 +141,12 @@ public:
script_runners.clear();
lilv_world_free(lilv_world);
- lilv_world = NULL;
delete rdf_world;
- rdf_world = NULL;
-
delete lv2_features;
- lv2_features = NULL;
-
delete forge;
-
- uris.reset();
+ delete uri_map;
+ delete uris;
}
typedef std::map< const std::string, SharedPtr<Module> > Modules;
@@ -171,9 +164,9 @@ public:
Shared::Configuration conf;
LV2Features* lv2_features;
Sord::World* rdf_world;
- SharedPtr<URIMap> uri_map;
Ingen::Forge* forge;
- SharedPtr<URIs> uris;
+ URIMap* uri_map;
+ URIs* uris;
SharedPtr<Interface> interface;
SharedPtr<EngineBase> engine;
SharedPtr<Serialisation::Serialiser> serialiser;
@@ -187,7 +180,7 @@ World::World(int& argc,
char**& argv,
LV2_URID_Map* map,
LV2_URID_Unmap* unmap)
- : _impl(new Pimpl(argc, argv, map, unmap))
+ : _impl(new Impl(argc, argv, map, unmap))
{
}
@@ -199,33 +192,32 @@ World::~World()
void World::set_engine(SharedPtr<EngineBase> e) { _impl->engine = e; }
void World::set_interface(SharedPtr<Interface> i) { _impl->interface = i; }
-void World::set_serialiser(SharedPtr<Serialisation::Serialiser> s) { _impl->serialiser = s; }
void World::set_parser(SharedPtr<Serialisation::Parser> p) { _impl->parser = p; }
+void World::set_serialiser(SharedPtr<Serialisation::Serialiser> s) { _impl->serialiser = s; }
void World::set_store(SharedPtr<Store> s) { _impl->store = s; }
-int& World::argc() { return _impl->argc; }
-char**& World::argv() { return _impl->argv; }
SharedPtr<EngineBase> World::engine() { return _impl->engine; }
SharedPtr<Interface> World::interface() { return _impl->interface; }
-SharedPtr<Serialisation::Serialiser> World::serialiser() { return _impl->serialiser; }
SharedPtr<Serialisation::Parser> World::parser() { return _impl->parser; }
+SharedPtr<Serialisation::Serialiser> World::serialiser() { return _impl->serialiser; }
SharedPtr<Store> World::store() { return _impl->store; }
-Shared::Configuration& World::conf() { return _impl->conf; }
-Ingen::Forge& World::forge() { return *_impl->forge; }
-LV2Features* World::lv2_features() { return _impl->lv2_features; }
-LilvWorld* World::lilv_world() { return _impl->lilv_world; }
-Sord::World* World::rdf_world() { return _impl->rdf_world; }
-SharedPtr<URIs> World::uris() { return _impl->uris; }
-SharedPtr<URIMap> World::uri_map() { return _impl->uri_map; }
+int& World::argc() { return _impl->argc; }
+char**& World::argv() { return _impl->argv; }
+Shared::Configuration& World::conf() { return _impl->conf; }
+
+Sord::World* World::rdf_world() { return _impl->rdf_world; }
+LilvWorld* World::lilv_world() { return _impl->lilv_world; }
+
+LV2Features& World::lv2_features() { return *_impl->lv2_features; }
+Ingen::Forge& World::forge() { return *_impl->forge; }
+URIs& World::uris() { return *_impl->uris; }
+URIMap& World::uri_map() { return *_impl->uri_map; }
-/** Load an Ingen module.
- * @return true on success, false on failure
- */
bool
World::load_module(const char* name)
{
- Pimpl::Modules::iterator i = _impl->modules.find(name);
+ Impl::Modules::iterator i = _impl->modules.find(name);
if (i != _impl->modules.end()) {
LOG(Raul::info)(Raul::fmt("Module `%1%' already loaded\n") % name);
return true;
@@ -247,7 +239,7 @@ World::load_module(const char* name)
bool
World::run_module(const char* name)
{
- Pimpl::Modules::iterator i = _impl->modules.find(name);
+ Impl::Modules::iterator i = _impl->modules.find(name);
if (i == _impl->modules.end()) {
LOG(Raul::error) << "Attempt to run unloaded module `" << name << "'" << endl;
return false;
@@ -257,8 +249,6 @@ World::run_module(const char* name)
return true;
}
-/** Unload all loaded Ingen modules.
- */
void
World::unload_modules()
{
@@ -272,7 +262,7 @@ World::new_interface(const std::string& engine_url,
SharedPtr<Interface> respondee)
{
const string scheme = engine_url.substr(0, engine_url.find(":"));
- const Pimpl::InterfaceFactories::const_iterator i = _impl->interface_factories.find(scheme);
+ const Impl::InterfaceFactories::const_iterator i = _impl->interface_factories.find(scheme);
if (i == _impl->interface_factories.end()) {
Raul::warn << "Unknown URI scheme `" << scheme << "'" << endl;
return SharedPtr<Interface>();
@@ -285,7 +275,7 @@ World::new_interface(const std::string& engine_url,
bool
World::run(const std::string& mime_type, const std::string& filename)
{
- const Pimpl::ScriptRunners::const_iterator i = _impl->script_runners.find(mime_type);
+ const Impl::ScriptRunners::const_iterator i = _impl->script_runners.find(mime_type);
if (i == _impl->script_runners.end()) {
Raul::warn << "Unknown script MIME type `" << mime_type << "'" << endl;
return false;