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

Wraps a collection by intercepting all changes to it and preserving them as a PatchList. More...

#include <PatchCollection.h>

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

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PatchCollection (const ReadonlyCollection< ITEM, TAG > &coll)
virtual ~PatchCollection ()
const PatchList< ITEM, TAG > & getChanges () const
 Get the changes that have been applied to this collection.
void resetChanges ()
 Throw away all changes previously applied to this collection.
void setChanges (const PatchList< ITEM, TAG > &changes)
 Set the changes list to a specific patch list.
void addChanges (const PatchList< ITEM, TAG > &changes)
 Add a specific patch list to the changes list.
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 int getCardinality (const TAG &tag) const
 Get the cardinality of tag `tag' (that is, the number of items who have it).
virtual void applyChange (const PatchList< ITEM, TAG > &change)
 Apply a patch to the collection.
virtual void output (Consumer< ITEM, TAG > &consumer) const
 Output all the contents of the collection to a Consumer.

Protected Member Functions

virtual void consumeItem (const ITEM &item, const OpSet< TAG > &tags)
 Process a tagged item, with its 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

const ReadonlyCollection<
ITEM, TAG > & 
coll
PatchList< ITEM, TAG > changes

Detailed Description

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

Wraps a collection by intercepting all changes to it and preserving them as a PatchList.


Constructor & Destructor Documentation

template<class ITEM, class TAG>
Tagcoll::PatchCollection< ITEM, TAG >::PatchCollection ( const ReadonlyCollection< ITEM, TAG > &  coll  )  [inline]

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


Member Function Documentation

template<class ITEM, class TAG>
void Tagcoll::PatchCollection< ITEM, TAG >::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>
OpSet< ITEM > Tagcoll::PatchCollection< ITEM, TAG >::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::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< TAG > Tagcoll::PatchCollection< ITEM, TAG >::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::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
const PatchList<ITEM, TAG>& Tagcoll::PatchCollection< ITEM, TAG >::getChanges (  )  const [inline]

Get the changes that have been applied to this collection.

template<class ITEM, class TAG>
void Tagcoll::PatchCollection< ITEM, TAG >::resetChanges (  )  [inline]

Throw away all changes previously applied to this collection.

template<class ITEM, class TAG>
void Tagcoll::PatchCollection< ITEM, TAG >::setChanges ( const PatchList< ITEM, TAG > &  changes  ) 

Set the changes list to a specific patch list.

template<class ITEM, class TAG>
void Tagcoll::PatchCollection< ITEM, TAG >::addChanges ( const PatchList< ITEM, TAG > &  changes  ) 

Add a specific patch list to the changes list.

template<class ITEM, class TAG>
bool Tagcoll::PatchCollection< ITEM, TAG >::hasTag ( const TAG &  tag  )  const [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::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< ITEM > Tagcoll::PatchCollection< ITEM, TAG >::getTaggedItems (  )  const [virtual]

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

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< TAG > Tagcoll::PatchCollection< ITEM, TAG >::getAllTags (  )  const [virtual]

Get the set of all the tags in this collection.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
int Tagcoll::PatchCollection< ITEM, TAG >::getCardinality ( const TAG &  tag  )  const [virtual]

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

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

template<class ITEM, class TAG>
void Tagcoll::PatchCollection< ITEM, TAG >::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 Tagcoll::PatchCollection< ITEM, TAG >::output ( Consumer< ITEM, TAG > &  consumer  )  const [virtual]

Output all the contents of the collection to a Consumer.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.


Member Data Documentation

template<class ITEM, class TAG>
const ReadonlyCollection<ITEM, TAG>& Tagcoll::PatchCollection< ITEM, TAG >::coll [protected]

template<class ITEM, class TAG>
PatchList<ITEM, TAG> Tagcoll::PatchCollection< ITEM, TAG >::changes [protected]


The documentation for this class was generated from the following files:
Generated on Mon Jan 12 12:09:01 2009 for libtagcoll by  doxygen 1.5.1