summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-01-22 14:29:12 +0200
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-01-22 14:29:12 +0200
commit9f3e54044fd1e0c26153195f91889342a8425b7f (patch)
tree71bcfde9546045b27d22a3c7265015ccec07ff22 /src
parentcfb16c2a93650ac2e0c9677bce11ed101aceffb0 (diff)
added ResourceSet
Diffstat (limited to 'src')
-rw-r--r--src/resource-set.cpp48
-rw-r--r--src/resource.cpp10
2 files changed, 55 insertions, 3 deletions
diff --git a/src/resource-set.cpp b/src/resource-set.cpp
new file mode 100644
index 0000000..999baec
--- /dev/null
+++ b/src/resource-set.cpp
@@ -0,0 +1,48 @@
+#include "resource-set.h"
+
+
+ResourcePolicy::ResourceSet::ResourceSet(const QString &applicationClass)
+ : applicationClass(applicationClass), resourceSet()
+{
+ identifier = (quint32)this;
+}
+
+ResourcePolicy::ResourceSet::~ResourceSet()
+{
+}
+
+void ResourcePolicy::ResourceSet::addResource(const ResourcePolicy::Resource &resource)
+{
+ resourceSet.insert(resource);
+}
+
+void ResourcePolicy::ResourceSet::addResources(const QSet<ResourcePolicy::Resource> &resources)
+{
+ resourceSet.unite(resources);
+}
+
+void ResourcePolicy::ResourceSet::setResources(const QSet<ResourcePolicy::Resource> &resources)
+{
+ resourceSet.clear();
+ resourceSet = resources;
+}
+
+bool ResourcePolicy::ResourceSet::contains(const ResourcePolicy::Resource &resource) const
+{
+ return resourceSet.contains(resource);
+}
+
+bool ResourcePolicy::ResourceSet::contains(const QSet<ResourcePolicy::Resource> &resources) const
+{
+ return resourceSet.contains(resources);
+}
+
+quint32 ResourcePolicy::ResourceSet::id() const
+{
+ return identifier;
+}
+
+QSet<ResourcePolicy::Resource> ResourcePolicy::ResourceSet::resources()
+{
+ return resourceSet;
+}
diff --git a/src/resource.cpp b/src/resource.cpp
index 3952c46..a54c8cf 100644
--- a/src/resource.cpp
+++ b/src/resource.cpp
@@ -73,16 +73,20 @@ void Resource::setId(quint32 newId)
identifier = newId;
}
-bool Resource::operator==(const Resource &other)
+bool Resource::operator==(const Resource &other) const
{
if(resourceType != other.resourceType) {
return false;
}
- if((identifier != other.identifier) or
- (shared != other.shared) or
+ if((shared != other.shared) or
(optional != other.optional))
{
return false;
}
return true;
}
+
+uint ResourcePolicy::qHash(const Resource & key)
+{
+ return (((key.type()<<1) + key.isShared()) << 1) + key.isOptional();
+}