libFAUDES

Sections

Index

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

#include <indexset.h>

Inherits faudes::IndexSet, and faudes::TaBaseSet< long unsigned int, Attr >.

List of all members.


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 290 of file indexset.h.


Public Types

typedef IndexSet::Iterator Iterator
 Iterators on indexset.

Public Member Functions

virtual TaIndexSetNew (void) const
 Faudes Type interface.
virtual TaIndexSetCopy (void) const
 Faudes Type interface.
virtual const TaIndexSetCast (const Type *pOther) const
 Faudes Type interface.
virtual TaIndexSetAssign (const Type &rSrc)
 Assign configuration data from other object.
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data.
virtual TaIndexSetoperator= (const TaIndexSet &rSrc)
virtual bool operator== (const TaIndexSet &rOther) const
virtual bool operator!= (const TaIndexSet &rOther) const
 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 TaIndexSetDoAssign (const TaIndexSet &rSource)
 Assign my members.

Friends

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

Member Typedef Documentation

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

Iterators on indexset.

Reimplemented from faudes::TaBaseSet< T, Attr, Cmp >.

Definition at line 380 of file indexset.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 535 of file indexset.h.

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

Copy-constructor (from TaIndexSet, incl attributes).

Definition at line 545 of file indexset.h.

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

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

Definition at line 557 of file 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 570 of file indexset.h.

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

Virtual destructor.

Definition at line 335 of file indexset.h.


Member Function Documentation

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

Faudes Type interface.

Construct object of same type on heap.

Reimplemented from faudes::TaBaseSet< T, Attr, Cmp >.

Definition at line 528 of file indexset.h.

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

Faudes Type interface.

Construct copy on heap.

Reimplemented from faudes::TaBaseSet< T, Attr, Cmp >.

Definition at line 528 of file indexset.h.

template<class Attr>
const TaIndexSet< Attr > * faudes::TaIndexSet< Attr >::Cast ( const Type pType  )  const [inline, virtual]

Faudes Type interface.

Cast object to my type.

Reimplemented from faudes::TaBaseSet< T, Attr, Cmp >.

Definition at line 528 of file indexset.h.

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

Assign configuration data from other object.

Derived classes should reimplement this method to first try to cast the source to the respective class. If successful, the protected function DoAssign is invoked to perform the actual assignment. If the cast fails, the Assign method of the parent class is called. Thus, faudes objects are up- and downcatsted for assignment, maintaining as much of the source data as digestable by the destination object. On the downside, there is no sensible typechecking at compile-time.

Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters:
rSrc Source to copy from
Returns:
Reference to this object.

Reimplemented from faudes::IndexSet.

Definition at line 528 of file indexset.h.

template<class Attr>
bool faudes::TaIndexSet< Attr >::Equal ( const Type rOther  )  const [inline, virtual]

Test equality of configuration data.

Derived classes should reimplement this method to return true if both actual types and configuration data match. The object name is not consired in the test.

This method calls the virtual method DoEqual(). Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters:
rOther Other objevt to compare with.
Returns:
True on match.

Reimplemented from faudes::IndexSet.

Definition at line 528 of file indexset.h.

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

Definition at line 528 of file indexset.h.

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

Definition at line 528 of file indexset.h.

template<class Attr>
bool faudes::TaIndexSet< Attr >::operator!= ( const TaIndexSet< Attr > &  rOther  )  const [inline, virtual]

Definition at line 528 of file indexset.h.

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

Relaxed assignment method.

Maintain provided they can be casted..

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

Definition at line 592 of file 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

Reimplemented from faudes::IndexSet.

Definition at line 604 of file 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 618 of file 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 611 of file 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

Definition at line 683 of file 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< T, Attr, Cmp >.

Definition at line 689 of file 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 696 of file 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 703 of file 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 633 of file 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 650 of file indexset.h.

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

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 642 of file 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

Definition at line 661 of file 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 676 of file 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 669 of file indexset.h.

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

Clear all set.

Reimplemented from faudes::TaBaseSet< T, Attr, Cmp >.

Definition at line 626 of file indexset.h.

template<class Attr>
TaIndexSet< Attr > & 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 582 of file 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 298 of file indexset.h.


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

libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6