summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/Builder.cpp14
-rw-r--r--src/shared/ClashAvoider.cpp8
-rw-r--r--src/shared/LV2Features.cpp3
-rw-r--r--src/shared/LV2Features.hpp8
-rw-r--r--src/shared/LV2Object.cpp22
-rw-r--r--src/shared/LV2URIMap.cpp51
-rw-r--r--src/shared/LV2URIMap.hpp59
-rw-r--r--src/shared/ResourceImpl.hpp4
8 files changed, 112 insertions, 57 deletions
diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp
index 37c193fb..fd94ddd0 100644
--- a/src/shared/Builder.cpp
+++ b/src/shared/Builder.cpp
@@ -16,13 +16,16 @@
*/
#include "raul/Atom.hpp"
-#include "Builder.hpp"
#include "common/interface/CommonInterface.hpp"
#include "common/interface/Patch.hpp"
#include "common/interface/Node.hpp"
#include "common/interface/Port.hpp"
#include "common/interface/Connection.hpp"
#include "common/interface/Plugin.hpp"
+#include "module/ingen_module.hpp"
+#include "module/World.hpp"
+#include "shared/LV2URIMap.hpp"
+#include "Builder.hpp"
using namespace std;
using namespace Raul;
@@ -40,12 +43,13 @@ Builder::Builder(CommonInterface& interface)
void
Builder::build(SharedPtr<const GraphObject> object)
{
+ const LV2URIMap& uris = *ingen_get_world()->uris.get();
SharedPtr<const Patch> patch = PtrCast<const Patch>(object);
if (patch) {
if (!object->path().is_root()) {
Resource::Properties props;
- props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Patch")));
- props.insert(make_pair("ingen:polyphony", Atom(int32_t(patch->internal_polyphony()))));
+ props.insert(make_pair(uris.rdf_type, uris.ingen_Patch));
+ props.insert(make_pair(uris.ingen_polyphony, Atom(int32_t(patch->internal_polyphony()))));
_interface.put(object->path(), props);
}
@@ -60,8 +64,8 @@ Builder::build(SharedPtr<const GraphObject> object)
SharedPtr<const Node> node = PtrCast<const Node>(object);
if (node) {
Resource::Properties props;
- props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Node")));
- props.insert(make_pair("rdf:instanceOf", Atom(Atom::URI, node->plugin()->uri().str())));
+ props.insert(make_pair(uris.rdf_type, uris.ingen_Node));
+ props.insert(make_pair(uris.rdf_instanceOf, node->plugin()->uri()));
_interface.put(node->path(), props);
build_object(object);
return;
diff --git a/src/shared/ClashAvoider.cpp b/src/shared/ClashAvoider.cpp
index f5777e04..a3e54957 100644
--- a/src/shared/ClashAvoider.cpp
+++ b/src/shared/ClashAvoider.cpp
@@ -45,9 +45,9 @@ ClashAvoider::map_path(const Raul::Path& in)
unsigned offset = 0;
bool has_offset = false;
- size_t pos = in.find_last_of("_");
+ const size_t pos = in.find_last_of('_');
if (pos != string::npos && pos != (in.length()-1)) {
- const std::string trailing = in.substr(in.find_last_of("_")+1);
+ const std::string trailing = in.substr(pos + 1);
has_offset = (sscanf(trailing.c_str(), "%u", &offset) > 0);
}
@@ -56,7 +56,7 @@ ClashAvoider::map_path(const Raul::Path& in)
// Path without _n suffix
Path base_path = in;
if (has_offset)
- base_path = base_path.substr(0, base_path.find_last_of("_"));
+ base_path = base_path.substr(0, base_path.find_last_of('_'));
debug << "BASE: " << base_path << endl;
@@ -108,7 +108,7 @@ ClashAvoider::map_path(const Raul::Path& in)
std::stringstream ss;
ss << base_path << "_" << offset;
if (!exists(ss.str())) {
- const string name = (base_path.length() > 1) ? base_path.name() : "_";
+ const string name = (base_path.length() > 1) ? base_path.symbol() : "_";
string str = ss.str();
InsertRecord i = _symbol_map.insert(make_pair(in, str));
debug << "HIT: offset = " << offset << ", str = " << str << endl;
diff --git a/src/shared/LV2Features.cpp b/src/shared/LV2Features.cpp
index b57f1117..5088d6e0 100644
--- a/src/shared/LV2Features.cpp
+++ b/src/shared/LV2Features.cpp
@@ -27,10 +27,7 @@ namespace Shared {
LV2Features::LV2Features()
-// : _lv2_features((LV2_Feature**)malloc(sizeof(LV2_Feature*)))
{
-// _lv2_features[0] = NULL;
-
add_feature(LV2_URI_MAP_URI, SharedPtr<Feature>(new LV2URIMap()));
}
diff --git a/src/shared/LV2Features.hpp b/src/shared/LV2Features.hpp
index 84b737f6..ff6d7b1d 100644
--- a/src/shared/LV2Features.hpp
+++ b/src/shared/LV2Features.hpp
@@ -18,16 +18,12 @@
#ifndef INGEN_SHARED_LV2FEATURES_HPP
#define INGEN_SHARED_LV2FEATURES_HPP
-#include "ingen-config.h"
-#ifndef HAVE_SLV2
-#error "This file requires SLV2, but HAVE_SLV2 is not defined. Please report."
-#endif
-
#include <map>
#include <string>
#include <vector>
-#include "slv2/slv2.h"
+#include "lv2.h"
#include "raul/SharedPtr.hpp"
+#include "ingen-config.h"
namespace Ingen {
namespace Shared {
diff --git a/src/shared/LV2Object.cpp b/src/shared/LV2Object.cpp
index 16e8ff71..193e2c1d 100644
--- a/src/shared/LV2Object.cpp
+++ b/src/shared/LV2Object.cpp
@@ -35,18 +35,18 @@ namespace LV2Object {
bool
to_atom(World* world, const LV2_Object* object, Raul::Atom& atom)
{
- SharedPtr<LV2URIMap> map = PtrCast<LV2URIMap>(world->lv2_features->feature(LV2_URI_MAP_URI));
+ SharedPtr<LV2URIMap> uris = world->uris;
- if (object->type == map->object_class_string) {
+ if (object->type == uris->object_class_string.id) {
atom = Raul::Atom((char*)(object + 1));
return true;
- } else if (object->type == map->object_class_bool) {
+ } else if (object->type == uris->object_class_bool.id) {
atom = Raul::Atom((bool)(int32_t*)(object + 1));
return true;
- } else if (object->type == map->object_class_int32) {
+ } else if (object->type == uris->object_class_int32.id) {
atom = Raul::Atom((int32_t*)(object + 1));
return true;
- } else if (object->type == map->object_class_float32) {
+ } else if (object->type == uris->object_class_float32.id) {
atom = Raul::Atom((float*)(object + 1));
return true;
}
@@ -60,22 +60,22 @@ to_atom(World* world, const LV2_Object* object, Raul::Atom& atom)
bool
from_atom(World* world, const Raul::Atom& atom, LV2_Object* object)
{
- SharedPtr<LV2URIMap> map = PtrCast<LV2URIMap>(world->lv2_features->feature(LV2_URI_MAP_URI));
+ SharedPtr<LV2URIMap> uris = world->uris;
char* str;
switch (atom.type()) {
case Raul::Atom::FLOAT:
- object->type = map->object_class_float32;
+ object->type = uris->object_class_float32.id;
object->size = sizeof(float);
*(float*)(object + 1) = atom.get_float();
break;
case Raul::Atom::INT:
- object->type = map->object_class_int32;
+ object->type = uris->object_class_int32.id;
object->size = sizeof(int32_t);
*(int32_t*)(object + 1) = atom.get_int32();
break;
case Raul::Atom::STRING:
- object->type = map->object_class_string;
+ object->type = uris->object_class_string.id;
object->size = std::min((uint16_t)object->size, (uint16_t)(strlen(atom.get_string()) + 1));
str = ((char*)(object + 1));
str[object->size - 1] = '\0';
@@ -83,8 +83,8 @@ from_atom(World* world, const Raul::Atom& atom, LV2_Object* object)
break;
case Raul::Atom::BLOB:
error << "TODO: Blob support" << endl;
- /*object->type = map->object_class_string;
- *(uint16_t*)(object + 1) = map->uri_to_id(NULL, atom.get_blob_type());
+ /*object->type = uris->object_class_string;
+ *(uint16_t*)(object + 1) = uris->uri_to_id(NULL, atom.get_blob_type());
memcpy(((char*)(object + 1) + sizeof(uint32_t)), atom.get_blob(),
std::min(atom.data_size(), (size_t)object->size));*/
default:
diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp
index d0c71acf..37856fe6 100644
--- a/src/shared/LV2URIMap.cpp
+++ b/src/shared/LV2URIMap.cpp
@@ -30,16 +30,49 @@ namespace Ingen {
namespace Shared {
+LV2URIMap::Quark::Quark(const char* c_str)
+ : Raul::URI(c_str)
+ , id(g_quark_from_string(c_str))
+{
+}
+
+
LV2URIMap::LV2URIMap()
- : object_class_bool(uri_to_id(NULL, LV2_OBJECT_URI "#Bool"))
- , object_class_string(uri_to_id(NULL, LV2_OBJECT_URI "#String"))
- , object_class_int32(uri_to_id(NULL, LV2_OBJECT_URI "#Int32"))
- , object_class_float32(uri_to_id(NULL, LV2_OBJECT_URI "#Float32"))
- , object_class_vector(uri_to_id(NULL, LV2_OBJECT_URI "#Vector"))
- , ui_format_events(uri_to_id(NULL, "http://lv2plug.in/ns/extensions/ui#Events"))
- , midi_event(uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent"))
- , string_transfer(uri_to_id(NULL, "http://lv2plug.in/ns/dev/string-port#StringTransfer"))
- , object_transfer(uri_to_id(NULL, LV2_OBJECT_URI "#ObjectTransfer"))
+ : ctx_context("ctx:context")
+ , ctx_AudioContext("ctx:AudioContext")
+ , ctx_MessageContext("ctx:MessageContext")
+ , doap_name("doap:name")
+ , ingen_LADSPAPlugin("ingen:LADSPAPlugin")
+ , ingen_Internal("ingen:Internal")
+ , ingen_Node("ingen:Node")
+ , ingen_Patch("ingen:Patch")
+ , ingen_Port("ingen:Port")
+ , ingen_broadcast("ingen:broadcast")
+ , ingen_enabled("ingen:enabled")
+ , ingen_polyphonic("ingen:polyphonic")
+ , ingen_polyphony("ingen:polyphony")
+ , ingen_selected("ingen:selected")
+ , ingen_value("ingen:value")
+ , ingenui_canvas_x("ingenui:canvas-x")
+ , ingenui_canvas_y("ingenui:canvas-y")
+ , lv2_Plugin("lv2:Plugin")
+ , lv2_index("lv2:index")
+ , lv2_maximum("lv2:maximum")
+ , lv2_minimum("lv2:minimum")
+ , lv2_name("lv2:name")
+ , lv2_symbol("lv2:symbol")
+ , lv2_toggled("lv2:toggled")
+ , midi_event("http://lv2plug.in/ns/ext/midi#MidiEvent")
+ , object_class_bool(LV2_OBJECT_URI "#Bool")
+ , object_class_float32(LV2_OBJECT_URI "#Float32")
+ , object_class_int32(LV2_OBJECT_URI "#Int32")
+ , object_class_string(LV2_OBJECT_URI "#String")
+ , object_class_vector(LV2_OBJECT_URI "#Vector")
+ , object_transfer(LV2_OBJECT_URI "#ObjectTransfer")
+ , rdf_instanceOf("rdf:instanceOf")
+ , rdf_type("rdf:type")
+ , string_transfer("http://lv2plug.in/ns/dev/string-port#StringTransfer")
+ , ui_format_events("http://lv2plug.in/ns/extensions/ui#Events")
{
uri_map_feature_data.uri_to_id = &LV2URIMap::uri_map_uri_to_id;
uri_map_feature_data.callback_data = this;
diff --git a/src/shared/LV2URIMap.hpp b/src/shared/LV2URIMap.hpp
index b1e6a89f..df9a1358 100644
--- a/src/shared/LV2URIMap.hpp
+++ b/src/shared/LV2URIMap.hpp
@@ -18,16 +18,10 @@
#ifndef INGEN_SHARED_LV2URIMAP_HPP
#define INGEN_SHARED_LV2URIMAP_HPP
-#include "ingen-config.h"
-#ifndef HAVE_SLV2
-#error "This file requires SLV2, but HAVE_SLV2 is not defined. Please report."
-#endif
-
-#include <map>
-#include <string>
#include <boost/utility.hpp>
-#include "slv2/slv2.h"
+#include <raul/URI.hpp>
#include "uri-map.lv2/uri-map.h"
+#include "ingen-config.h"
#include "LV2Features.hpp"
namespace Ingen {
@@ -55,15 +49,46 @@ private:
LV2_URI_Map_Feature uri_map_feature_data;
public:
- const uint32_t object_class_bool;
- const uint32_t object_class_string;
- const uint32_t object_class_int32;
- const uint32_t object_class_float32;
- const uint32_t object_class_vector;
- const uint32_t ui_format_events;
- const uint32_t midi_event;
- const uint32_t string_transfer;
- const uint32_t object_transfer;
+ struct Quark : public Raul::URI {
+ Quark(const char* str);
+ uint32_t id;
+ };
+
+ const Quark ctx_context;
+ const Quark ctx_AudioContext;
+ const Quark ctx_MessageContext;
+ const Quark doap_name;
+ const Quark ingen_LADSPAPlugin;
+ const Quark ingen_Internal;
+ const Quark ingen_Node;
+ const Quark ingen_Patch;
+ const Quark ingen_Port;
+ const Quark ingen_broadcast;
+ const Quark ingen_enabled;
+ const Quark ingen_polyphonic;
+ const Quark ingen_polyphony;
+ const Quark ingen_selected;
+ const Quark ingen_value;
+ const Quark ingenui_canvas_x;
+ const Quark ingenui_canvas_y;
+ const Quark lv2_Plugin;
+ const Quark lv2_index;
+ const Quark lv2_maximum;
+ const Quark lv2_minimum;
+ const Quark lv2_name;
+ const Quark lv2_symbol;
+ const Quark lv2_toggled;
+ const Quark midi_event;
+ const Quark object_class_bool;
+ const Quark object_class_float32;
+ const Quark object_class_int32;
+ const Quark object_class_string;
+ const Quark object_class_vector;
+ const Quark object_transfer;
+ const Quark rdf_instanceOf;
+ const Quark rdf_type;
+ const Quark string_transfer;
+ const Quark ui_format_events;
};
diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp
index f5e6e4da..eb80a46c 100644
--- a/src/shared/ResourceImpl.hpp
+++ b/src/shared/ResourceImpl.hpp
@@ -32,8 +32,8 @@ class ResourceImpl : virtual public Resource
public:
ResourceImpl(const Raul::URI& uri) : _uri(uri) {}
- virtual void set_uri(const Raul::URI& uri) { _uri = uri; }
- virtual const Raul::URI uri() const { return _uri.str(); }
+ virtual void set_uri(const Raul::URI& uri) { _uri = uri; }
+ virtual const Raul::URI& uri() const { return _uri; }
const Properties& properties() const { return _properties; }
Properties& properties() { return _properties; }