From cf6e43bc6a14fc0fd290864b4f71aeb600a28e9d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 28 May 2009 19:54:24 +0000 Subject: Generic plugin property mechanism. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2031 a436a847-0d15-0410-975c-d299462d15a1 --- src/shared/ResourceImpl.cpp | 11 +++++++++-- src/shared/ResourceImpl.hpp | 9 ++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/shared') diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index ca3eaacd..ac828f58 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -47,11 +47,18 @@ ResourceImpl::add_property(const Raul::URI& uri, const Raul::Atom& value) } -void +Raul::Atom& ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value) { _properties.erase(uri); - _properties.insert(make_pair(uri, value)); + return _properties.insert(make_pair(uri, value))->second; +} + + +Raul::Atom& +ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value) const +{ + return const_cast(this)->set_property(uri, value); } diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp index 118d4dbe..36d4305e 100644 --- a/src/shared/ResourceImpl.hpp +++ b/src/shared/ResourceImpl.hpp @@ -38,7 +38,7 @@ public: Properties& properties() { return _properties; } const Raul::Atom& get_property(const Raul::URI& uri) const; - void set_property(const Raul::URI& uri, const Raul::Atom& value); + Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value); void add_property(const Raul::URI& uri, const Raul::Atom& value); void set_properties(const Properties& p); void add_properties(const Properties& p); @@ -57,9 +57,12 @@ public: static const Raul::URI meta_uri(const Raul::URI& base, const Raul::URI& uri); +protected: + Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const; + private: - Raul::URI _uri; - Properties _properties; + Raul::URI _uri; + mutable Properties _properties; }; -- cgit v1.2.1