attribute Class Template Reference
[Attributes and attribute pools]

Class for storing array/vector like data assigned with graph objects. More...

#include <attribute.h>

Inheritance diagram for attribute:

attributeBase

Public Member Functions

 attribute (TIndex _size, const T &_defaultValue) throw ()
 attribute (const attribute< T > &dupAttr) throw ()
size_t Size () const throw ()
GetValue (TIndex index) throw ()
void SetValue (TIndex index, const T newValue) throw ()
void SetDefaultValue (const T _defaultValue) throw ()
void SetConstant (const T _defaultValue) throw ()
void Assign (const T _defaultValue) throw ()
vector< T > * GetVector () throw ()
T * GetArray () throw ()
TIndex MinIndex () throw ()
TIndex MaxIndex () throw ()
MinValue () throw ()
MaxValue () throw ()
DefaultValue () throw ()
bool IsConstant () throw ()
void ComputeBounds () throw ()
void ReleaseBounds () throw ()

Protected Member Functions

void IncreaseSize (TIndex _size) throw (ERRange)
void SetCapacity (TIndex capacity) throw (ERRange)
void ReserveItems (TIndex capacity) throw (ERRange)
void AppendItems (TIndex numItems) throw ()
void EraseItems (TIndex numItems) throw (ERRange)
void SwapItems (TIndex index1, TIndex index2) throw (ERRange)

Detailed Description

template<typename T>
class attribute< T >

Class for storing array/vector like data assigned with graph objects.

This class extends the STL vector functionality as follows:


Constructor & Destructor Documentation

attribute TIndex  _size,
const T &  _defaultValue
throw ()
 

Create a new attribute.

Parameters:
_size The initial size of the vector representation
_defaultValue The value assigned with non-represented indices

attribute const attribute< T > &  dupAttr  )  throw ()
 

Clone an existing attribute.

Parameters:
dupAttr The attribute to copy from


Member Function Documentation

void AppendItems TIndex  numItems  )  throw () [protected]
 

Insert trailing items to this attribute, but only if the attribute size is > 0.

Parameters:
numItems The number of indices to be added to the vector representation

void Assign const T  _defaultValue  )  throw ()
 

Set the default attribute value and apply it to all indices.

Parameters:
_defaultValue The desired default value
This function does not release the vector data representation

void ComputeBounds  )  throw ()
 

Determine minimal and maximal indices.

This is executed with the first call to MinValue(), MaxValue(), MinIndex(), MaxIndex() and, occasionally, when attribute values are updated.

T DefaultValue  )  throw ()
 

Return the default value.

void EraseItems TIndex  numItems  )  throw (ERRange) [protected]
 

Erase trailing items from this attribute.

Parameters:
numItems The number of indices to be eliminated from the vector representation

T * GetArray  )  throw ()
 

Export the encapsulated array.

T GetValue TIndex  index  )  throw ()
 

Return the attribute value for a given index.

Parameters:
index An attribute index
Returns:
The attribute value for this index
This also works for indices which not actually represented. In that case, the default value is returned

vector< T > * GetVector  )  throw ()
 

Export the encapsulated vector.

void IncreaseSize TIndex  _size  )  throw (ERRange) [protected]
 

Increase the attribute size to a given value.

Parameters:
_size The desired number of represented attribute values

bool IsConstant  )  throw ()
 

Check if a vector representation is present and needed.

TIndex MaxIndex  )  throw ()
 

Return the maximum index which achieves the maximal value.

T MaxValue  )  throw ()
 

Return the maximal represented attribute value.

TIndex MinIndex  )  throw ()
 

Return the minimum index which achieves the minimal value.

T MinValue  )  throw ()
 

Return the minimal represented attribute value.

void ReleaseBounds  )  throw ()
 

Invalidate the minimal and maximal indices.

This is occasionally called by SetValue() and EraseItems(). It needs to be called explicitly when a vector or array is exported and values are manipulated

void ReserveItems TIndex  capacity  )  throw (ERRange) [protected]
 

Set the attribute capacity, but only if the attribute size is > 0.

Parameters:
capacity The desired number of allocated attribute values

void SetCapacity TIndex  capacity  )  throw (ERRange) [protected]
 

Set the attribute capacity, even if the attribute size is == 0.

Parameters:
capacity The desired number of allocated attribute values
This is intended to avoid reallocations when the index range increases

void SetConstant const T  _defaultValue  )  throw ()
 

Set the default attribute value and apply it to all indices.

Parameters:
_defaultValue The desired default value
This function disallocates the vector data representation

void SetDefaultValue const T  _defaultValue  )  throw ()
 

Set the default attribute value.

Parameters:
_defaultValue The desired default value
This function does not immediately affect the vector data representation. It is applied whenever the vector data representation grows, namely by the methods IncreaseSize(), AppendItems() and SetValue()

void SetValue TIndex  index,
const T  newValue
throw ()
 

Set the attribute value for a given index.

Parameters:
index An attribute index
newValue The desired value for this index
This method may grow the encapsulated vector so that the index is represented

size_t Size  )  const throw ()
 

Return the size of the encapsulated vector.

Returns:
The number of represented indices

void SwapItems TIndex  index1,
TIndex  index2
throw (ERRange) [protected]
 

Swap two attribute values represented by the encapsulated vector.

Parameters:
index1 A represented index
index2 A represented index