summaryrefslogtreecommitdiffstats
path: root/include/ingen/Resource.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-13 04:59:03 +0000
committerDavid Robillard <d@drobilla.net>2011-04-13 04:59:03 +0000
commit8b2f670248c92776e375bd30c0815a4ff259bb0e (patch)
tree0f130bf4f118209788d2792b06de9f8b0aefebc6 /include/ingen/Resource.hpp
parent793bef06e2a98561e266a32ee767410ea44d4c67 (diff)
downloadingen-8b2f670248c92776e375bd30c0815a4ff259bb0e.tar.gz
ingen-8b2f670248c92776e375bd30c0815a4ff259bb0e.tar.bz2
ingen-8b2f670248c92776e375bd30c0815a4ff259bb0e.zip
Consistent local or installed includes for interface headers.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3143 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'include/ingen/Resource.hpp')
-rw-r--r--include/ingen/Resource.hpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/include/ingen/Resource.hpp b/include/ingen/Resource.hpp
new file mode 100644
index 00000000..66183951
--- /dev/null
+++ b/include/ingen/Resource.hpp
@@ -0,0 +1,101 @@
+/* This file is part of Ingen.
+ * Copyright (C) 2008-2009 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_INTERFACE_RESOURCE_HPP
+#define INGEN_INTERFACE_RESOURCE_HPP
+
+#include <map>
+#include <string>
+
+#include "raul/Atom.hpp"
+#include "raul/URI.hpp"
+
+namespace Ingen {
+namespace Shared {
+
+
+class Resource
+{
+public:
+ enum Graph {
+ DEFAULT,
+ EXTERNAL,
+ INTERNAL
+ };
+
+ class Property : public Raul::Atom {
+ public:
+ Property(const Raul::Atom& atom, Graph ctx=DEFAULT)
+ : Raul::Atom(atom)
+ , _ctx(ctx)
+ {}
+
+ Property() : Raul::Atom(), _ctx(DEFAULT) {}
+ Property(int32_t val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(float val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(bool val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(const char* val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(const std::string& val) : Raul::Atom(val), _ctx(DEFAULT) {}
+
+ Property(const Raul::Atom::DictValue& dict)
+ : Raul::Atom(dict)
+ , _ctx(DEFAULT)
+ {}
+
+ Property(Type t, const std::string& uri)
+ : Raul::Atom(t, uri)
+ , _ctx(DEFAULT)
+ {}
+
+ Graph context() const { return _ctx; }
+ void set_context(Graph ctx) { _ctx = ctx; }
+
+ private:
+ Graph _ctx;
+ };
+
+ virtual ~Resource() {}
+
+ virtual const Raul::URI& uri() const = 0;
+
+ typedef std::multimap<Raul::URI, Property> Properties;
+
+ static void set_context(Properties& props, Graph ctx) {
+ for (Properties::iterator i = props.begin(); i != props.end(); ++i) {
+ i->second.set_context(ctx);
+ }
+ }
+
+ virtual Properties properties(Resource::Graph ctx) const = 0;
+
+ virtual const Properties& properties() const = 0;
+ virtual Properties& properties() = 0;
+ virtual const Raul::Atom& get_property(const Raul::URI& uri) const = 0;
+ virtual Raul::Atom& set_property(const Raul::URI& uri,
+ const Raul::Atom& value) = 0;
+ virtual void add_property(const Raul::URI& uri,
+ const Raul::Atom& value) = 0;
+ virtual bool has_property(const Raul::URI& uri,
+ const Raul::Atom& value) const = 0;
+};
+
+
+} // namespace Shared
+} // namespace Ingen
+
+#endif // INGEN_INTERFACE_RESOURCE_HPP
+