summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-09-09 12:22:06 +0200
committerStef Walter <stefw@collabora.co.uk>2011-09-09 14:23:45 +0200
commit2a73924b070044ceb9e600c0daf007f0bddaf65b (patch)
tree70c0b873833f7303b868c68e7c987172a0a6f593
parentd14a8aff48381ea97e68b7996e1b7bb2f7a923fb (diff)
downloadgcr-2a73924b070044ceb9e600c0daf007f0bddaf65b.tar.gz
gcr: Add gcr_union_collection_have() and gcr_union_collection_size()
* Used to check wether a collection is part of the union.
-rw-r--r--docs/reference/gcr/gcr-sections.txt2
-rw-r--r--gcr/gcr-union-collection.c34
-rw-r--r--gcr/gcr-union-collection.h5
3 files changed, 41 insertions, 0 deletions
diff --git a/docs/reference/gcr/gcr-sections.txt b/docs/reference/gcr/gcr-sections.txt
index 7019ad3..0f22399 100644
--- a/docs/reference/gcr/gcr-sections.txt
+++ b/docs/reference/gcr/gcr-sections.txt
@@ -269,6 +269,8 @@ gcr_union_collection_new
gcr_union_collection_add
gcr_union_collection_take
gcr_union_collection_remove
+gcr_union_collection_have
+gcr_union_collection_size
<SUBSECTION Standard>
GCR_IS_UNION_COLLECTION
GCR_IS_UNION_COLLECTION_CLASS
diff --git a/gcr/gcr-union-collection.c b/gcr/gcr-union-collection.c
index 558590f..55e1785 100644
--- a/gcr/gcr-union-collection.c
+++ b/gcr/gcr-union-collection.c
@@ -305,3 +305,37 @@ gcr_union_collection_remove (GcrUnionCollection *self,
g_object_unref (collection);
}
+
+/**
+ * gcr_union_collection_have:
+ * @self: the union collection
+ * @collection: the collection to check
+ *
+ * Check whether the collection is present in the union.
+ *
+ * Returns: whether present or not
+ */
+gboolean
+gcr_union_collection_have (GcrUnionCollection *self,
+ GcrCollection *collection)
+{
+ g_return_val_if_fail (GCR_IS_UNION_COLLECTION (self), FALSE);
+ g_return_val_if_fail (GCR_IS_COLLECTION (collection), FALSE);
+ return g_hash_table_lookup (self->pv->collections, collection) != NULL;
+}
+
+/**
+ * gcr_union_collection_size:
+ * @self: the union collection
+ *
+ * Return the number of collections in this union. This does not reflect
+ * the number of objects in the combined collection.
+ *
+ * Returns: number of collections inlcuded
+ */
+guint
+gcr_union_collection_size (GcrUnionCollection *self)
+{
+ g_return_val_if_fail (GCR_IS_UNION_COLLECTION (self), FALSE);
+ return g_hash_table_size (self->pv->collections);
+}
diff --git a/gcr/gcr-union-collection.h b/gcr/gcr-union-collection.h
index ac9a59d..46d8a04 100644
--- a/gcr/gcr-union-collection.h
+++ b/gcr/gcr-union-collection.h
@@ -66,6 +66,11 @@ void gcr_union_collection_take (GcrUnionCollec
void gcr_union_collection_remove (GcrUnionCollection *self,
GcrCollection *collection);
+gboolean gcr_union_collection_have (GcrUnionCollection *self,
+ GcrCollection *collection);
+
+guint gcr_union_collection_size (GcrUnionCollection *self);
+
G_END_DECLS
#endif /* __GCR_UNION_COLLECTION_H__ */