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

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

In-memory collection whose representation is organised similarly to the on-disk representation used by TDBDiskIndex. More...

#include <TDBIndexer.h>

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

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~TDBIndexer ()
virtual bool hasItem (const ITEM &item) const
virtual bool hasTag (const TAG &tag) const
 Check if the collection contains a tag.
virtual OpSet< ITEM > getTaggedItems () const
 Get the set of all the items that have tags according to this collection.
virtual OpSet< TAG > getAllTags () const
 Get the set of all the tags in this collection.
virtual void output (Consumer< ITEM, TAG > &consumer) const
 Output all the contents of the collection to a Consumer.
virtual void applyChange (const PatchList< ITEM, TAG > &change)
 Apply a patch to the collection.
void writeIndex (Converter< ITEM, std::string > &itemconv, Converter< TAG, std::string > &tagconv, const std::string &pkgidx, const std::string &tagidx) const
 Write all collected informations to a disk index.

Protected Member Functions

virtual void consumeItem (const ITEM &item, const OpSet< TAG > &tags)
 Process a tagged item, with its tags.
virtual void consumeItems (const OpSet< ITEM > &items, const OpSet< TAG > &tags)
 Process a set of items identically tagged, with their tags.
virtual OpSet< ITEM > getItemsHavingTag (const TAG &tag) const
 Get the items which are tagged with at least the tag `tag'.
virtual OpSet< TAG > getTagsOfItem (const ITEM &item) const
 Get the tags attached to an item.

Protected Attributes

std::map< ITEM, OpSet< TAG > > items
std::map< TAG, OpSet< ITEM > > tags

Detailed Description

template<class ITEM, class TAG>
class Tagcoll::TDBIndexer< ITEM, TAG >

In-memory collection whose representation is organised similarly to the on-disk representation used by TDBDiskIndex.

It can be used as a working collection, and it can also write its contents into an on-disk index that can later be used by TDBDiskIndex.

On-disk indexes produced by TDBIndexer are written in a single, optimised run and tend to be more compact than the ones created by TDBDiskIndex.


Constructor & Destructor Documentation

template<class ITEM, class TAG>
virtual Tagcoll::TDBIndexer< ITEM, TAG >::~TDBIndexer  )  [inline, virtual]
 


Member Function Documentation

template<class ITEM, class TAG>
void TDBIndexer::applyChange const PatchList< ITEM, TAG > &  change  )  [virtual]
 

Apply a patch to the collection.

Example:

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

Implements Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
void TDBIndexer::consumeItem const ITEM &  item,
const OpSet< TAG > &  tags
[protected, virtual]
 

Process a tagged item, with its tags.

Implements Tagcoll::Consumer< ITEM, TAG >.

template<class ITEM, class TAG>
void TDBIndexer::consumeItems const OpSet< ITEM > &  items,
const OpSet< TAG > &  tags
[protected, virtual]
 

Process a set of items identically tagged, with their tags.

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

template<class ITEM, class TAG>
OpSet< TAG > TDBIndexer::getAllTags  )  const [virtual]
 

Get the set of all the tags in this collection.

Implements Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< ITEM > TDBIndexer::getItemsHavingTag const TAG &  tag  )  const [protected, 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

Implements Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< ITEM > TDBIndexer::getTaggedItems  )  const [virtual]
 

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

Implements Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< TAG > TDBIndexer::getTagsOfItem const ITEM &  item  )  const [protected, 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.

Implements Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
virtual bool Tagcoll::TDBIndexer< ITEM, TAG >::hasItem const ITEM &  item  )  const [inline, virtual]
 

template<class ITEM, class TAG>
virtual bool Tagcoll::TDBIndexer< 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 from Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
void TDBIndexer::output Consumer< ITEM, TAG > &  consumer  )  const [virtual]
 

Output all the contents of the collection to a Consumer.

Implements Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
void TDBIndexer::writeIndex Converter< ITEM, std::string > &  itemconv,
Converter< TAG, std::string > &  tagconv,
const std::string &  pkgidx,
const std::string &  tagidx
const
 

Write all collected informations to a disk index.

Parameters:
itemconv Converter than can convert an ITEM to a string
tagconv Converter than can convert a TAG to a string
pkgidx File name for the package index to write
tagidx File name for the tag index to write


Member Data Documentation

template<class ITEM, class TAG>
std::map<ITEM, OpSet<TAG> > Tagcoll::TDBIndexer< ITEM, TAG >::items [protected]
 

template<class ITEM, class TAG>
std::map<TAG, OpSet<ITEM> > Tagcoll::TDBIndexer< ITEM, TAG >::tags [protected]
 


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