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

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

#include <ReadonlyCollection.h>

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

Inheritance graph
[legend]
List of all members.

Public Member Functions

virtual ~ReadonlyCollection ()
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 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

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::ReadonlyCollection< 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::ReadonlyCollection< ITEM, TAG >::~ReadonlyCollection (  )  [inline, virtual]


Member Function Documentation

template<typename ITEM, typename TAG>
virtual OpSet<ITEM> Tagcoll::ReadonlyCollection< 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::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, Tagcoll::TDBIndexer< ITEM, TAG >, Tagcoll::InputMerger< std::string, std::string >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual OpSet<ITEM> Tagcoll::ReadonlyCollection< 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 >, Tagcoll::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::InputMerger< std::string, std::string >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::ReadonlyCollection< 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::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, Tagcoll::TDBIndexer< ITEM, TAG >, Tagcoll::InputMerger< std::string, std::string >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::ReadonlyCollection< 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 >, Tagcoll::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual bool Tagcoll::ReadonlyCollection< 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::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, Tagcoll::TDBIndexer< ITEM, TAG >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
OpSet<TAG> Tagcoll::ReadonlyCollection< 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>
OpSet<TAG> Tagcoll::ReadonlyCollection< 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<ITEM> Tagcoll::ReadonlyCollection< 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>
OpSet<ITEM> Tagcoll::ReadonlyCollection< 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>
virtual OpSet<ITEM> Tagcoll::ReadonlyCollection< 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::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, Tagcoll::TDBIndexer< ITEM, TAG >, Tagcoll::InputMerger< std::string, std::string >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::ReadonlyCollection< 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::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, Tagcoll::TDBIndexer< ITEM, TAG >, Tagcoll::InputMerger< std::string, std::string >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual int Tagcoll::ReadonlyCollection< 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::IntDiskIndex< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual OpSet<TAG> Tagcoll::ReadonlyCollection< 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 >, Tagcoll::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::InputMerger< std::string, std::string >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual OpSet<ITEM> Tagcoll::ReadonlyCollection< 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 >, Tagcoll::ItemGrouper< ITEM, TAG >, and Tagcoll::InputMerger< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual void Tagcoll::ReadonlyCollection< 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::IntDiskIndex< ITEM, TAG >, Tagcoll::ItemGrouper< ITEM, TAG >, Tagcoll::PatchCollection< ITEM, TAG >, Tagcoll::TDBDiskIndex< ITEM, TAG >, Tagcoll::TDBIndexer< ITEM, TAG >, Tagcoll::InputMerger< std::string, std::string >, and Tagcoll::IntDiskIndex< std::string, std::string >.

template<typename ITEM, typename TAG>
virtual void Tagcoll::ReadonlyCollection< 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 >, Tagcoll::ItemGrouper< ITEM, TAG >, and Tagcoll::InputMerger< std::string, std::string >.


The documentation for this class was generated from the following file:
Generated on Sat Jan 17 03:11:08 2009 for libtagcoll by  doxygen 1.5.1