Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Tagcoll::Collection< ITEM, TAG > Class Template Reference

Interface for all collections of tagged items. More...

#include <Collection.h>

Inheritance diagram for Tagcoll::Collection< ITEM, TAG >:

Inheritance graph
[legend]
Collaboration diagram for Tagcoll::Collection< ITEM, TAG >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~Collection ()
virtual bool hasTag (const TAG &tag) const
 Check if the collection contains a tag.
OpSet< TAG > getTags (const ITEM &item) const
 Get the tags of item `item'.
OpSet< TAG > getTags (const OpSet< ITEM > &items) const
 Get all the tags of items `items'.
OpSet< ITEM > getItems (const TAG &tag) const
 Get the items with tag `tag'.
OpSet< ITEM > getItems (const OpSet< TAG > &tags) const
 Get the items with tag `tag'.
virtual void applyChange (const PatchList< ITEM, TAG > &change)=0
 Apply a patch to the collection.
virtual OpSet< ITEM > getTaggedItems () const =0
 Get the set of all the items that have tags according to this collection.
virtual OpSet< TAG > getAllTags () const =0
 Get the set of all the tags in this collection.
virtual int getCardinality (const TAG &tag) const
 Get the cardinality of tag `tag' (that is, the number of items who have it).
virtual OpSet< TAG > getCompanionTags (const OpSet< TAG > &tags) const
 Get the set of all tags in this collection that appear in tagsets containing `tags'.
virtual OpSet< ITEM > getRelatedItems (const OpSet< TAG > &tags, int maxdistance=1) const
 Get the related items at the given maximum distance.
virtual void output (Consumer< ITEM, TAG > &consumer) const =0
 Output all the contents of the collection to a Consumer.
virtual void outputHavingTags (const OpSet< TAG > &tags, Consumer< ITEM, TAG > &consumer) const
 Send to a consumer all the items which are tagged with at least the given tags.

Protected Member Functions

void consumeItemUntagged (const ITEM &)
 Process an untagged item.
void consumeItemsUntagged (const OpSet< ITEM > &)
 Process a set of items, all with no tags.
virtual OpSet< ITEM > getItemsHavingTag (const TAG &tag) const =0
 Get the items which are tagged with at least the tag `tag'.
virtual OpSet< ITEM > getItemsHavingTags (const OpSet< TAG > &tags) const
 Get the items which are tagged with at least the tags `tags'.
virtual OpSet< TAG > getTagsOfItem (const ITEM &item) const =0
 Get the tags attached to an item.
virtual OpSet< TAG > getTagsOfItems (const OpSet< ITEM > &items) const
 Get all the tags attached to the items in a set.

Detailed Description

template<typename ITEM, typename TAG>
class Tagcoll::Collection< ITEM, TAG >

Interface for all collections of tagged items.

Note:
The point of a collection is to track the tags attached to items, and not to store the items themselves. This means that collections are not required to keep track of items with no tags.


Constructor & Destructor Documentation

template<typename ITEM, typename TAG>
virtual Tagcoll::Collection< ITEM, TAG >::~Collection  )  [inline, virtual]
 


Member Function Documentation

template<typename ITEM, typename TAG>
virtual void Tagcoll::Collection< ITEM, TAG >::applyChange const PatchList< ITEM, TAG > &  change  )  [pure virtual]
 

Apply a patch to the collection.

Example:

 void perform(const PatchList<ITEM, TAG>& change)
 {
    collection.applyChange(change);
    undo.push_back(change.getReverse());
 }

Implemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::TDBIndexer< ITEM, TAG >.

template<typename ITEM, typename TAG>
void Tagcoll::Collection< ITEM, TAG >::consumeItemsUntagged const OpSet< ITEM > &   )  [inline, protected, virtual]
 

Process a set of items, all with no tags.

Reimplemented from Tagcoll::Consumer< ITEM, TAG >.

template<typename ITEM, typename TAG>
void Tagcoll::Collection< ITEM, TAG >::consumeItemUntagged const ITEM &   )  [inline, protected, virtual]
 

Process an untagged item.

Implements Tagcoll::Consumer< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::Collection< ITEM, TAG >::getAllTags  )  const [pure virtual]
 

Get the set of all the tags in this collection.

Implemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::InputMerger< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::TDBIndexer< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual int Tagcoll::Collection< ITEM, TAG >::getCardinality const TAG &  tag  )  const [inline, virtual]
 

Get the cardinality of tag `tag' (that is, the number of items who have it).

Reimplemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, and Tagcoll::TDBDiskIndex< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::Collection< ITEM, TAG >::getCompanionTags const OpSet< TAG > &  tags  )  const [inline, virtual]
 

Get the set of all tags in this collection that appear in tagsets containing `tags'.

Example:

 void refineSelection(const OpSet<Tag>& selection)
 {
    OpSet<Tag> extraTags = collection.getCompanionTags(selection);
    tagMenu.setAvailableOptions(extraTags);
 }

Reimplemented in Tagcoll::CardinalityStore< ITEM, TAG >, and Tagcoll::ItemGrouper< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet<ITEM> Tagcoll::Collection< ITEM, TAG >::getItems const OpSet< TAG > &  tags  )  const [inline]
 

Get the items with tag `tag'.

Return an empty set if `tag' does not exist

template<typename ITEM, typename TAG>
OpSet<ITEM> Tagcoll::Collection< ITEM, TAG >::getItems const TAG &  tag  )  const [inline]
 

Get the items with tag `tag'.

Return an empty set if `tag' does not exist

template<typename ITEM, typename TAG>
virtual OpSet<ITEM> Tagcoll::Collection< ITEM, TAG >::getItemsHavingTag const TAG &  tag  )  const [protected, pure virtual]
 

Get the items which are tagged with at least the tag `tag'.

Returns:
The items found, or an empty set if no items have that tag

Implemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::InputMerger< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::TDBIndexer< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual OpSet<ITEM> Tagcoll::Collection< ITEM, TAG >::getItemsHavingTags const OpSet< TAG > &  tags  )  const [inline, protected, virtual]
 

Get the items which are tagged with at least the tags `tags'.

Returns:
The items found, or an empty set if no items have that tag

Reimplemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::InputMerger< ITEM, TAG >, and Tagcoll::ItemGrouper< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual OpSet<ITEM> Tagcoll::Collection< ITEM, TAG >::getRelatedItems const OpSet< TAG > &  tags,
int  maxdistance = 1
const [inline, virtual]
 

Get the related items at the given maximum distance.

Examples:

 // Get the items related to a given one, at the given distance
 OpSet<Item> getRelated(const Item& item, int distance)
 {
    OpSet<Item> res = collection.getRelatedItems(collection.getTags(item), distance);
    return res - item;
 }

 // Get the items related to the given ones, at the given distance
 OpSet<Item> getRelated(const OpSet<Item>& items, int distance)
 {
    OpSet<Item> res = collection.getRelatedItems(collection.getTags(items), distance);
    return res - items;
 }

 // Get the related items, increasing the distance until it finds at
 // least 'minimum' items
 OpSet<Item> getRelated(const Item& item, int minimum)
 {
    OpSet<Tag> tags = collection.getTags(item);
    OpSet<Item> res;
    for (int i = 0; i < tags.size() && res.size() < minimum; i++)
         res += collection.getRelatedItems(tags, i);
      return res - item;
 }

Reimplemented in Tagcoll::CardinalityStore< ITEM, TAG >, and Tagcoll::ItemGrouper< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual OpSet<ITEM> Tagcoll::Collection< ITEM, TAG >::getTaggedItems  )  const [pure virtual]
 

Get the set of all the items that have tags according to this collection.

Implemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::InputMerger< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::TDBIndexer< ITEM, TAG >.

template<typename ITEM, typename TAG>
OpSet<TAG> Tagcoll::Collection< ITEM, TAG >::getTags const OpSet< ITEM > &  items  )  const [inline]
 

Get all the tags of items `items'.

Return an empty set if all of `item' do not exist

template<typename ITEM, typename TAG>
OpSet<TAG> Tagcoll::Collection< ITEM, TAG >::getTags const ITEM &  item  )  const [inline]
 

Get the tags of item `item'.

Return an empty set if `item' does not exist

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::Collection< ITEM, TAG >::getTagsOfItem const ITEM &  item  )  const [protected, pure virtual]
 

Get the tags attached to an item.

Parameters:
item The item to query
Returns:
The set of tags, or an empty set if the item has no tags or it does not exist.

Implemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::TDBIndexer< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::Collection< ITEM, TAG >::getTagsOfItems const OpSet< ITEM > &  items  )  const [inline, protected, virtual]
 

Get all the tags attached to the items in a set.

Parameters:
items The items to query
Returns:
The set of tags, or an empty set if the items have no tags or do not exist.

Reimplemented in Tagcoll::CardinalityStore< ITEM, TAG >, and Tagcoll::ItemGrouper< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual bool Tagcoll::Collection< ITEM, TAG >::hasTag const TAG &  tag  )  const [inline, virtual]
 

Check if the collection contains a tag.

Parameters:
tag The tag to look for
Returns:
true if the collection contains tag, false otherwise

Reimplemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::TDBIndexer< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual void Tagcoll::Collection< ITEM, TAG >::output Consumer< ITEM, TAG > &  consumer  )  const [pure virtual]
 

Output all the contents of the collection to a Consumer.

Implemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::TDBIndexer< ITEM, TAG >.

template<typename ITEM, typename TAG>
virtual void Tagcoll::Collection< ITEM, TAG >::outputHavingTags const OpSet< TAG > &  tags,
Consumer< ITEM, TAG > &  consumer
const [inline, virtual]
 

Send to a consumer all the items which are tagged with at least the given tags.

Reimplemented in Tagcoll::CardinalityStore< ITEM, TAG >, Tagcoll::InputMerger< ITEM, TAG >, and Tagcoll::ItemGrouper< ITEM, TAG >.


The documentation for this class was generated from the following file:
Generated on Fri Sep 9 22:13:17 2005 for libtagcoll by  doxygen 1.4.4