summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/NodeModel.cpp1
-rw-r--r--src/libs/client/PluginModel.hpp16
-rw-r--r--src/libs/client/PortModel.hpp30
-rw-r--r--src/libs/client/Serializer.cpp16
-rw-r--r--src/libs/client/Serializer.hpp23
5 files changed, 34 insertions, 52 deletions
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index 87b62dd9..52a4e1e9 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -141,6 +141,7 @@ NodeModel::get_port(const string& port_name) const
Shared::Port*
NodeModel::port(uint32_t index) const
{
+ assert(index < num_ports());
return dynamic_cast<Shared::Port*>(_ports[index].get());
}
diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp
index b4b0ab96..ce268a06 100644
--- a/src/libs/client/PluginModel.hpp
+++ b/src/libs/client/PluginModel.hpp
@@ -62,22 +62,6 @@ public:
const string& name() const { return _name; }
void name(const string& s) { _name = s; }
- /*const char* const type_string() const {
- if (_type == LV2) return "LV2";
- else if (_type == LADSPA) return "LADSPA";
- else if (_type == Internal) return "Internal";
- else if (_type == Patch) return "Patch";
- else return "";
- }*/
-
- const char* const type_uri() const {
- if (_type == LV2) return "ingen:LV2";
- else if (_type == LADSPA) return "ingen:LADSPA";
- else if (_type == Internal) return "ingen:Internal";
- else if (_type == Patch) return "ingen:Patch";
- else return "";
- }
-
/** DEPRECATED */
void set_type(const string& type_string) {
if (type_string == "LV2") _type = LV2;
diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp
index d6a766d8..8624c031 100644
--- a/src/libs/client/PortModel.hpp
+++ b/src/libs/client/PortModel.hpp
@@ -23,10 +23,12 @@
#include <string>
#include <vector>
#include <sigc++/sigc++.h>
-#include "ObjectModel.hpp"
#include <raul/SharedPtr.hpp>
#include <raul/Path.hpp>
-using std::string; using std::vector; using std::cerr; using std::endl;
+#include "interface/Port.hpp"
+#include "ObjectModel.hpp"
+
+using std::string; using std::vector;
namespace Ingen {
namespace Client {
@@ -36,20 +38,16 @@ namespace Client {
*
* \ingroup IngenClient
*/
-class PortModel : public ObjectModel
+class PortModel : public ObjectModel, public Shared::Port
{
public:
enum Direction { INPUT, OUTPUT };
- inline string type() const { return _type; }
- inline float value() const { return _current_val; }
- inline bool connected() const { return (_connections > 0); }
- inline bool is_input() const { return (_direction == INPUT); }
- inline bool is_output() const { return (_direction == OUTPUT); }
- inline bool is_audio() const { return (_type == "ingen:AudioPort"); }
- inline bool is_control() const { return (_type == "ingen:ControlPort"); }
- inline bool is_midi() const { return (_type == "ingen:MidiPort"); }
- inline bool is_osc() const { return (_type == "ingen:OSCPort"); }
+ inline DataType type() const { return _type; }
+ inline Atom value() const { return Atom(_current_val); }
+ inline bool connected() const { return (_connections > 0); }
+ inline bool is_input() const { return (_direction == INPUT); }
+ inline bool is_output() const { return (_direction == OUTPUT); }
bool is_logarithmic() const;
bool is_integer() const;
@@ -76,15 +74,15 @@ public:
private:
friend class Store;
- PortModel(const Path& path, const string& type, Direction dir)
+ PortModel(const Path& path, DataType type, Direction dir)
: ObjectModel(path, true),
_type(type),
_direction(dir),
_current_val(0.0f),
_connections(0)
{
- if (!is_audio() && !is_control() && !is_input())
- cerr << "[PortModel] Warning: Unknown port type" << endl;
+ if (_type == DataType::UNKNOWN)
+ std::cerr << "[PortModel] Warning: Unknown port type" << std::endl;
}
void add_child(SharedPtr<ObjectModel> c) { throw; }
@@ -93,7 +91,7 @@ private:
void connected_to(SharedPtr<PortModel> p) { ++_connections; signal_connection.emit(p); }
void disconnected_from(SharedPtr<PortModel> p) { --_connections; signal_disconnection.emit(p); }
- string _type;
+ DataType _type;
Direction _direction;
float _current_val;
size_t _connections;
diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp
index d367733d..a5fbb614 100644
--- a/src/libs/client/Serializer.cpp
+++ b/src/libs/client/Serializer.cpp
@@ -37,11 +37,7 @@
#include "interface/EngineInterface.hpp"
#include "interface/Port.hpp"
#include "ConnectionModel.hpp"
-#include "NodeModel.hpp"
#include "PatchModel.hpp"
-#include "PluginModel.hpp"
-#include "PortModel.hpp"
-#include "PresetModel.hpp"
#include "Serializer.hpp"
using namespace std;
@@ -60,7 +56,7 @@ Serializer::Serializer(Raul::RDF::World& world)
}
void
-Serializer::to_file(SharedPtr<ObjectModel> object, const string& filename)
+Serializer::to_file(SharedPtr<GraphObject> object, const string& filename)
{
_root_object = object;
start_to_filename(filename);
@@ -70,7 +66,7 @@ Serializer::to_file(SharedPtr<ObjectModel> object, const string& filename)
string
-Serializer::to_string(SharedPtr<ObjectModel> object)
+Serializer::to_string(SharedPtr<GraphObject> object)
{
_root_object = object;
start_to_string();
@@ -216,7 +212,7 @@ Serializer::find_file(const string& filename, const string& additional_path)
#endif
void
-Serializer::serialize(SharedPtr<ObjectModel> object) throw (std::logic_error)
+Serializer::serialize(SharedPtr<GraphObject> object) throw (std::logic_error)
{
if (!_model)
throw std::logic_error("serialize called without serialization in progress");
@@ -322,7 +318,7 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch)
void
-Serializer::serialize_plugin(SharedPtr<PluginModel> plugin)
+Serializer::serialize_plugin(SharedPtr<Shared::Plugin> plugin)
{
assert(_model);
@@ -370,6 +366,7 @@ Serializer::serialize_node(SharedPtr<Shared::Node> node, const RDF::Node& node_i
for (uint32_t i=0; i < node->num_ports(); ++i) {
Port* p = node->port(i);
+ assert(p);
const RDF::Node port_id = path_to_node_id(p->path());
serialize_port(p, port_id);
_model->add_statement(node_id, "ingen:port", port_id);
@@ -402,7 +399,8 @@ Serializer::serialize_port(const Port* port, const RDF::Node& port_id)
_model->add_statement(port_id, "ingen:name", Atom(port->path().name().c_str()));
- _model->add_statement(port_id, "rdf:type", Atom(port->type().uri()));
+ _model->add_statement(port_id, "rdf:type",
+ RDF::Node(_model->world(), RDF::Node::RESOURCE, port->type().uri()));
if (port->type() == DataType::CONTROL && port->is_input())
_model->add_statement(port_id, "ingen:value", port->value());
diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp
index d40e77ae..fafedfa5 100644
--- a/src/libs/client/Serializer.hpp
+++ b/src/libs/client/Serializer.hpp
@@ -28,22 +28,23 @@
#include <raul/Atom.hpp>
#include <raul/RDFWorld.hpp>
#include <raul/RDFModel.hpp>
-#include "ObjectModel.hpp"
+using namespace Raul;
using namespace Ingen::Shared;
namespace Ingen {
-namespace Shared { class Node; class Port; }
+namespace Shared {
+ class Plugin;
+ class GraphObject;
+ class Node;
+ class Port;
+}
namespace Client {
-class PluginModel;
class PatchModel;
-class NodeModel;
-class PortModel;
class ConnectionModel;
-class PresetModel;
/** Serializes Ingen objects (patches, nodes, etc) to RDF.
@@ -55,11 +56,11 @@ class Serializer
public:
Serializer(Raul::RDF::World& world);
- void to_file(SharedPtr<ObjectModel> object, const string& filename);
- string to_string(SharedPtr<ObjectModel> object);
+ void to_file(SharedPtr<GraphObject> object, const string& filename);
+ string to_string(SharedPtr<GraphObject> object);
void start_to_string();
- void serialize(SharedPtr<ObjectModel> object) throw (std::logic_error);
+ void serialize(SharedPtr<GraphObject> object) throw (std::logic_error);
void serialize_connection(SharedPtr<ConnectionModel> c) throw (std::logic_error);
string finish();
@@ -70,7 +71,7 @@ private:
void setup_prefixes();
- void serialize_plugin(SharedPtr<PluginModel> p);
+ void serialize_plugin(SharedPtr<Shared::Plugin> p);
void serialize_patch(SharedPtr<PatchModel> p);
void serialize_node(SharedPtr<Shared::Node> n, const Raul::RDF::Node& id);
@@ -81,7 +82,7 @@ private:
typedef std::map<Raul::Path, Raul::RDF::Node> NodeMap;
- SharedPtr<ObjectModel> _root_object;
+ SharedPtr<GraphObject> _root_object;
Mode _mode;
NodeMap _node_map;
string _base_uri;