libFAUDES

Sections

Index

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

#include <indexset.h>

Inherits faudes::IndexSet.

Inherited by 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(), 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.

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 TaIndexSetNew (void) const
 Construct on heap with same type.
virtual ~TaIndexSet (void)
 Virtual destructor.
virtual TaIndexSetoperator= (const TaIndexSet &rSrc)
 Assignment operator (uses Copy).
virtual TaIndexSetoperator= (const IndexSet &rSrc)
 Assignment operator (uses Copy).
virtual void Copy (TaIndexSet< Attr > &rSet) const
 Copy to other index with same attribute type.
virtual void Copy (IndexSet &rSet) const
 Copy to other index set.
virtual Idx AttributesSize (void) const
 Get number of explicit (aka non-default) attributes.
virtual const Attr * Attributep (void) const
 Attribute typeinfo.
virtual const AttributeVoidAttribute (void) const
 Attribute typeinfo.
virtual bool AttributeTry (const Type &rAttr) const
 Attribute typeinfo.
virtual Attr * Attributep (const Idx &idx)
 Get attribute reference by index.
virtual const Attr & Attribute (const Idx &idx) const
 Get attribute by index.
virtual void Attribute (const Idx &idx, const Attr &attr)
 Set attribute.
virtual void Attribute (const Idx &idx, const Type &attr)
 Set attribute.
virtual void AttributeTry (const Idx &idx, const Type &attr)
 Set attribute.
virtual void Attributes (const IndexSet &rOtherSet)
 Set attributes.
virtual void Attributes (const TaIndexSet &rOtherSet)
 Set attributes.
virtual void ClrAttribute (const Idx &idx)
 Clear attribute to default value.
virtual 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.
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 (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.
virtual 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 Attributes

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

Static Protected Attributes

static Attr mDefAttribute
 default attribute

Friends

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

Constructor & Destructor Documentation

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

Constructor.

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

Copy-constructor (from TaIndexSet, incl attributes).

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

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

template<class Attr>
faudes::TaIndexSet< Attr >::TaIndexSet ( const std::string &  rFilename,
const std::string &  rLabel = "IndexSet" 
) [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)

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

Virtual destructor.


Member Function Documentation

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

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

Assignment operator (uses Copy).

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

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

Assignment operator (uses Copy).

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

Reimplemented from faudes::IndexSet.

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

Copy to other index with same attribute type.

Parameters:
rSet 

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

Copy to other index set.

This function maintains attributes if types can be casted.

Parameters:
rSet 

Reimplemented from faudes::IndexSet.

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

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

Returns:
Number of entries in mAttributeMap

Reimplemented from faudes::TBaseSet< T, Cmp >.

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

Attribute typeinfo.

Returns:
Pointer to some attribute of this sets attribute type.

Reimplemented from faudes::TBaseSet< T, Cmp >.

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

Attribute typeinfo.

Returns:
Reference to some attribute of this sets attribute type

Reimplemented from faudes::TBaseSet< T, Cmp >.

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

Attribute typeinfo.

This set accepts all attributes that we can cast to our attribute type.

Parameters:
rAttr Attribute type to test.
Returns:
True, if attribute type is accepted.

Reimplemented from faudes::TBaseSet< T, Cmp >.

template<class Attr>
Attr * faudes::TaIndexSet< Attr >::Attributep ( const Idx idx  )  [inline, virtual]

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
Exceptions:
Exception 
  • Element does not exist (63)
Returns:
Pointer to attribute

template<class Attr>
const Attr & faudes::TaIndexSet< Attr >::Attribute ( const Idx idx  )  const [inline, virtual]

Get attribute by index.

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

Parameters:
idx Index to specify element
Exceptions:
Exception 
  • Element does not exist (63)
Returns:
Reference to attribute

template<class Attr>
void faudes::TaIndexSet< Attr >::Attribute ( const Idx idx,
const Attr &  attr 
) [inline, virtual]

Set attribute.

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

Parameters:
idx Index to specify element
attr Attribute value.
Exceptions:
Exception 
  • Element does not exist (63)

template<class Attr>
void faudes::TaIndexSet< Attr >::Attribute ( const Idx idx,
const Type attr 
) [inline, virtual]

Set attribute.

Provided that the attribute can be casted to the appropriate type, this method sets the attribute of the sepcified element to the given value.

Parameters:
idx Index to specify element
attr Attribute value.
Exceptions:
Exception 
  • Element does not exist (63)
  • Cannot cast attribute type (63)

template<class Attr>
void faudes::TaIndexSet< Attr >::AttributeTry ( const Idx idx,
const Type attr 
) [inline, virtual]

Set attribute.

Provided that the attribute can be casted to the appropriate type, this method sets the attribute of the sepcified element to the given value.

Parameters:
idx Index to specify element
attr Attribute value.
Exceptions:
Exception 
  • Element does not exist (63)

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)

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

template<class Attr>
void faudes::TaIndexSet< Attr >::ClrAttribute ( const Idx idx  )  [inline, virtual]

Clear attribute to default value.

Parameters:
idx index to specify element

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

Clear all attributes to default value.

Reimplemented from faudes::TBaseSet< T, Cmp >.

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

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::TBaseSet< T, Cmp >.

Reimplemented in faudes::TaNameSet< Attr >, faudes::TaNameSet< faudes::HioEventFlags >, faudes::TaNameSet< faudes::SimConditionAttribute >, faudes::TaNameSet< faudes::SimEventAttribute >, faudes::TaNameSet< EventAttr >, and faudes::TaNameSet< faudes::AttributeCFlags >.

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

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

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.

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

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

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 >, faudes::TaNameSet< faudes::HioEventFlags >, faudes::TaNameSet< faudes::SimConditionAttribute >, faudes::TaNameSet< faudes::SimEventAttribute >, faudes::TaNameSet< EventAttr >, and faudes::TaNameSet< faudes::AttributeCFlags >.

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

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 >, faudes::TaNameSet< faudes::HioEventFlags >, faudes::TaNameSet< faudes::SimConditionAttribute >, faudes::TaNameSet< faudes::SimEventAttribute >, faudes::TaNameSet< EventAttr >, and faudes::TaNameSet< faudes::AttributeCFlags >.

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

Inserts elements of rOtherSet.

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

Parameters:
rOtherSet Other IndexSet

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

Inserts elements of rOtherSet.

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

Parameters:
rOtherSet Other IndexSet

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

Clear all set.

Reimplemented from faudes::TBaseSet< T, Cmp >.

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

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

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

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

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

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

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

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


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.


Member Data Documentation

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

Stored attributes.


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

libFAUDES 2.13a c++ source docu by doxygen 1.5.6