faudes::TaIndexSet< Attr > Class Template Reference
[State, Event and Transition Set]

Set of indices with attributes. More...

#include <cfl_indexset.h>

List of all members.

Public Types

typedef IndexSet::Iterator Iterator
 Iterators on indexset.

Public Member Functions

 TaIndexSet (void)
 Constructor.
 TaIndexSet (const TaIndexSet &rOtherSet)
 Copy-constructor (from TaIndexSet, incl attributes).
 TaIndexSet (const IndexSet &rOtherSet)
 Copy-constructor (from IndexSet, sets attributes to default).
 TaIndexSet (const std::string &rFilename, const std::string &rLabel="")
 Construct from file.
virtual ~TaIndexSet (void)
 Virtual destructor.
virtual TaIndexSetAssign (const IndexSet &rSrc)
 Relaxed assignment method.
virtual TaIndexSetoperator= (const IndexSet &rSrc)
 Relaxed assignment operator.
virtual void Attributes (const IndexSet &rOtherSet)
 Set attributes.
virtual void Attributes (const TaIndexSet &rOtherSet)
 Set attributes.
bool Erase (const Idx &rIndex)
 Erase Element (incl its attribute).
Iterator Erase (const Iterator &pos)
 Erase element by iterator (incl attribute).
void EraseSet (const IndexSet &rOtherSet)
 Erase elements given by other set.
void RestrictSet (const IndexSet &rOtherSet)
 Restrict to specified subset.
Idx Insert (void)
 Insert new index to set using default attribute.
Idx Insert (const Attr &rAttr)
 Insert new index with attribute.
bool Insert (const Idx &rIndex)
 Insert element.
bool Insert (const Idx &rIndex, const Attr &attr)
 Insert element with attribute.
virtual void InsertSet (const IndexSet &rOtherSet)
 Inserts elements of rOtherSet.
virtual void InsertSet (const TaIndexSet &rOtherSet)
 Inserts elements of rOtherSet.
virtual void Clear (void)
 Clear all set.

Protected Member Functions

virtual void DoAssign (const TaIndexSet &rSource)
 Assign my members.

Friends

class IndexSet
 We implement "protected privacy for template classes" by friendship.

Detailed Description

template<class Attr>
class faudes::TaIndexSet< Attr >

Set of indices with attributes.

A TaIndexSet<Attr> is a template derived from IndexSet, such that each set element has an Attribute of class Attr. The template parameter Attr must provide basic functions for file IO and must define a default value, see AttributeVoid and AttributeFlags for an examples. Attributes are maintained by an STL map to associate indices with attributes different from the default value. Thus, attributes with default value do not take up any memeory.

Parameters:
mAttributeMap STL map of type std::map<Idx,Attr> to hold attributes

The copy constructor copies attributes; the methods InsertSet(), EraseSet() and RestrictSet() maintain attributes; all other set operations derived from IndexSet either return a IndexSet (no attributes) or set all attributes to the dafault value. To set or get an attribute of an index that does not exist in the set is considered as an error and triggers an exception (id 60) when the macro FAUDES_CHECKED is defined.

The format for token IO is demonstrated by the following example of a set with name "MySet" consisting of indices 17, 25, 40, where index 25 has a nontrivial attribute attached:

 <Myset> 
 17 
 25 <AValue> "Some Value" </AValue> 
 40 
 </MySet>  

Note that attributes may be either subsections or tokens of type different from integer and string. This is to allow reading a token stream to a class with incompatible (or no) attributes.

Definition at line 316 of file cfl_indexset.h.


Member Typedef Documentation

template<class Attr>
typedef IndexSet::Iterator faudes::TaIndexSet< Attr >::Iterator

Iterators on indexset.

Reimplemented from faudes::IndexSet.

Definition at line 407 of file cfl_indexset.h.


Constructor & Destructor Documentation

template<class Attr >
faudes::TaIndexSet< Attr >::TaIndexSet ( void   )  [inline]

Constructor.

Definition at line 562 of file cfl_indexset.h.

template<class Attr >
faudes::TaIndexSet< Attr >::TaIndexSet ( const TaIndexSet< Attr > &  rOtherSet  )  [inline]

Copy-constructor (from TaIndexSet, incl attributes).

Definition at line 572 of file cfl_indexset.h.

template<class Attr >
faudes::TaIndexSet< Attr >::TaIndexSet ( const IndexSet rOtherSet  )  [inline]

Copy-constructor (from IndexSet, sets attributes to default).

Definition at line 584 of file cfl_indexset.h.

template<class Attr >
faudes::TaIndexSet< Attr >::TaIndexSet ( const std::string &  rFilename,
const std::string &  rLabel = "" 
) [inline]

Construct from file.

This constructor uses the Read(TokenReader&, const std::string&) function to read.

Parameters:
rFilename Name of file
rLabel Section for the set in file
Exceptions:
Exception 
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52)

Definition at line 597 of file cfl_indexset.h.

template<class Attr>
virtual faudes::TaIndexSet< Attr >::~TaIndexSet ( void   )  [inline, virtual]

Virtual destructor.

Definition at line 362 of file cfl_indexset.h.


Member Function Documentation

template<class Attr >
TaIndexSet< Attr > & faudes::TaIndexSet< Attr >::Assign ( const IndexSet rSrc  )  [inline, virtual]

Relaxed assignment method.

Maintain attributes provided they can be casted.

Parameters:
rSrc Source from which to assign
Returns:
Ref to this set

Definition at line 617 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::Attributes ( const TaIndexSet< Attr > &  rOtherSet  )  [inline, virtual]

Set attributes.

Attributes are copied per element from rOtherSet. Elements of this set which are not in rOtherSet maintain their attribute.

Parameters:
rOtherSet Other IndexSet

Definition at line 636 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::Attributes ( const IndexSet rOtherSet  )  [inline, virtual]

Set attributes.

Provided that rOtherSet has attributes that can be casted to the appropriate type, attributes are copied per element from rOtherSet. Elements of this set which are not in rOtherSet maintain their attribute.

Parameters:
rOtherSet Other IndexSet
Exceptions:
Exception 
  • Element does not exist (63)
  • Cannot cast attribute type (63)

Definition at line 643 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::Clear ( void   )  [inline, virtual]

Clear all set.

Reimplemented from faudes::TaBaseSet< Idx, Attr >.

Definition at line 651 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::DoAssign ( const TaIndexSet< Attr > &  rSource  )  [inline, protected, virtual]

Assign my members.

This method maintains attributes.

Parameters:
rSource Source to copy from
Returns:
Ref to this set

Definition at line 609 of file cfl_indexset.h.

template<class Attr >
TaIndexSet< Attr >::Iterator faudes::TaIndexSet< Attr >::Erase ( const Iterator pos  )  [inline, virtual]

Erase element by iterator (incl attribute).

Parameters:
pos Iterator to specify element
Returns:
Iterator to next element or End()

Reimplemented from faudes::TaBaseSet< Idx, Attr >.

Definition at line 714 of file cfl_indexset.h.

template<class Attr >
bool faudes::TaIndexSet< Attr >::Erase ( const Idx rIndex  )  [inline]

Erase Element (incl its attribute).

Parameters:
rIndex Index to specify element
Returns:
True if element used to exist

Reimplemented from faudes::TaBaseSet< Idx, Attr >.

Definition at line 708 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::EraseSet ( const IndexSet rOtherSet  )  [inline]

Erase elements given by other set.

This function ignores the attributes of the other set and maintains the attributes of the remaining elements in this set.

Parameters:
rOtherSet Elements to erase

Definition at line 721 of file cfl_indexset.h.

template<class Attr>
bool faudes::TaIndexSet< Attr >::Insert ( const Idx rIndex,
const Attr &  attr 
) [inline]

Insert element with attribute.

Parameters:
rIndex Index to specify element
attr Specify attribute of (new) element
Returns:
True if element was new to set

Reimplemented from faudes::TaBaseSet< Idx, Attr >.

Definition at line 686 of file cfl_indexset.h.

template<class Attr>
bool faudes::TaIndexSet< Attr >::Insert ( const Idx rIndex  )  [inline, virtual]

Insert element.

If the element exists, the attribute is maintained. If the element does not exist, it is inserted with default attribute.

Parameters:
rIndex Index to specify element
Returns:
True if element was new to set

Reimplemented from faudes::IndexSet.

Definition at line 667 of file cfl_indexset.h.

template<class Attr>
Idx faudes::TaIndexSet< Attr >::Insert ( const Attr &  rAttr  )  [inline]

Insert new index with attribute.

If the index allready exists, the attribute is overwritten by rAttr.

Parameters:
rAttr Specify attribute of new element
Returns:
new index

Definition at line 675 of file cfl_indexset.h.

template<class Attr >
Idx faudes::TaIndexSet< Attr >::Insert ( void   )  [inline]

Insert new index to set using default attribute.

Returns:
New index

Reimplemented from faudes::IndexSet.

Definition at line 658 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::InsertSet ( const TaIndexSet< Attr > &  rOtherSet  )  [inline, virtual]

Inserts elements of rOtherSet.

Attributes of this set are maintained, new elements are inserted with attribute.

Parameters:
rOtherSet Other IndexSet

Definition at line 694 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::InsertSet ( const IndexSet rOtherSet  )  [inline, virtual]

Inserts elements of rOtherSet.

Attributes of this set are maintained, newly inserted elements have default attribute.

Parameters:
rOtherSet Other IndexSet

Definition at line 701 of file cfl_indexset.h.

template<class Attr >
TaIndexSet< Attr > & faudes::TaIndexSet< Attr >::operator= ( const IndexSet rSrc  )  [inline, virtual]

Relaxed assignment operator.

Maintain attributes provided they can be casted.

Parameters:
rSrc Source from which to assign
Returns:
Ref to this set

Definition at line 629 of file cfl_indexset.h.

template<class Attr >
void faudes::TaIndexSet< Attr >::RestrictSet ( const IndexSet rOtherSet  )  [inline]

Restrict to specified subset.

Erases any elements no in the specified set. This function ignores the attributes of the other set and maintains the attributes of the remaining elements in this set.

Parameters:
rOtherSet Elements to erase

Definition at line 728 of file cfl_indexset.h.


Friends And Related Function Documentation

template<class Attr>
friend class IndexSet [friend]

We implement "protected privacy for template classes" by friendship.

This is used for the pragmatic implemention conversion constructors.

Definition at line 326 of file cfl_indexset.h.


The documentation for this class was generated from the following file:

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen