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

#include <indexset.h>

Inheritance diagram for faudes::TaIndexSet< Attr >:

faudes::IndexSet faudes::TBaseSet< Idx > faudes::TaNameSet< 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() and EraseSet() 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 249 of file indexset.h.

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="IndexSet")
 Construct from file.
virtual ~TaIndexSet (void)
 Virtual destructor.
template<class OtherAttr>
void CopyWithoutAttributes (TaIndexSet< OtherAttr > &rSet) const
 Copy to any other TaIndexSet.
Idx AttributesSize (void) const
 Get number of explicit (presumably non-default) attributes.
Attr * Attributep (Idx idx)
 Get attribute reference by index.
const Attr & Attribute (Idx idx) const
 Get attribute by index.
void Attribute (Idx idx, const Attr &attr)
 Set attribute.
void ClrAttribute (Idx idx)
 Clear attribute to default value.
void ClearAttributes (void)
 Clear all attributes to default value.
bool Erase (Idx idx)
 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.
Idx Insert (void)
 Insert new index to set using default attribute.
Idx Insert (const Attr &attr)
 Insert new index with attribute.
bool Insert (Idx idx)
 Insert element.
bool Insert (Idx idx, const Attr &attr)
 Insert element with attribute.
void InsertSet (const IndexSet &rOtherSet)
 Inserts elements of rOtherSet.
void InsertSet (const TaIndexSet &rOtherSet)
 Inserts elements of rOtherSet.
void Clear (void)
 Clear all set.
void SetUnion (const TaIndexSet &rOtherSet)
 Set union.
void SetUnion (const IndexSet &rOtherSet)
 Set union.
void SetIntersection (const TaIndexSet &rOtherSet)
 Set intersection.
void SetIntersection (const IndexSet &rOtherSet)
 Set intersection.

Protected Member Functions

void DoWrite (TokenWriter &rTw, const std::string &rLabel="") const
 Write to TokenWriter, see TBaseSet for public wrappers.
void DoRead (TokenReader &rTr, const std::string &rLabel="IndexSet")
 Read from TokenReader.

Protected Attributes

std::map< Idx, Attr > mAttributeMap
 Stored attributes.

Static Protected Attributes

static Attr mDefAttribute
 Statics per template parameter.

Friends

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


Constructor & Destructor Documentation

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

Constructor.

Definition at line 568 of file indexset.h.

template<class Attr>
faudes::TaIndexSet< Attr >::TaIndexSet const TaIndexSet< Attr > &  rOtherSet  ) 
 

Copy-constructor (from TaIndexSet, incl attributes).

Definition at line 575 of file indexset.h.

template<class Attr>
faudes::TaIndexSet< Attr >::TaIndexSet const IndexSet rOtherSet  ) 
 

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

Definition at line 584 of file indexset.h.

template<class Attr>
faudes::TaIndexSet< Attr >::TaIndexSet const std::string &  rFilename,
const std::string &  rLabel = "IndexSet"
 

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

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

Virtual destructor.

Definition at line 291 of file indexset.h.


Member Function Documentation

template<class Attr>
void faudes::TaIndexSet< Attr >::Attribute Idx  idx,
const Attr &  attr
 

Set attribute.

Sets the attribute of the sepcified element to the given value.

Parameters:
idx Index to specify element
attr Attribute value.

Definition at line 748 of file indexset.h.

template<class Attr>
const Attr & faudes::TaIndexSet< Attr >::Attribute Idx  idx  )  const
 

Get attribute by index.

This function returns a const reference to the attribute of the specified index.

Parameters:
idx Index to specify element
Returns:
Reference to attribute

Definition at line 730 of file indexset.h.

template<class Attr>
Attr * faudes::TaIndexSet< Attr >::Attributep Idx  idx  ) 
 

Get attribute reference by index.

Note that in order to produce a non-const reference this method will insert an explicit default attribute if necessary. If a const reference is sufficient, you should use Attribute(Idx) const instead.

Parameters:
idx Index to specify element
Returns:
Pointer to attribute

Definition at line 710 of file indexset.h.

template<class Attr>
Idx faudes::TaIndexSet< Attr >::AttributesSize void   )  const
 

Get number of explicit (presumably non-default) attributes.

Returns:
Number of entries in mAttributeMap

Definition at line 704 of file indexset.h.

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

Clear all set.

Reimplemented from faudes::TBaseSet< Idx >.

Definition at line 777 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::ClearAttributes void   ) 
 

Clear all attributes to default value.

Definition at line 765 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::ClrAttribute Idx  idx  ) 
 

Clear attribute to default value.

Parameters:
idx index to specify element

Definition at line 771 of file indexset.h.

template<class Attr>
template<class OtherAttr>
void faudes::TaIndexSet< Attr >::CopyWithoutAttributes TaIndexSet< OtherAttr > &  rSet  )  const
 

Copy to any other TaIndexSet.

This function ignores input attributes and sets the result attributes to the default value.

Parameters:
rSet 

Definition at line 602 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::DoRead TokenReader rTr,
const std::string &  rLabel = "IndexSet"
[protected, virtual]
 

Read from TokenReader.

Uses TokenReader::SeekBegin() to seek the specified section, reads subsequent integer tokens as indexes, calls matching TokenReader::SeekEnd(). Any subsections or Tokens of type different than integer are skipped. Thus, a file written from a set with attributes can be read as IndexSet.

Parameters:
rTr Reference to tokenreader
rLabel Section to read
Exceptions:
Exception 
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52)

Reimplemented from faudes::IndexSet.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 648 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::DoWrite TokenWriter rTw,
const std::string &  rLabel = ""
const [protected, virtual]
 

Write to TokenWriter, see TBaseSet for public wrappers.

Appends the IndexSet to TokenWriter. This will write a section with label Name() that holds integer tokens to represent the IndexSet. For non-default attribute values, the respective index is followed by the attribute value. The latter may consist of sections (or tokens different from integer or string) to allow for transparent reading; see AttributeVoid and AttributeFlags. Example for 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>  

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write, defaults to name of set
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::IndexSet.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 610 of file indexset.h.

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

Erase element by iterator (incl attribute).

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

Reimplemented from faudes::TBaseSet< Idx >.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 866 of file indexset.h.

template<class Attr>
bool faudes::TaIndexSet< Attr >::Erase Idx  idx  ) 
 

Erase Element (incl its attribute).

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

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 857 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::EraseSet const IndexSet rOtherSet  ) 
 

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

template<class Attr>
bool faudes::TaIndexSet< Attr >::Insert Idx  idx,
const Attr &  attr
 

Insert element with attribute.

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

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 813 of file indexset.h.

template<class Attr>
bool faudes::TaIndexSet< Attr >::Insert Idx  idx  ) 
 

Insert element.

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

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

Reimplemented from faudes::IndexSet.

Reimplemented in faudes::TaNameSet< Attr >, and faudes::TaNameSet< EventAttr >.

Definition at line 793 of file indexset.h.

template<class Attr>
Idx faudes::TaIndexSet< Attr >::Insert const Attr &  attr  ) 
 

Insert new index with attribute.

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

Definition at line 802 of file indexset.h.

template<class Attr>
Idx faudes::TaIndexSet< Attr >::Insert void   ) 
 

Insert new index to set using default attribute.

Returns:
New index

Reimplemented from faudes::IndexSet.

Definition at line 784 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::InsertSet const TaIndexSet< Attr > &  rOtherSet  ) 
 

Inserts elements of rOtherSet.

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

Parameters:
rOtherSet Other IndexSet

Definition at line 826 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::InsertSet const IndexSet rOtherSet  ) 
 

Inserts elements of rOtherSet.

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

Parameters:
rOtherSet Other IndexSet

Definition at line 851 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::SetIntersection const IndexSet rOtherSet  ) 
 

Set intersection.

The intersection is wrt set of indices, the result is stored in this set. Attributes are set to default.

Parameters:
rOtherSet Other IndexSet

Definition at line 922 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::SetIntersection const TaIndexSet< Attr > &  rOtherSet  ) 
 

Set intersection.

The intersection is wrt set of indices, the result is stored in this set. Attributes are set to default.

Parameters:
rOtherSet Other IndexSet

Definition at line 929 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::SetUnion const IndexSet rOtherSet  ) 
 

Set union.

The union is wrt the set of indices, the result is accumulated in this set. Attributes are set to default. See also InsertSet(const IndexSet&).

Parameters:
rOtherSet Other IndexSet

Definition at line 908 of file indexset.h.

template<class Attr>
void faudes::TaIndexSet< Attr >::SetUnion const TaIndexSet< Attr > &  rOtherSet  ) 
 

Set union.

The union is wrt the set of indices, the result is accumulated in this set. Attributes are set to default. See also InsertSet(const TaIndexSet&).

Parameters:
rOtherSet Other TaIndexSet

Definition at line 915 of file indexset.h.


Friends And Related Function Documentation

template<class Attr>
friend class TaIndexSet [friend]
 

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

This is used for the pragmatic implemention conversion constructors.

Reimplemented from faudes::IndexSet.

Definition at line 255 of file indexset.h.


Member Data Documentation

template<class Attr>
std::map<Idx,Attr> faudes::TaIndexSet< Attr >::mAttributeMap [protected]
 

Stored attributes.

Definition at line 495 of file indexset.h.


The documentation for this class was generated from the following file:
Generated on Fri May 9 11:26:48 2008 for libFAUDES 2.09b by  doxygen 1.4.4