From 6b6cb56b2ceab509569bfca247f108f2be5e25c0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 23 Feb 2013 19:55:13 +0000 Subject: Move Atom implementation out of Raul so it can depend on LV2. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5076 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/AtomReader.hpp | 2 +- ingen/AtomWriter.hpp | 6 ++-- ingen/ClashAvoider.hpp | 6 ++-- ingen/Configuration.hpp | 37 ++++++++++++------------- ingen/Forge.hpp | 43 +++++++++++++++++++++++++---- ingen/Interface.hpp | 6 ++-- ingen/Resource.hpp | 32 ++++++++++----------- ingen/URIs.hpp | 6 ++-- ingen/client/ClientStore.hpp | 6 ++-- ingen/client/ObjectModel.hpp | 6 ++-- ingen/client/PluginModel.hpp | 4 +-- ingen/client/PortModel.hpp | 18 ++++++------ ingen/client/SigClientInterface.hpp | 4 +-- ingen/client/ThreadedSigClientInterface.hpp | 33 +++++++++++----------- 14 files changed, 120 insertions(+), 89 deletions(-) (limited to 'ingen') diff --git a/ingen/AtomReader.hpp b/ingen/AtomReader.hpp index 8a821194..1cf55bb5 100644 --- a/ingen/AtomReader.hpp +++ b/ingen/AtomReader.hpp @@ -49,7 +49,7 @@ public: bool write(const LV2_Atom* msg); private: - void get_atom(const LV2_Atom* in, Raul::Atom& out); + void get_atom(const LV2_Atom* in, Atom& out); const char* atom_to_uri(const LV2_Atom* atom); boost::optional atom_to_path(const LV2_Atom* atom); diff --git a/ingen/AtomWriter.hpp b/ingen/AtomWriter.hpp index 3dab20ec..4b5555b1 100644 --- a/ingen/AtomWriter.hpp +++ b/ingen/AtomWriter.hpp @@ -66,9 +66,9 @@ public: void disconnect_all(const Raul::Path& graph, const Raul::Path& path); - void set_property(const Raul::URI& subject, - const Raul::URI& predicate, - const Raul::Atom& value); + void set_property(const Raul::URI& subject, + const Raul::URI& predicate, + const Atom& value); void set_response_id(int32_t id); diff --git a/ingen/ClashAvoider.hpp b/ingen/ClashAvoider.hpp index ac3f7e07..60affa2a 100644 --- a/ingen/ClashAvoider.hpp +++ b/ingen/ClashAvoider.hpp @@ -74,9 +74,9 @@ public: virtual void disconnect_all(const Raul::Path& graph, const Raul::Path& path); - virtual void set_property(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); + virtual void set_property(const Raul::URI& subject_path, + const Raul::URI& predicate, + const Atom& value); virtual void del(const Raul::URI& uri); diff --git a/ingen/Configuration.hpp b/ingen/Configuration.hpp index 6002a178..ffa9723e 100644 --- a/ingen/Configuration.hpp +++ b/ingen/Configuration.hpp @@ -25,10 +25,9 @@ #include #include +#include "ingen/Atom.hpp" #include "ingen/Forge.hpp" #include "ingen/URIMap.hpp" - -#include "raul/Atom.hpp" #include "raul/Exception.hpp" namespace Ingen { @@ -60,13 +59,13 @@ public: * @param type Type * @param value Default value */ - Configuration& add(const std::string& key, - const std::string& name, - char letter, - const std::string& desc, - Scope scope, - const Raul::Atom::TypeID type, - const Raul::Atom& value); + Configuration& add(const std::string& key, + const std::string& name, + char letter, + const std::string& desc, + Scope scope, + const LV2_URID type, + const Atom& value); void print_usage(const std::string& program, std::ostream& os); @@ -108,8 +107,8 @@ public: std::list load_default(const std::string& app, const std::string& filename); - const Raul::Atom& option(const std::string& long_name) const; - bool set(const std::string& long_name, const Raul::Atom& value); + const Atom& option(const std::string& long_name) const; + bool set(const std::string& long_name, const Atom& value); const std::list& files() const { return _files; } @@ -118,19 +117,19 @@ private: public: Option(const std::string& k, const std::string& n, char l, const std::string& d, Scope s, - const Raul::Atom::TypeID type, const Raul::Atom& def) + const LV2_URID type, const Atom& def) : key(k), name(n), letter(l) , desc(d), scope(s) , type(type), value(def) {} - std::string key; - std::string name; - char letter; - std::string desc; - Scope scope; - Raul::Atom::TypeID type; - Raul::Atom value; + std::string key; + std::string name; + char letter; + std::string desc; + Scope scope; + LV2_URID type; + Atom value; }; struct OptionNameOrder { diff --git a/ingen/Forge.hpp b/ingen/Forge.hpp index e92a9501..de32b3e8 100644 --- a/ingen/Forge.hpp +++ b/ingen/Forge.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2012 David Robillard + Copyright 2007-2013 David Robillard Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -19,20 +19,53 @@ #include -#include "raul/Atom.hpp" +#include "ingen/Atom.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/forge.h" namespace Ingen { class URIMap; -/** Forge for Raul Atoms. +/** Forge for Atoms. * @ingroup IngenShared */ -class Forge : public Raul::Forge { +class Forge : public LV2_Atom_Forge { public: explicit Forge(URIMap& map); - std::string str(const Raul::Atom& atom); + std::string str(const Atom& atom); + + Atom make() { return Atom(); } + Atom make(int32_t v) { return Atom(sizeof(v), Int, &v); } + Atom make(float v) { return Atom(sizeof(v), Float, &v); } + Atom make(bool v) { + const int32_t iv = v ? 1 : 0; + return Atom(sizeof(int32_t), Bool, &iv); + } + + Atom make_urid(int32_t v) { return Atom(sizeof(int32_t), URID, &v); } + + Atom alloc(uint32_t size, uint32_t type, const void* val) { + return Atom(size, type, val); + } + + Atom alloc(const char* v) { + const size_t len = strlen(v); + return Atom(len + 1, String, v); + } + + Atom alloc(const std::string& v) { + return Atom(v.length() + 1, String, v.c_str()); + } + + Atom alloc_uri(const char* v) { + const size_t len = strlen(v); + return Atom(len + 1, URI, v); + } + + Atom alloc_uri(const std::string& v) { + return Atom(v.length() + 1, URI, v.c_str()); + } private: URIMap& _map; diff --git a/ingen/Interface.hpp b/ingen/Interface.hpp index 023221bd..0fc90d42 100644 --- a/ingen/Interface.hpp +++ b/ingen/Interface.hpp @@ -81,9 +81,9 @@ public: virtual void disconnect_all(const Raul::Path& graph, const Raul::Path& path) = 0; - virtual void set_property(const Raul::URI& subject, - const Raul::URI& predicate, - const Raul::Atom& value) = 0; + virtual void set_property(const Raul::URI& subject, + const Raul::URI& predicate, + const Atom& value) = 0; /** Set the ID to use to respond to the next message. * Setting the ID to -1 will disable responses. diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp index e741a633..756419d8 100644 --- a/ingen/Resource.hpp +++ b/ingen/Resource.hpp @@ -20,8 +20,8 @@ #include #include +#include "ingen/Atom.hpp" #include "ingen/URIs.hpp" -#include "raul/Atom.hpp" #include "raul/Deletable.hpp" #include "raul/URI.hpp" @@ -70,10 +70,10 @@ public: } /** A property value (an Atom with a context). */ - class Property : public Raul::Atom { + class Property : public Atom { public: - Property(const Raul::Atom& atom, Graph ctx=Graph::DEFAULT) - : Raul::Atom(atom) + Property(const Atom& atom, Graph ctx=Graph::DEFAULT) + : Atom(atom) , _ctx(ctx) {} @@ -93,16 +93,16 @@ public: * This is only useful for properties with a single value. If the * requested property has several values, the first will be returned. */ - virtual const Raul::Atom& get_property(const Raul::URI& uri) const; + virtual const Atom& get_property(const Raul::URI& uri) const; /** Set (replace) a property value. * * This will first erase any properties with the given @p uri, so after * this call exactly one property with predicate @p uri will be set. */ - virtual const Raul::Atom& set_property( + virtual const Atom& set_property( const Raul::URI& uri, - const Raul::Atom& value, + const Atom& value, Graph ctx=Graph::DEFAULT); /** Add a property value. @@ -111,21 +111,21 @@ public: * predicate @p uri and values other than @p value exist, this will result * in multiple values for the property. */ - virtual void add_property(const Raul::URI& uri, - const Raul::Atom& value, - Graph ctx=Graph::DEFAULT); + virtual void add_property(const Raul::URI& uri, + const Atom& value, + Graph ctx = Graph::DEFAULT); /** Remove a property. * * If @p value is ingen:wildcard then any property with @p uri for a * predicate will be removed. */ - virtual void remove_property(const Raul::URI& uri, - const Raul::Atom& value); + virtual void remove_property(const Raul::URI& uri, + const Atom& value); /** Return true iff a property is set. */ - virtual bool has_property(const Raul::URI& uri, - const Raul::Atom& value) const; + virtual bool has_property(const Raul::URI& uri, + const Atom& value) const; /** Set (replace) several properties at once. * @@ -150,7 +150,7 @@ public: * This can be used by derived classes to implement special behaviour for * particular properties (e.g. ingen:value for ports). */ - virtual void on_property(const Raul::URI& uri, const Raul::Atom& value) {} + virtual void on_property(const Raul::URI& uri, const Atom& value) {} /** Get the ingen type from a set of Properties. * @@ -175,7 +175,7 @@ public: Properties& properties() { return _properties; } protected: - const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const; + const Atom& set_property(const Raul::URI& uri, const Atom& value) const; URIs& _uris; diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp index a09037e6..4cbe62a6 100644 --- a/ingen/URIs.hpp +++ b/ingen/URIs.hpp @@ -17,9 +17,9 @@ #ifndef INGEN_URIS_HPP #define INGEN_URIS_HPP +#include "ingen/Atom.hpp" #include "ingen/Forge.hpp" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" -#include "raul/Atom.hpp" #include "raul/Noncopyable.hpp" #include "raul/URI.hpp" @@ -46,9 +46,9 @@ public: struct Quark : public Raul::URI { Quark(Ingen::Forge& forge, URIMap* map, const char* str); operator LV2_URID() const { return id; } - operator Raul::Atom() const { return atom; } + operator Atom() const { return atom; } uint32_t id; - Raul::Atom atom; + Atom atom; }; Ingen::Forge& forge; diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp index e9c85ba9..f53217b4 100644 --- a/ingen/client/ClientStore.hpp +++ b/ingen/client/ClientStore.hpp @@ -84,9 +84,9 @@ public: void move(const Raul::Path& old_path, const Raul::Path& new_path); - void set_property(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); + void set_property(const Raul::URI& subject_path, + const Raul::URI& predicate, + const Atom& value); void connect(const Raul::Path& tail, const Raul::Path& head); diff --git a/ingen/client/ObjectModel.hpp b/ingen/client/ObjectModel.hpp index 52655949..66c3db7c 100644 --- a/ingen/client/ObjectModel.hpp +++ b/ingen/client/ObjectModel.hpp @@ -59,9 +59,9 @@ public: bool is_a(const Raul::URI& type) const; - const Raul::Atom& get_property(const Raul::URI& key) const; + const Atom& get_property(const Raul::URI& key) const; - void on_property(const Raul::URI& uri, const Raul::Atom& value); + void on_property(const Raul::URI& uri, const Atom& value); const Raul::Path& path() const { return _path; } const Raul::Symbol& symbol() const { return _symbol; } @@ -73,7 +73,7 @@ public: // Signals INGEN_SIGNAL(new_child, void, SPtr); INGEN_SIGNAL(removed_child, void, SPtr); - INGEN_SIGNAL(property, void, const Raul::URI&, const Raul::Atom&); + INGEN_SIGNAL(property, void, const Raul::URI&, const Atom&); INGEN_SIGNAL(destroyed, void); INGEN_SIGNAL(moved, void); diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp index dea85651..7f409f02 100644 --- a/ingen/client/PluginModel.hpp +++ b/ingen/client/PluginModel.hpp @@ -55,7 +55,7 @@ public: Type type() const { return _type; } - virtual const Raul::Atom& get_property(const Raul::URI& key) const; + virtual const Atom& get_property(const Raul::URI& key) const; Raul::Symbol default_block_symbol() const; std::string human_name() const; @@ -91,7 +91,7 @@ public: // Signals INGEN_SIGNAL(changed, void); - INGEN_SIGNAL(property, void, const Raul::URI&, const Raul::Atom&); + INGEN_SIGNAL(property, void, const Raul::URI&, const Atom&); protected: friend class ClientStore; diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp index 568975fc..84a5d0d8 100644 --- a/ingen/client/PortModel.hpp +++ b/ingen/client/PortModel.hpp @@ -45,11 +45,11 @@ public: bool supports(const Raul::URI& value_type) const; - inline uint32_t index() const { return _index; } - inline const Raul::Atom& value() const { return get_property(_uris.ingen_value); } - inline bool connected() const { return (_connections > 0); } - inline bool is_input() const { return (_direction == Direction::INPUT); } - inline bool is_output() const { return (_direction == Direction::OUTPUT); } + inline uint32_t index() const { return _index; } + inline const Atom& value() const { return get_property(_uris.ingen_value); } + inline bool connected() const { return (_connections > 0); } + inline bool is_input() const { return (_direction == Direction::INPUT); } + inline bool is_output() const { return (_direction == Direction::OUTPUT); } bool port_property(const Raul::URI& uri) const; @@ -65,12 +65,12 @@ public: inline bool operator==(const PortModel& pm) const { return (path() == pm.path()); } - void on_property(const Raul::URI& uri, const Raul::Atom& value); + void on_property(const Raul::URI& uri, const Atom& value); // Signals - INGEN_SIGNAL(value_changed, void, const Raul::Atom&); - INGEN_SIGNAL(voice_changed, void, uint32_t, const Raul::Atom&); - INGEN_SIGNAL(activity, void, const Raul::Atom&); + INGEN_SIGNAL(value_changed, void, const Atom&); + INGEN_SIGNAL(voice_changed, void, uint32_t, const Atom&); + INGEN_SIGNAL(activity, void, const Atom&); INGEN_SIGNAL(connection, void, SPtr); INGEN_SIGNAL(disconnection, void, SPtr); diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp index 900a9923..2210d4f4 100644 --- a/ingen/client/SigClientInterface.hpp +++ b/ingen/client/SigClientInterface.hpp @@ -58,7 +58,7 @@ public: INGEN_SIGNAL(connection, void, Raul::Path, Raul::Path) INGEN_SIGNAL(disconnection, void, Raul::Path, Raul::Path) INGEN_SIGNAL(disconnect_all, void, Raul::Path, Raul::Path) - INGEN_SIGNAL(property_change, void, Raul::URI, Raul::URI, Raul::Atom) + INGEN_SIGNAL(property_change, void, Raul::URI, Raul::URI, Atom) /** Fire pending signals. Only does anything on derived classes (that may queue) */ virtual bool emit_signals() { return false; } @@ -106,7 +106,7 @@ protected: void disconnect_all(const Raul::Path& graph, const Raul::Path& path) { EMIT(disconnect_all, graph, path); } - void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value) + void set_property(const Raul::URI& subject, const Raul::URI& key, const Atom& value) { EMIT(property_change, subject, key, value); } void set_response_id(int32_t id) {} diff --git a/ingen/client/ThreadedSigClientInterface.hpp b/ingen/client/ThreadedSigClientInterface.hpp index d4e5f6d6..562c5fca 100644 --- a/ingen/client/ThreadedSigClientInterface.hpp +++ b/ingen/client/ThreadedSigClientInterface.hpp @@ -25,11 +25,10 @@ #include #include -#include "raul/Atom.hpp" -#include "raul/SRSWQueue.hpp" - +#include "ingen/Atom.hpp" #include "ingen/Interface.hpp" #include "ingen/client/SigClientInterface.hpp" +#include "raul/SRSWQueue.hpp" /** Returns nothing and takes no parameters (because they have all been bound) */ typedef sigc::slot Closure; @@ -104,7 +103,7 @@ public: void disconnect_all(const Raul::Path& graph, const Raul::Path& path) { push_sig(sigc::bind(disconnect_all_slot, graph, path)); } - void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value) + void set_property(const Raul::URI& subject, const Raul::URI& key, const Atom& value) { push_sig(sigc::bind(property_change_slot, subject, key, value)); } /** Process all queued events - Called from GTK thread to emit signals. */ @@ -145,21 +144,21 @@ private: Raul::SRSWQueue _sigs; - sigc::slot bundle_begin_slot; - sigc::slot bundle_end_slot; - sigc::slot response_slot; - sigc::slot error_slot; - sigc::slot new_plugin_slot; + sigc::slot bundle_begin_slot; + sigc::slot bundle_end_slot; + sigc::slot response_slot; + sigc::slot error_slot; + sigc::slot new_plugin_slot; sigc::slot put_slot; + Resource::Graph> put_slot; sigc::slot delta_slot; - sigc::slot connection_slot; - sigc::slot object_deleted_slot; - sigc::slot object_moved_slot; - sigc::slot disconnection_slot; - sigc::slot disconnect_all_slot; - sigc::slot property_change_slot; + Resource::Properties> delta_slot; + sigc::slot connection_slot; + sigc::slot object_deleted_slot; + sigc::slot object_moved_slot; + sigc::slot disconnection_slot; + sigc::slot disconnect_all_slot; + sigc::slot property_change_slot; }; } // namespace Client -- cgit v1.2.1