| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Attributes
TeComposite< T > Class Template Reference

Defines a template for handling a composite object. More...

`#include <TeComposite.h>`

Inheritance diagram for TeComposite< T >:

List of all members.

## Public Types

typedef vector< T >::iterator | iterator
| An iterator to the composite elements.
typedef vector< T >::const_iterator | const_iterator
typedef vector< T > ::reverse_iterator | reverse_iterator
| A reverse iterator to the composite elements.

## Public Member Functions

void | add (const T &elem)
| Adds a new component.
bool | erase (unsigned int i)
| Removes the i-th component.
bool | erase (T &elem)
| Removes a specific element.
iterator | erase (iterator it)
| Removes an element pointed by an iterator.
void | clear ()
| Removes all elements.
size_t | size () const
| Returns the size of the composite.
T & | operator[] (int i)
| Returns the i-th element.
bool | empty () const
| Returns TRUE if the composite is empty.
void | reserve (int nelem)
| Reserves space for n elements (reserve is available for vectors)
iterator | begin (void)
| Returns an iterator to the composite first element.
iterator | end (void)
| Returns a iterator to the composite last plus one element.
reverse_iterator | rbegin (void)
| The iterator to the first position in the TeComposite in reverse order.
reverse_iterator | rend (void)
| The iterator to the last plus one position in the TeComposite in reverse order.

## Protected Attributes

vector< T > | components_
| a vector of components

## Detailed Description

### template<class T>
class TeComposite< T >

Defines a template for handling a composite object.

Provides a vector for storing components and ensures proper destruction of them, by means of a handle/body idiom. Provide a handle to an implementation and thus allow efficient copying of derived objects

Note:
  This is a specialised example of the "Composite" design pattern, with support for the "Bridge" pattern (also known as the handle/body idiom).

## Member Typedef Documentation

template<class T>

typedef vector<T>::const_iterator TeComposite< T >::const_iterator

template<class T>

typedef vector<T>::iterator TeComposite< T >::iterator

An iterator to the composite elements.

template<class T>

typedef vector<T>::reverse_iterator TeComposite< T >::reverse_iterator

A reverse iterator to the composite elements.

## Member Function Documentation

template<class T>

void TeComposite< T >::add | ( | const T & | elem | ) | `[inline]`

Adds a new component.

template<class T>

iterator TeComposite< T >::begin | ( | void |  | ) | `[inline]`

Returns an iterator to the composite first element.

template<class T>

void TeComposite< T >::clear | ( |  | ) | `[inline]`

Removes all elements.

template<class T>

bool TeComposite< T >::empty | ( |  | ) | const`[inline]`

Returns TRUE if the composite is empty.

template<class T>

iterator TeComposite< T >::end | ( | void |  | ) | `[inline]`

Returns a iterator to the composite last plus one element.

template<class T>

iterator TeComposite< T >::erase | ( | iterator | it | ) | `[inline]`

Removes an element pointed by an iterator.

template<class T>

bool TeComposite< T >::erase | ( | unsigned int | i | ) | `[inline]`

Removes the i-th component.

template<class T>

bool TeComposite< T >::erase | ( | T & | elem | ) | `[inline]`

Removes a specific element.

Parameters:

  elem | the element to be removed

template<class T>

T& TeComposite< T >::operator[] | ( | int | i | ) | `[inline]`

Returns the i-th element.

template<class T>

reverse_iterator TeComposite< T >::rbegin | ( | void |  | ) | `[inline]`

The iterator to the first position in the TeComposite in reverse order.

template<class T>

reverse_iterator TeComposite< T >::rend | ( | void |  | ) | `[inline]`

The iterator to the last plus one position in the TeComposite in reverse order.

template<class T>

void TeComposite< T >::reserve | ( | int | nelem | ) | `[inline]`

Reserves space for n elements (reserve is available for vectors)

template<class T>

size_t TeComposite< T >::size | ( |  | ) | const`[inline]`

Returns the size of the composite.

## Member Data Documentation

template<class T>

vector<T> TeComposite< T >::components_`[protected]`

a vector of components

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

- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeComposite.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines