>xabsl   The Extensible Agent Behavior Specification Language

XabslEngine Class Library Reference

 

xabsl::NamedArray< T > Class Template Reference

#include <XabslArray.h>

Inheritance diagram for xabsl::NamedArray< T >:

Inheritance graph
[legend]
Collaboration diagram for xabsl::NamedArray< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class xabsl::NamedArray< T >

The class implements a dynamic array.

Each array element can have a text label.

Author:
Martin Loetzsch

Matthias JŸngel

Thomas Ršfer

Definition at line 216 of file XabslArray.h.


Public Member Functions

virtual ~NamedArray ()
 Destructor.

NamedArray< T > & operator= (const NamedArray< T > &other)
 Assignment operator.

void clear ()
 Clears the array.

getElement (const char *name, T defaultValue) const
 Returns the value for a given name.

T & getElement (const char *name) const
 Returns the value for a given name.

T & getElement (int pos) const
 Returns the value for a given array position.

NamedArrayElement< T > * getPElement (const char *name)
 Returns a pointer to the array element for a given name.

const char * getName (int pos) const
 Returns the name of an element.

void append (const char *name, T element)
 The function appends a new element to the array.

void append (T element)
void setElement (const char *name, T value)
 The function sets the value of an element in the array.

void setElement (int pos, T value)
 The function sets the value of an element in the array.

operator[] (int pos) const
 Returns the value for a given array position.

operator[] (const char *name) const
 Returns the value for a given name.

bool exists (const char *name) const
 Returns whether an element for the given name exists.

void removeLast ()
 Removes the last element of the array.


Protected Member Functions

int find (const char *name) const
 Returns the index of an element with the given name.


Constructor & Destructor Documentation

template<class T>
virtual xabsl::NamedArray< T >::~NamedArray  )  [inline, virtual]
 

Destructor.

Definition at line 220 of file XabslArray.h.


Member Function Documentation

template<class T>
NamedArray<T>& xabsl::NamedArray< T >::operator= const NamedArray< T > &  other  )  [inline]
 

Assignment operator.

Parameters:
other The other NamedArray that is assigned to this one
Returns:
A reference to this object after the assignment.

Definition at line 230 of file XabslArray.h.

template<class T>
void xabsl::NamedArray< T >::clear  )  [inline]
 

Clears the array.

Reimplemented from xabsl::Array< NamedArrayElement< T > * >.

Definition at line 244 of file XabslArray.h.

template<class T>
T xabsl::NamedArray< T >::getElement const char *  name,
defaultValue
const [inline]
 

Returns the value for a given name.

If no element exists for the name, the default value is returned.

Parameters:
name The name element
defaultValue The value that is returned if no element exists for the name.
Returns:
Either the element found or the default value.

Definition at line 258 of file XabslArray.h.

Referenced by xabsl::NamedArray< EnumeratedOutputSymbol * >::getElement(), and xabsl::NamedArray< EnumeratedOutputSymbol * >::operator[]().

template<class T>
T& xabsl::NamedArray< T >::getElement const char *  name  )  const [inline]
 

Returns the value for a given name.

Note that the function crashes if the element does not exist.

Parameters:
name The name of the element

Definition at line 272 of file XabslArray.h.

template<class T>
T& xabsl::NamedArray< T >::getElement int  pos  )  const [inline]
 

Returns the value for a given array position.

Note that the function crashes if the required position is bigger than the size of the array.

Reimplemented from xabsl::Array< NamedArrayElement< T > * >.

Definition at line 282 of file XabslArray.h.

template<class T>
NamedArrayElement<T>* xabsl::NamedArray< T >::getPElement const char *  name  )  [inline]
 

Returns a pointer to the array element for a given name.

Note that the function crashes if the element does not exist

Parameters:
name the name of the element

Definition at line 292 of file XabslArray.h.

template<class T>
const char* xabsl::NamedArray< T >::getName int  pos  )  const [inline]
 

Returns the name of an element.

Definition at line 298 of file XabslArray.h.

Referenced by xabsl::NamedArray< EnumeratedOutputSymbol * >::find().

template<class T>
void xabsl::NamedArray< T >::append const char *  name,
element
[inline]
 

The function appends a new element to the array.

Parameters:
name A string label for the element.
element The new element.

Definition at line 308 of file XabslArray.h.

Referenced by xabsl::NamedArray< EnumeratedOutputSymbol * >::append().

template<class T>
void xabsl::NamedArray< T >::append element  )  [inline]
 

Definition at line 312 of file XabslArray.h.

template<class T>
void xabsl::NamedArray< T >::setElement const char *  name,
value
[inline]
 

The function sets the value of an element in the array.

Note that the function crashes if the element does not exist.

Parameters:
name A string label for the element.
value The new element.

Definition at line 323 of file XabslArray.h.

Referenced by xabsl::NamedArray< EnumeratedOutputSymbol * >::setElement().

template<class T>
void xabsl::NamedArray< T >::setElement int  pos,
value
[inline]
 

The function sets the value of an element in the array.

Note that the function crashes if the element does not exist.

Parameters:
pos The position of the element in the array.
value The new element.

Definition at line 334 of file XabslArray.h.

template<class T>
T xabsl::NamedArray< T >::operator[] int  pos  )  const [inline]
 

Returns the value for a given array position.

Note that the function crashes if the required position is bigger than the size of the array.

Reimplemented from xabsl::Array< NamedArrayElement< T > * >.

Definition at line 344 of file XabslArray.h.

template<class T>
T xabsl::NamedArray< T >::operator[] const char *  name  )  const [inline]
 

Returns the value for a given name.

Note that the function crashes if the element does not exist.

Parameters:
name The name of the element

Definition at line 354 of file XabslArray.h.

template<class T>
bool xabsl::NamedArray< T >::exists const char *  name  )  const [inline]
 

Returns whether an element for the given name exists.

Definition at line 360 of file XabslArray.h.

Referenced by xabsl::Action::create().

template<class T>
void xabsl::NamedArray< T >::removeLast  )  [inline]
 

Removes the last element of the array.

Reimplemented from xabsl::Array< NamedArrayElement< T > * >.

Definition at line 366 of file XabslArray.h.

template<class T>
int xabsl::NamedArray< T >::find const char *  name  )  const [inline, protected]
 

Returns the index of an element with the given name.

Parameters:
name The name that is searched for.
Returns:
The index of the element of -1 if the name does not exist.

Definition at line 378 of file XabslArray.h.

Referenced by xabsl::NamedArray< EnumeratedOutputSymbol * >::exists(), xabsl::NamedArray< EnumeratedOutputSymbol * >::getElement(), xabsl::NamedArray< EnumeratedOutputSymbol * >::getPElement(), and xabsl::NamedArray< EnumeratedOutputSymbol * >::setElement().


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

Up | Main Page | Generated at Wed Aug 19 17:32:30 2009.