diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/ResourceImpl.cpp | 16 | ||||
-rw-r--r-- | src/shared/ResourceImpl.hpp | 3 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index d315b8f0..14227ccf 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -40,10 +40,20 @@ ResourceImpl::add_property(const Raul::URI& uri, const Raul::Atom& value) } Raul::Atom& -ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value) +ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value, + Resource::Graph ctx) { - _properties.erase(uri); - return _properties.insert(make_pair(uri, value))->second; + // Erase existing property in this context + for (Properties::iterator i = _properties.find(uri); + (i != _properties.end()) && (i->first == uri); + ++i) { + if (i->second.context() == ctx && i->second == value) { + _properties.erase(i); + } + } + + // Insert new property + return _properties.insert(make_pair(uri, Property(value, ctx)))->second; } void diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp index 47d6f31d..6afc567d 100644 --- a/src/shared/ResourceImpl.hpp +++ b/src/shared/ResourceImpl.hpp @@ -46,7 +46,8 @@ public: Properties properties(Resource::Graph ctx) const; const Raul::Atom& get_property(const Raul::URI& uri) const; - Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value); + 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); |