diff options
Diffstat (limited to 'include/ingen')
-rw-r--r-- | include/ingen/client/ClientStore.hpp | 4 | ||||
-rw-r--r-- | include/ingen/client/ObjectModel.hpp | 2 | ||||
-rw-r--r-- | include/ingen/client/PluginModel.hpp | 2 | ||||
-rw-r--r-- | include/ingen/client/PluginUI.hpp | 2 | ||||
-rw-r--r-- | include/ingen/shared/LV2Features.hpp | 77 | ||||
-rw-r--r-- | include/ingen/shared/LV2URIMap.hpp | 70 | ||||
-rw-r--r-- | include/ingen/shared/ResourceImpl.hpp | 87 | ||||
-rw-r--r-- | include/ingen/shared/Store.hpp | 59 |
8 files changed, 298 insertions, 5 deletions
diff --git a/include/ingen/client/ClientStore.hpp b/include/ingen/client/ClientStore.hpp index 1a93f8e1..a79b235c 100644 --- a/include/ingen/client/ClientStore.hpp +++ b/include/ingen/client/ClientStore.hpp @@ -29,8 +29,8 @@ #include "ingen/ServerInterface.hpp" #include "ingen/client/signal.hpp" -#include "shared/LV2URIMap.hpp" -#include "shared/Store.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/Store.hpp" namespace Raul { class Atom; } diff --git a/include/ingen/client/ObjectModel.hpp b/include/ingen/client/ObjectModel.hpp index ec2c319a..07cf8674 100644 --- a/include/ingen/client/ObjectModel.hpp +++ b/include/ingen/client/ObjectModel.hpp @@ -28,7 +28,7 @@ #include "ingen/GraphObject.hpp" #include "ingen/client/signal.hpp" -#include "shared/ResourceImpl.hpp" +#include "ingen/shared/ResourceImpl.hpp" namespace Ingen { diff --git a/include/ingen/client/PluginModel.hpp b/include/ingen/client/PluginModel.hpp index bae17994..a0887454 100644 --- a/include/ingen/client/PluginModel.hpp +++ b/include/ingen/client/PluginModel.hpp @@ -26,7 +26,7 @@ #include "ingen/Plugin.hpp" #include "ingen/ServerInterface.hpp" #include "ingen/client/signal.hpp" -#include "shared/ResourceImpl.hpp" +#include "ingen/shared/ResourceImpl.hpp" #include "ingen/shared/World.hpp" namespace Ingen { diff --git a/include/ingen/client/PluginUI.hpp b/include/ingen/client/PluginUI.hpp index bf0094e7..ed5dc5a6 100644 --- a/include/ingen/client/PluginUI.hpp +++ b/include/ingen/client/PluginUI.hpp @@ -24,7 +24,7 @@ #include "suil/suil.h" -#include "shared/LV2Features.hpp" +#include "ingen/shared/LV2Features.hpp" namespace Ingen { diff --git a/include/ingen/shared/LV2Features.hpp b/include/ingen/shared/LV2Features.hpp new file mode 100644 index 00000000..f33cc605 --- /dev/null +++ b/include/ingen/shared/LV2Features.hpp @@ -0,0 +1,77 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_SHARED_LV2FEATURES_HPP +#define INGEN_SHARED_LV2FEATURES_HPP + +#include <vector> + +#include "lv2/lv2plug.in/ns/lv2core/lv2.h" + +#include "raul/SharedPtr.hpp" + +namespace Ingen { + +class Node; + +namespace Shared { + +class World; + +/** Stuff that may need to be passed to an LV2 plugin (i.e. LV2 features). + */ +class LV2Features { +public: + LV2Features(); + + class Feature { + public: + virtual ~Feature() {} + + virtual SharedPtr<LV2_Feature> feature(Shared::World* world, + Node* node) = 0; + }; + + class FeatureArray { + public: + typedef std::vector< SharedPtr<LV2_Feature> > FeatureVector; + + explicit FeatureArray(FeatureVector& features); + + ~FeatureArray(); + + LV2_Feature** array() { return _array; } + + private: + FeatureVector _features; + LV2_Feature** _array; + }; + + void add_feature(SharedPtr<Feature> feature); + + SharedPtr<FeatureArray> lv2_features(Shared::World* world, + Node* node) const; + +private: + typedef std::vector< SharedPtr<Feature> > Features; + Features _features; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_LV2FEATURES_HPP diff --git a/include/ingen/shared/LV2URIMap.hpp b/include/ingen/shared/LV2URIMap.hpp new file mode 100644 index 00000000..98508fd1 --- /dev/null +++ b/include/ingen/shared/LV2URIMap.hpp @@ -0,0 +1,70 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_SHARED_LV2URIMAP_HPP +#define INGEN_SHARED_LV2URIMAP_HPP + +#include <map> +#include <utility> + +#include <boost/utility.hpp> + +#include "ingen/shared/LV2Features.hpp" +#include "ingen/shared/URIs.hpp" +#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" +#include "raul/URI.hpp" + +namespace Ingen { +namespace Shared { + +/** Implementation of the LV2 URI Map extension + */ +class LV2URIMap : public boost::noncopyable, public LV2Features::Feature { +public: + LV2URIMap(URIs& uris); + + SharedPtr<LV2_Feature> feature(Shared::World*, Node*) { + return SharedPtr<LV2_Feature>(&uri_map_feature, NullDeleter<LV2_Feature>); + } + + virtual uint32_t uri_to_id(const char* map, const char* uri); + virtual const char* id_to_uri(const char* map, uint32_t id); + + std::pair<bool, uint32_t> event_to_global(uint16_t event_id) const; + std::pair<bool, uint16_t> global_to_event(uint32_t global_id) const; + +private: + static uint32_t uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data, + const char* map, + const char* uri); + + LV2_Feature uri_map_feature; + LV2_URI_Map_Feature uri_map_feature_data; + + typedef std::map<uint16_t, uint32_t> EventToGlobal; + typedef std::map<uint32_t, uint16_t> GlobalToEvent; + + EventToGlobal _event_to_global; + GlobalToEvent _global_to_event; + + URIs& _uris; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_LV2URIMAP_HPP diff --git a/include/ingen/shared/ResourceImpl.hpp b/include/ingen/shared/ResourceImpl.hpp new file mode 100644 index 00000000..13f1bd8f --- /dev/null +++ b/include/ingen/shared/ResourceImpl.hpp @@ -0,0 +1,87 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_SHARED_RESOURCEIMPL_HPP +#define INGEN_SHARED_RESOURCEIMPL_HPP + +#include "raul/URI.hpp" +#include "raul/SharedPtr.hpp" + +#include "ingen/Resource.hpp" + +namespace Ingen { +namespace Shared { + +class URIs; + +class ResourceImpl : virtual public Resource +{ +public: + ResourceImpl(URIs& uris, const Raul::URI& uri) + : _uris(uris) + , _uri(uri) + {} + + URIs& uris() const { return _uris; } + + 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; } + + Properties properties(Resource::Graph ctx) const; + + const Raul::Atom& get_property(const Raul::URI& uri) const; + const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value, + Resource::Graph ctx=Resource::DEFAULT); + void remove_property(const Raul::URI& uri, const Raul::Atom& value); + bool has_property(const Raul::URI& uri, const Raul::Atom& value) const; + void add_property(const Raul::URI& uri, const Raul::Atom& value, + Graph ctx=DEFAULT); + void set_properties(const Properties& p); + void add_properties(const Properties& p); + void remove_properties(const Properties& p); + + void dump(std::ostream& os) const; + + /** Get the ingen type from a set of Properties. + * If some coherent ingen type is found, true is returned and the appropriate + * output parameter set to true. Otherwise false is returned. + */ + static bool type(const URIs& uris, + const Properties& properties, + bool& patch, + bool& node, + bool& port, + bool& is_output); + +protected: + const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const; + + URIs& _uris; + +private: + Raul::URI _uri; + mutable Properties _properties; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_RESOURCEIMPL_HPP + diff --git a/include/ingen/shared/Store.hpp b/include/ingen/shared/Store.hpp new file mode 100644 index 00000000..cc78e946 --- /dev/null +++ b/include/ingen/shared/Store.hpp @@ -0,0 +1,59 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_SHARED_STORE_HPP +#define INGEN_SHARED_STORE_HPP + +#include <string> + +#include <glibmm/thread.h> + +#include "raul/PathTable.hpp" + +#include "ingen/GraphObject.hpp" + +namespace Ingen { +namespace Shared { + +class Store : public Raul::PathTable< SharedPtr<GraphObject> > { +public: + virtual ~Store() {} + + virtual void add(GraphObject* o); + + typedef Raul::Table< Raul::Path, SharedPtr<GraphObject> > Objects; + + const_iterator children_begin(SharedPtr<const GraphObject> o) const; + const_iterator children_end(SharedPtr<const GraphObject> o) const; + + SharedPtr<GraphObject> find_child(SharedPtr<const GraphObject> parent, + const std::string& child_name) const; + + unsigned child_name_offset(const Raul::Path& parent, + const Raul::Symbol& symbol, + bool allow_zero=true); + + Glib::RWLock& lock() { return _lock; } + +private: + Glib::RWLock _lock; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_STORE_HPP |