summaryrefslogtreecommitdiffstats
path: root/ingen/Resource.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-11-24 13:44:03 +0100
committerDavid Robillard <d@drobilla.net>2018-11-24 13:44:03 +0100
commita7d83f19b08eb4c6f79a82fe60c2b86db13f4420 (patch)
treed9b620bfba1e7462df4ddb3f6225cc5216c0ca81 /ingen/Resource.hpp
parentd63edc742cebd685f8a05936682210aa5c1e69a9 (diff)
downloadingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.tar.gz
ingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.tar.bz2
ingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.zip
Squashed 'waflib/' changes from 6e726eb1..5ea8f99f
5ea8f99f Improve test output spacing 0e23b29f Raise exception when test suite fails to ensure non-zero exit status d6de073b Show run time of unit tests 5b655541 Add short configure option for ultra-strict flags 4687ba6d Use gtest-like test output 258903d9 Fix failure count in test group summaries da07e738 Fix verbose tests with Python 3 git-subtree-dir: waflib git-subtree-split: 5ea8f99f6e1246079c1fe6bb590c38a53aadd40d
Diffstat (limited to 'ingen/Resource.hpp')
-rw-r--r--ingen/Resource.hpp205
1 files changed, 0 insertions, 205 deletions
diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp
deleted file mode 100644
index 9fc854c7..00000000
--- a/ingen/Resource.hpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2016 David Robillard <http://drobilla.net/>
-
- 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
- Software Foundation, either version 3 of the License, or 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 Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INGEN_RESOURCE_HPP
-#define INGEN_RESOURCE_HPP
-
-#include <cassert>
-#include <string>
-
-#include "ingen/Properties.hpp"
-#include "ingen/URI.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/ingen.h"
-#include "raul/Deletable.hpp"
-
-namespace Ingen {
-
-class Atom;
-
-/** A resource with a URI described by properties.
- *
- * This is the base class for most things in Ingen, including graphs, blocks,
- * ports, and the engine itself.
- *
- * @ingroup Ingen
- */
-class INGEN_API Resource : public Raul::Deletable
-{
-public:
- using Graph = Property::Graph;
-
- Resource(const URIs& uris, const URI& uri)
- : _uris(uris)
- , _uri(uri)
- {}
-
- Resource& operator=(const Resource& rhs) {
- assert(&rhs._uris == &_uris);
- if (&rhs != this) {
- _uri = rhs._uri;
- _properties = rhs._properties;
- }
- return *this;
- }
-
- static URI graph_to_uri(Graph g) {
- switch (g) {
- case Graph::EXTERNAL: return URI(INGEN_NS "externalContext");
- case Graph::INTERNAL: return URI(INGEN_NS "internalContext");
- default: return URI(INGEN_NS "defaultContext");
- }
- }
-
- static Graph uri_to_graph(const URI& uri) {
- if (uri == INGEN_NS "externalContext") {
- return Graph::EXTERNAL;
- } else if (uri == INGEN_NS "internalContext") {
- return Graph::INTERNAL;
- }
- return Graph::DEFAULT;
- }
-
- /** Get a single property value.
- *
- * This is only useful for properties with a single value. If the
- * requested property has several values, the first will be returned.
- */
- virtual const Atom& get_property(const URI& uri) const;
-
- /** Set (replace) a property value.
- *
- * This will first erase any properties with the given `uri`, so after
- * this call exactly one property with predicate `uri` will be set.
- */
- virtual const Atom& set_property(const URI& uri,
- const Atom& value,
- Graph ctx = Graph::DEFAULT);
-
- /** Set (replace) a property value.
- *
- * This will first erase any properties with the given `uri`, so after
- * this call exactly one property with predicate `uri` will be set.
- */
- virtual const Atom& set_property(const URI& uri,
- const URIs::Quark& value,
- Graph ctx = Graph::DEFAULT);
-
- /** Add a property value.
- *
- * This will not remove any existing values, so if properties with
- * predicate `uri` and values other than `value` exist, this will result
- * in multiple values for the property.
- *
- * @return True iff a new property was added.
- */
- virtual bool add_property(const URI& uri,
- const Atom& value,
- Graph ctx = Graph::DEFAULT);
-
- /** Remove a property.
- *
- * If `value` is patch:wildcard then any property with `uri` for a
- * predicate will be removed.
- */
- virtual void remove_property(const URI& uri,
- const Atom& value);
-
- /** Remove a property.
- *
- * If `value` is patch:wildcard then any property with `uri` for a
- * predicate will be removed.
- */
- virtual void remove_property(const URI& uri,
- const URIs::Quark& value);
-
- /** Return true iff a property is set with a specific value. */
- virtual bool has_property(const URI& uri,
- const Atom& value) const;
-
- /** Return true iff a property is set with a specific value. */
- virtual bool has_property(const URI& uri,
- const URIs::Quark& value) const;
-
- /** Set (replace) several properties at once.
- *
- * This will erase all properties with keys in `p`, though multiple values
- * for one property may exist in `p` will all be set (unlike simply
- * calling set_property in a loop which would only set one value).
- */
- void set_properties(const Properties& props);
-
- /** Add several properties at once. */
- void add_properties(const Properties& props);
-
- /** Remove several properties at once.
- *
- * This removes all matching properties (both key and value), or all
- * properties with a matching key if the value in `p` is patch:wildcard.
- */
- void remove_properties(const Properties& props);
-
- /** Hook called whenever a property is added.
- *
- * 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 URI& uri, const Atom& value) {}
-
- /** Hook called whenever a property value is removed.
- *
- * If all values for a key are removed, then value will be the wildcard.
- *
- * This can be used by derived classes to implement special behaviour for
- * particular properties (e.g. ingen:value for ports).
- */
- virtual void on_property_removed(const URI& uri, const Atom& value) {}
-
- /** 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& graph,
- bool& block,
- bool& port,
- bool& is_output);
-
- virtual void set_uri(const URI& uri) { _uri = uri; }
-
- /** Get all the properties with a given context. */
- Properties properties(Resource::Graph ctx) const;
-
- const URIs& uris() const { return _uris; }
- const URI& uri() const { return _uri; }
- const Properties& properties() const { return _properties; }
- Properties& properties() { return _properties; }
-
-protected:
- const Atom& set_property(const URI& uri, const Atom& value) const;
-
- const URIs& _uris;
-
-private:
- URI _uri;
- mutable Properties _properties;
-};
-
-} // namespace Ingen
-
-#endif // INGEN_RESOURCE_HPP