| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# ObjectList< TYPE > Class Template Reference

ObjectList is one of the basic Gaudi container classes capable of being registered in Data Stores. More...

`#include <GaudiKernel/ObjectList.h>`

Inheritance diagram for ObjectList< TYPE >:

[legend]
Collaboration diagram for ObjectList< TYPE >:

[legend]

List of all members.

## Public Types
typedef TYPE | contained_type
typedef std::list< TYPE * > ::value_type | value_type
typedef std::list< TYPE * > ::reference | reference
typedef std::list< TYPE * > ::const_reference | const_reference
typedef std::list< TYPE * > ::iterator | iterator
typedef std::list< TYPE * > ::const_iterator | const_iterator
typedef std::list< TYPE * > ::reverse_iterator | reverse_iterator
typedef std::list< TYPE * > ::const_reverse_iterator | const_reverse_iterator
typedef std::vector< TYPE * > ::pointer | pointer
typedef std::vector< TYPE * > ::const_pointer | const_pointer
## Public Member Functions
| ObjectList ()
| Constructors.
| ObjectList (const char *name)
| ObjectList (const ObjectList< TYPE > &value)
| Copy Constructor.
virtual | ~ObjectList ()
| Destructor.
virtual const CLID & | clID () const
| Retrieve pointer to class defininition structure.
const ObjectList< TYPE > & | operator= (const ObjectList< TYPE > &right)
| Clone operator.
ObjectList< TYPE >::iterator | begin ()
| Return an iterator pointing to the beginning of the container.
ObjectList< TYPE >::const_iterator | begin () const
| Return a const_iterator pointing to the beginning of the container.
ObjectList< TYPE >::iterator | end ()
| Return an iterator pointing to the end of the container.
ObjectList< TYPE >::const_iterator | end () const
| Return a const_iterator pointing to the end of the container.
ObjectList< TYPE > ::reverse_iterator | rbegin ()
| Return a reverse_iterator pointing to the beginning of the reversed container.
ObjectList< TYPE > ::const_reverse_iterator | rbegin () const
| Return a const_reverse_iterator pointing to the beginning of the reversed container.
ObjectList< TYPE > ::reverse_iterator | rend ()
| Return a reverse_iterator pointing to the end of the reversed container.
ObjectList< TYPE > ::const_reverse_iterator | rend () const
| Return a const_reverse_iterator pointing to the end of the reversed container.
ObjectList< TYPE >::size_type | size () const
| Return the size of the container Size means the number of objects stored in the container, independently on the amount of information stored in each object.
virtual ObjectList< TYPE > ::size_type | numberOfObjects () const
| The same as size(), return number of objects in the container.
ObjectList< TYPE >::size_type | max_size () const
| Return the largest possible size of the container.
bool | empty () const
| Return true if the size of the container is 0.
ObjectList< TYPE >::reference | front ()
| Return reference to the first element.
ObjectList< TYPE >::const_reference | front () const
| Return const_reference to the first element.
ObjectList< TYPE >::reference | back ()
| Return reference to the last element.
ObjectList< TYPE >::const_reference | back () const
| Return const_reference to the last element.
void | push_back (typename ObjectList< TYPE >::const_reference value)
| push_back = append = insert a new element at the end of the container
virtual long | add (ContainedObject *pObject)
| Add an object to the container.
void | pop_back ()
| pop_back = remove the last element from the container The removed object will be deleted (see the method release)
virtual long | remove (ContainedObject *value)
| Release object from the container (the poiter will be removed from the container, but the object itself will remain alive) (see the method pop_back).
ObjectList< TYPE >::iterator | insert (typename ObjectList< TYPE >::iterator position, typename ObjectList< TYPE >::const_reference value)
| Insert "value" before "position".
void | erase (typename ObjectList< TYPE >::iterator position)
| Erase the object at "position" from the container. The removed object will be deleted.
void | erase (typename ObjectList< TYPE >::iterator first, typename ObjectList< TYPE >::iterator last)
| Erase the range [first, last) from the container. The removed object will be deleted.
void | clear ()
| Clear the entire content of the container and delete all contained objects.
virtual long | index (const ContainedObject *obj) const
| Return distance of a given object from the beginning of its container It correcponds to the "index" ( from 0 to size()-1 ) If "obj" not fount, return -1.
virtual ContainedObject * | containedObject (long dist) const
| Return const pointer to an object of a given distance.
virtual std::ostream & | fillStream (std::ostream &s) const
| Fill the output stream (ASCII).
## Static Public Member Functions
static const CLID & | classID ()
| Retrieve reference to class definition structure (static access).
## Private Attributes
std::list< TYPE * > | m_list
| The STL list.

## Detailed Description

### template<class TYPE>
class ObjectList< TYPE >

ObjectList is one of the basic Gaudi container classes capable of being registered in Data Stores.

It is based on Standard Library (STL) std::list (see STL Programmer's Guide) ObjectList has all functions of the std::list interface,

Each object is allowed to belong into a single container only. After inserting the object into the container, it takes over all responsibilities for the object. E.g. erasing the object from its container causes removing the object's pointer from the container and deleting the object itself.

Author:
  Pavel Binko

  Pere Mato

Date:
  19/10/1999, 30/11/2000

Definition at line 38 of file ObjectList.h.

## Member Typedef Documentation

template<class TYPE>

typedef TYPE ObjectList< TYPE >::contained_type

Definition at line 41 of file ObjectList.h.

template<class TYPE>

typedef std::list<TYPE*>::value_type ObjectList< TYPE >::value_type

Definition at line 42 of file ObjectList.h.

template<class TYPE>

typedef std::list<TYPE*>::reference ObjectList< TYPE >::reference

Definition at line 44 of file ObjectList.h.

template<class TYPE>

typedef std::list<TYPE*>::const_reference ObjectList< TYPE >::const_reference

Definition at line 45 of file ObjectList.h.

template<class TYPE>

typedef std::list<TYPE*>::iterator ObjectList< TYPE >::iterator

Definition at line 47 of file ObjectList.h.

template<class TYPE>

typedef std::list<TYPE*>::const_iterator ObjectList< TYPE >::const_iterator

Definition at line 48 of file ObjectList.h.

template<class TYPE>

typedef std::list<TYPE*>::reverse_iterator ObjectList< TYPE >::reverse_iterator

Definition at line 50 of file ObjectList.h.

template<class TYPE>

typedef std::list<TYPE*>::const_reverse_iterator ObjectList< TYPE >::const_reverse_iterator

Definition at line 51 of file ObjectList.h.

template<class TYPE>

typedef std::vector<TYPE*>::pointer ObjectList< TYPE >::pointer

Definition at line 57 of file ObjectList.h.

template<class TYPE>

typedef std::vector<TYPE*>::const_pointer ObjectList< TYPE >::const_pointer

Definition at line 58 of file ObjectList.h.

## Constructor & Destructor Documentation

template<class TYPE>

ObjectList< TYPE >::ObjectList | ( |  | ) | `[inline]`

Constructors.

Definition at line 63 of file ObjectList.h.

    00064     : m_list(0) { }

template<class TYPE>

ObjectList< TYPE >::ObjectList | ( | const char * | name | ) | `[inline]`

Definition at line 65 of file ObjectList.h.

    00066     : m_list(0) { }

template<class TYPE>

ObjectList< TYPE >::ObjectList | ( | const ObjectList< TYPE > & | value | ) | `[inline]`

Copy Constructor.

Definition at line 68 of file ObjectList.h.

    00069     : m_list(value.m_list) { }

template<class TYPE>

virtual ObjectList< TYPE >::~ObjectList | ( |  | ) | `[inline, virtual]`

Destructor.

Definition at line 72 of file ObjectList.h.

    00072                         {
    00073     clear();
    00074   }

## Member Function Documentation

template<class TYPE>

virtual const CLID& ObjectList< TYPE >::clID | ( |  | ) | const`[inline, virtual]`

Retrieve pointer to class defininition structure.

Reimplemented from DataObject.

Definition at line 77 of file ObjectList.h.

    00077                                    {
    00078     return ObjectList<TYPE>::classID();
    00079   }

template<class TYPE>

static const CLID& ObjectList< TYPE >::classID | ( |  | ) | `[inline, static]`

Retrieve reference to class definition structure (static access).

Retrieve Pointer to class definition structure.

Reimplemented from DataObject.

Definition at line 80 of file ObjectList.h.

    00080                                {
    00081     static CLID clid = TYPE::classID() + CLID_ObjectList;
    00082     return clid;
    00083   }

template<class TYPE>

const ObjectList<TYPE>& ObjectList< TYPE >::operator= | ( | const ObjectList< TYPE > & | right | ) | `[inline]`

Clone operator.

Definition at line 86 of file ObjectList.h.

    00086                                                                      {
    00087     this->processingVersion = right.m_processingVersion;
    00088     this->detectorDataObject = right.m_detectorDataObject;
    00089     m_list = right.m_list;
    00090     return *this;
    00091   }

template<class TYPE>

ObjectList<TYPE>::iterator ObjectList< TYPE >::begin | ( | void |  | ) | `[inline]`

Return an iterator pointing to the beginning of the container.

Definition at line 94 of file ObjectList.h.

    00094                                              {
    00095     return m_list.begin();
    00096   }

template<class TYPE>

ObjectList<TYPE>::const_iterator ObjectList< TYPE >::begin | ( | void |  | ) | const`[inline]`

Return a const_iterator pointing to the beginning of the container.

Definition at line 99 of file ObjectList.h.

    00099                                                          {
    00100     return m_list.begin();
    00101   }

template<class TYPE>

ObjectList<TYPE>::iterator ObjectList< TYPE >::end | ( | void |  | ) | `[inline]`

Return an iterator pointing to the end of the container.

Definition at line 104 of file ObjectList.h.

    00104                                            {
    00105     return m_list.end();
    00106   }

template<class TYPE>

ObjectList<TYPE>::const_iterator ObjectList< TYPE >::end | ( | void |  | ) | const`[inline]`

Return a const_iterator pointing to the end of the container.

Definition at line 109 of file ObjectList.h.

    00109                                                        {
    00110     return m_list.end();
    00111   }

template<class TYPE>

ObjectList<TYPE>::reverse_iterator ObjectList< TYPE >::rbegin | ( | void |  | ) | `[inline]`

Return a reverse_iterator pointing to the beginning of the reversed container.

Definition at line 115 of file ObjectList.h.

    00115                                                       {
    00116     return m_list.rbegin();
    00117   }

template<class TYPE>

ObjectList<TYPE>::const_reverse_iterator ObjectList< TYPE >::rbegin | ( | void |  | ) | const`[inline]`

Return a const_reverse_iterator pointing to the beginning of the reversed container.

Definition at line 120 of file ObjectList.h.

    00120                                                                   {
    00121     return m_list.rbegin();
    00122   }

template<class TYPE>

ObjectList<TYPE>::reverse_iterator ObjectList< TYPE >::rend | ( | void |  | ) | `[inline]`

Return a reverse_iterator pointing to the end of the reversed container.

Definition at line 125 of file ObjectList.h.

    00125                                                     {
    00126     return m_list.rend();
    00127   }

template<class TYPE>

ObjectList<TYPE>::const_reverse_iterator ObjectList< TYPE >::rend | ( | void |  | ) | const`[inline]`

Return a const_reverse_iterator pointing to the end of the reversed container.

Definition at line 130 of file ObjectList.h.

    00130                                                                 {
    00131     return m_list.rend();
    00132   }

template<class TYPE>

ObjectList<TYPE>::size_type ObjectList< TYPE >::size | ( | void |  | ) | const`[inline]`

Return the size of the container Size means the number of objects stored in the container, independently on the amount of information stored in each object.

Definition at line 136 of file ObjectList.h.

    00136                                                    {
    00137     return m_list.size();
    00138   }

template<class TYPE>

virtual ObjectList<TYPE>::size_type ObjectList< TYPE >::numberOfObjects | ( |  | ) | const`[inline, virtual]`

The same as size(), return number of objects in the container.

Implements ObjectContainerBase.

Definition at line 140 of file ObjectList.h.

    00140                                                                      {
    00141     return m_list.size();
    00142   }

template<class TYPE>

ObjectList<TYPE>::size_type ObjectList< TYPE >::max_size | ( |  | ) | const`[inline]`

Return the largest possible size of the container.

Definition at line 145 of file ObjectList.h.

    00145                                                        {
    00146     return m_list.max_size();
    00147   }

template<class TYPE>

bool ObjectList< TYPE >::empty | ( | void |  | ) | const`[inline]`

Return true if the size of the container is 0.

Definition at line 150 of file ObjectList.h.

    00150                       {
    00151     return m_list.empty();
    00152   }

template<class TYPE>

ObjectList<TYPE>::reference ObjectList< TYPE >::front | ( | void |  | ) | `[inline]`

Return reference to the first element.

Definition at line 155 of file ObjectList.h.

    00155                                               {
    00156     return m_list.front();
    00157   }

template<class TYPE>

ObjectList<TYPE>::const_reference ObjectList< TYPE >::front | ( | void |  | ) | const`[inline]`

Return const_reference to the first element.

Definition at line 160 of file ObjectList.h.

    00160                                                           {
    00161     return m_list.front();
    00162   }

template<class TYPE>

ObjectList<TYPE>::reference ObjectList< TYPE >::back | ( | void |  | ) | `[inline]`

Return reference to the last element.

Definition at line 165 of file ObjectList.h.

    00165                                              {
    00166     return m_list.back();
    00167   }

template<class TYPE>

ObjectList<TYPE>::const_reference ObjectList< TYPE >::back | ( | void |  | ) | const`[inline]`

Return const_reference to the last element.

Definition at line 170 of file ObjectList.h.

    00170                                                          {
    00171     return m_list.back();
    00172   }

template<class TYPE>

void ObjectList< TYPE >::push_back | ( | typename ObjectList< TYPE >::const_reference | value | ) | `[inline]`

push_back = append = insert a new element at the end of the container

Definition at line 175 of file ObjectList.h.

    00175                                                                    {
    00176     if( 0 != value->parent() ) {
    00177       const_cast<ObjectContainerBase*>(value->parent())->remove(value);
    00178     }
    00179     value->setParent(this);
    00180     m_list.push_back(value);
    00181   }

template<class TYPE>

virtual long ObjectList< TYPE >::add | ( | ContainedObject * | pObject | ) | `[inline, virtual]`

Add an object to the container.

Implements ObjectContainerBase.

Definition at line 184 of file ObjectList.h.

    00184                                              {
    00185     try {
    00186       typename ObjectList<TYPE>::value_type ptr =
    00187             dynamic_cast<typename ObjectList<TYPE>::value_type>(pObject);
    00188       if ( 0 != ptr ) {
    00189         push_back(ptr);
    00190         return m_list.size()-1;
    00191       }
    00192     }
    00193     catch(...) {
    00194     }
    00195     return -1;
    00196   }

template<class TYPE>

void ObjectList< TYPE >::pop_back | ( | void |  | ) | `[inline]`

pop_back = remove the last element from the container The removed object will be deleted (see the method release)

Definition at line 200 of file ObjectList.h.

    00200                    {
    00201     typename ObjectList<TYPE>::value_type position = m_list.back();
    00202     // Set the back pointer to 0 to avoid repetitional searching
    00203     // for the object in the container, and deleting the object
    00204     position->setParent (0);
    00205     delete position;
    00206     // Removing from the container itself
    00207     m_list.pop_back();
    00208   }

template<class TYPE>

virtual long ObjectList< TYPE >::remove | ( | ContainedObject * | value | ) | `[inline, virtual]`

Release object from the container (the poiter will be removed from the container, but the object itself will remain alive) (see the method pop_back).

Implements ObjectContainerBase.

Definition at line 212 of file ObjectList.h.

    00212                                               {
    00213     // Find the object of value value
    00214     long idx = 0;
    00215     typename ObjectList<TYPE>::iterator   iter;
    00216     for( iter = begin(); iter != end(); iter++, idx++ )  {
    00217       if( value == *iter ) {
    00218         break;
    00219       }
    00220     }
    00221     if( end() == iter )  {
    00222       // Object cannot be released from the conatiner,
    00223       // as it is not contained in it
    00224       return -1;
    00225     }
    00226     else  {
    00227       // Set the back pointer to 0 to avoid repetitional searching
    00228       // for the object in the container and deleting the object
    00229       (*iter)->setParent (0);
    00230       erase(iter);
    00231       return idx;
    00232     }
    00233   }

template<class TYPE>

ObjectList<TYPE>::iterator ObjectList< TYPE >::insert | ( | typename ObjectList< TYPE >::iterator | position,
|  | typename ObjectList< TYPE >::const_reference | value |
| ) |  |  | `[inline]`

Insert "value" before "position".

Definition at line 236 of file ObjectList.h.

    00237                                                                                       {
    00238     value->setParent(this);
    00239     typename ObjectList<TYPE>::iterator i = m_list.insert(position, value);
    00240     return i;
    00241   }

template<class TYPE>

void ObjectList< TYPE >::erase | ( | typename ObjectList< TYPE >::iterator | position | ) | `[inline]`

Erase the object at "position" from the container. The removed object will be deleted.

Definition at line 244 of file ObjectList.h.

    00244                                                            {
    00245     if( 0 != (*position)->parent() ) {
    00246       // Set the back pointer to 0 to avoid repetitional searching
    00247       // for the object in the container, and deleting the object
    00248       (*position)->setParent (0);
    00249       delete *position;
    00250     }
    00251     // Removing from the container itself
    00252     m_list.erase(position);
    00253   }

template<class TYPE>

void ObjectList< TYPE >::erase | ( | typename ObjectList< TYPE >::iterator | first,
|  | typename ObjectList< TYPE >::iterator | last |
| ) |  |  | `[inline]`

Erase the range [first, last) from the container. The removed object will be deleted.

Definition at line 256 of file ObjectList.h.

    00257                                                        {
    00258     for( typename ObjectList<TYPE>::iterator iter = first; iter != last; iter++ )  {
    00259       // Set the back pointer to 0 to avoid repetitional searching
    00260       // for the object in the container, and deleting the object
    00261       (*iter)->setParent (0);
    00262       delete *iter;
    00263     }
    00264     // Removing from the container itself
    00265     m_list.erase(first, last);
    00266   }

template<class TYPE>

void ObjectList< TYPE >::clear | ( | void |  | ) | `[inline]`

Clear the entire content of the container and delete all contained objects.

Definition at line 269 of file ObjectList.h.

    00269                   {
    00270     erase(begin(), end());
    00271   }

template<class TYPE>

virtual long ObjectList< TYPE >::index | ( | const ContainedObject * | obj | ) | const`[inline, virtual]`

Return distance of a given object from the beginning of its container It correcponds to the "index" ( from 0 to size()-1 ) If "obj" not fount, return -1.

Implements ObjectContainerBase.

Definition at line 275 of file ObjectList.h.

    00275                                                          {
    00276     long i = 0;
    00277     typename ObjectList<TYPE>::const_iterator   iter;
    00278     for( iter = begin(); iter != end(); iter++ )  {
    00279       if( *iter == obj ) {
    00280         return i;
    00281       }
    00282       i++;
    00283     }
    00284     return -1;
    00285   }

template<class TYPE>

virtual ContainedObject* ObjectList< TYPE >::containedObject | ( | long | dist | ) | const`[inline, virtual]`

Return const pointer to an object of a given distance.

Implements ObjectContainerBase.

Definition at line 288 of file ObjectList.h.

    00288                                                               {
    00289     long i = 0;
    00290     typename ObjectList<TYPE>::const_iterator   iter;
    00291     for( iter = begin(); iter != end(); iter++ )  {
    00292       if( dist == i ) {
    00293         return *iter;
    00294       }
    00295       i++;
    00296     }
    00297     return 0;
    00298   }

template<class TYPE>

virtual std::ostream& ObjectList< TYPE >::fillStream | ( | std::ostream & | s | ) | const`[inline, virtual]`

Fill the output stream (ASCII).

Reimplemented from DataObject.

Definition at line 301 of file ObjectList.h.

    00301                                                                            {
    00302     s << "class ObjectList :    size = "
    00303       << std::setw(12)
    00304       << size() << "\n";
    00305     // Output the base class
    00306     //ObjectContainerBase::fillStream(s);
    00307     if ( 0 != size() ) {
    00308       s << "\nContents of the STL list :";
    00309       long   count = 0;
    00310       typename ObjectList<TYPE>::const_iterator iter;
    00311       for( iter = m_list.begin(); iter != m_list.end(); iter++, count++ ) {
    00312         s << "\nIndex "
    00313           << std::setw(12)
    00314           << count
    00315           << " of object of type "<< **iter;
    00316       }
    00317     }
    00318     return s;
    00319   }

## Member Data Documentation

template<class TYPE>

std::list<TYPE*> ObjectList< TYPE >::m_list`[private]`

The STL list.

Definition at line 324 of file ObjectList.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiKernel/GaudiKernel/ObjectList.h