Detailed Description

template<class T, class Attr, class Cmp = std::less<T>>
class faudes::TAttrMap< T, Attr, Cmp >

Attribute interface for TBaseSet.

TAttrMap provides a typed interface to access the attributes associated with elements of a TBaseSet. It is meant to faciltate classes derived from TBaseSet that use non-trivial attributes. Note that the actual attribute map is hosted by TBaseSet itself.

Note: technically, the TAttrMap holds a reference to the associated TBaseSet. When deriving from a child of TBaseSet, the interface is introduced by additional inheritance of TAttrMap. Effectively, this avoids the diomand-shape inheritance we used to have in pre 2.30 versions of libFAUDES and which caused various issues with the MS Visual Studio compilers regarding covaraint return values in the context of templates.

Definition at line 52 of file cfl_attrmap.h.

#include <cfl_attrmap.h>

Public Member Functions

 TAttrMap (TBaseSet< T, Cmp > *pBaseSetRef)
 Constructor. More...
 
virtual ~TAttrMap (void)
 Virtual destructor. More...
 
void AssignWithAttributes (const TBaseSet< T, Cmp > &rSourceSet)
 Copy from a TBaseSet to the associated TBaseSet, with attributes, provided that they can be casted accordingly. More...
 
const Attr * AttributeType (void) const
 Attribute typeinfo. More...
 
Attr * Attributep (const T &rElem)
 Get attribute reference by element. More...
 
const Attr & Attribute (const T &rElem) const
 Get attribute by element. More...
 
void Attribute (const T &rElem, const Type &attr)
 Set attribute. More...
 
void Attribute (const T &rElem, const Attr &attr)
 Set attribute. More...
 
void AttributeTry (const T &rElem, const Type &attr)
 Set attribute. More...
 
bool Insert (const T &rElem)
 Insert element. More...
 
bool Insert (const T &rElem, const Attr &attr)
 Insert element with attribute. More...
 
void InsertSet (const TBaseSet< T, Cmp > &rOtherSet)
 Inserts elements from rOtherSet. More...
 
bool Erase (const T &rElem)
 Erase Element (incl its attribute) More...
 
TBaseSet< T, Cmp >::Iterator Erase (const typename TBaseSet< T, Cmp >::Iterator &pos)
 Erase element by iterator (incl attribute) More...
 
void EraseSet (const TBaseSet< T, Cmp > &rOtherSet)
 Erase elements given by other set. More...
 
void RestrictSet (const TBaseSet< T, Cmp > &rOtherSet)
 Restrict to specified subset. More...
 

Protected Types

typedef TBaseSet< T, Cmp >::iterator iterator
 use TBaseSet STL iterators More...
 
typedef TBaseSet< T, Cmp >::const_iterator const_iterator
 use TBaseSet STL iterators More...
 
typedef TBaseSet< T, Cmp >::aiterator aiterator
 use TBaseSet STL iterators More...
 
typedef TBaseSet< T, Cmp >::const_aiterator const_aiterator
 use TBaseSet STL iterators More...
 

Protected Attributes

TBaseSet< T, Cmp > * pBaseSet
 reference to associated TBaseSet More...
 

Member Typedef Documentation

◆ aiterator

template<class T , class Attr , class Cmp = std::less<T>>
typedef TBaseSet<T,Cmp>::aiterator faudes::TAttrMap< T, Attr, Cmp >::aiterator
protected

use TBaseSet STL iterators

Definition at line 244 of file cfl_attrmap.h.

◆ const_aiterator

template<class T , class Attr , class Cmp = std::less<T>>
typedef TBaseSet<T,Cmp>::const_aiterator faudes::TAttrMap< T, Attr, Cmp >::const_aiterator
protected

use TBaseSet STL iterators

Definition at line 247 of file cfl_attrmap.h.

◆ const_iterator

template<class T , class Attr , class Cmp = std::less<T>>
typedef TBaseSet<T,Cmp>::const_iterator faudes::TAttrMap< T, Attr, Cmp >::const_iterator
protected

use TBaseSet STL iterators

Definition at line 241 of file cfl_attrmap.h.

◆ iterator

template<class T , class Attr , class Cmp = std::less<T>>
typedef TBaseSet<T,Cmp>::iterator faudes::TAttrMap< T, Attr, Cmp >::iterator
protected

use TBaseSet STL iterators

Definition at line 238 of file cfl_attrmap.h.

Constructor & Destructor Documentation

◆ TAttrMap()

template<class T , class Attr , class Cmp >
faudes::TAttrMap< T, Attr, Cmp >::TAttrMap ( TBaseSet< T, Cmp > *  pBaseSetRef)

Constructor.

Record associated set.

Definition at line 277 of file cfl_attrmap.h.

◆ ~TAttrMap()

template<class T , class Attr , class Cmp >
faudes::TAttrMap< T, Attr, Cmp >::~TAttrMap ( void  )
virtual

Virtual destructor.

Definition at line 285 of file cfl_attrmap.h.

Member Function Documentation

◆ AssignWithAttributes()

template<class T , class Attr , class Cmp >
void faudes::TAttrMap< T, Attr, Cmp >::AssignWithAttributes ( const TBaseSet< T, Cmp > &  rSourceSet)

Copy from a TBaseSet to the associated TBaseSet, with attributes, provided that they can be casted accordingly.

Parameters
rSourceSetSet to copy from

Definition at line 292 of file cfl_attrmap.h.

◆ Attribute() [1/3]

template<class T , class Attr , class Cmp >
const Attr & faudes::TAttrMap< T, Attr, Cmp >::Attribute ( const T &  rElem) const

Get attribute by element.

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

Parameters
rElemSpecify element
Exceptions
Exception
  • Element does not exist (63)
Returns
Reference to attribute

Definition at line 464 of file cfl_attrmap.h.

◆ Attribute() [2/3]

template<class T , class Attr , class Cmp >
void faudes::TAttrMap< T, Attr, Cmp >::Attribute ( const T &  rElem,
const Attr &  attr 
)

Set attribute.

This method sets the attribute of the sepcified element to the given value.

Parameters
rElemSpecify element
attrAttribute value.
Exceptions
Exception
  • Element does not exist (60)
  • Cannot cast attribute type (63)

Definition at line 514 of file cfl_attrmap.h.

◆ Attribute() [3/3]

template<class T , class Attr , class Cmp >
void faudes::TAttrMap< T, Attr, Cmp >::Attribute ( const T &  rElem,
const Type attr 
)

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
rElemSpecify element
attrAttribute value.
Exceptions
Exception
  • Element does not exist (60)
  • Cannot cast attribute type (63)

Definition at line 481 of file cfl_attrmap.h.

◆ Attributep()

template<class T , class Attr , class Cmp >
Attr * faudes::TAttrMap< T, Attr, Cmp >::Attributep ( const T &  rElem)

Get attribute reference by element.

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(rElem) const instead.

Parameters
rElemSpecify element
Exceptions
Exception
  • Element does not exist (60)
Returns
Pointer to attribute

Definition at line 446 of file cfl_attrmap.h.

◆ AttributeTry()

template<class T , class Attr , class Cmp >
void faudes::TAttrMap< T, Attr, Cmp >::AttributeTry ( const T &  rElem,
const Type attr 
)

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. If the cast fails, this method does nothing.

Parameters
rElemSpecify element
attrAttribute value.
Exceptions
Exception
  • Element does not exist (60)

Definition at line 499 of file cfl_attrmap.h.

◆ AttributeType()

template<class T , class Attr , class Cmp >
const Attr * faudes::TAttrMap< T, Attr, Cmp >::AttributeType ( void  ) const

Attribute typeinfo.

Returns
Pointer to some attribute of this sets attribute type.

Definition at line 438 of file cfl_attrmap.h.

◆ Erase() [1/2]

template<class T , class Attr , class Cmp >
bool faudes::TAttrMap< T, Attr, Cmp >::Erase ( const T &  rElem)

Erase Element (incl its attribute)

Parameters
rElemSpecify element
Returns
True if element used to exist

Definition at line 369 of file cfl_attrmap.h.

◆ Erase() [2/2]

template<class T , class Attr , class Cmp >
TBaseSet< T, Cmp >::Iterator faudes::TAttrMap< T, Attr, Cmp >::Erase ( const typename TBaseSet< T, Cmp >::Iterator &  pos)

Erase element by iterator (incl attribute)

Parameters
posIterator to specify element
Returns
Iterator to next element or End()

Definition at line 376 of file cfl_attrmap.h.

◆ EraseSet()

template<class T , class Attr , class Cmp >
void faudes::TAttrMap< T, Attr, Cmp >::EraseSet ( const TBaseSet< T, Cmp > &  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
rOtherSetElements to erase

Definition at line 386 of file cfl_attrmap.h.

◆ Insert() [1/2]

template<class T , class Attr , class Cmp >
bool faudes::TAttrMap< T, Attr, Cmp >::Insert ( const T &  rElem)

Insert element.

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

Parameters
rElemSpecify element
Returns
True if element was new to set

Definition at line 323 of file cfl_attrmap.h.

◆ Insert() [2/2]

template<class T , class Attr , class Cmp >
bool faudes::TAttrMap< T, Attr, Cmp >::Insert ( const T &  rElem,
const Attr &  attr 
)

Insert element with attribute.

Parameters
rElemSpecify element
attrSpecify attribute of (new) element
Returns
True if element was new to set

Definition at line 331 of file cfl_attrmap.h.

◆ InsertSet()

template<class T , class Attr , class Cmp >
void faudes::TAttrMap< T, Attr, Cmp >::InsertSet ( const TBaseSet< T, Cmp > &  rOtherSet)

Inserts elements from rOtherSet.

Attributes of this set are maintained, newly inserted elements receive attributes from rOtherSet, provided that can be casted appropriately.

Parameters
rOtherSetOther BaseSet

Definition at line 340 of file cfl_attrmap.h.

◆ RestrictSet()

template<class T , class Attr , class Cmp >
void faudes::TAttrMap< T, Attr, Cmp >::RestrictSet ( const TBaseSet< T, Cmp > &  rOtherSet)

Restrict to specified subset.

Erases any elements not 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
rOtherSetElements to erase

Definition at line 409 of file cfl_attrmap.h.

Member Data Documentation

◆ pBaseSet

template<class T , class Attr , class Cmp = std::less<T>>
TBaseSet<T,Cmp>* faudes::TAttrMap< T, Attr, Cmp >::pBaseSet
protected

reference to associated TBaseSet

Definition at line 250 of file cfl_attrmap.h.


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

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen