| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes

# 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 std::list<TYPE*>::const_iterator ObjectList< TYPE >::const_iterator

Definition at line 48 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.

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*>::const_reverse_iterator ObjectList< TYPE >::const_reverse_iterator

Definition at line 51 of file ObjectList.h.

template<class TYPE>

typedef TYPE ObjectList< TYPE >::contained_type

Definition at line 41 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::vector<TYPE*>::pointer ObjectList< TYPE >::pointer

Definition at line 57 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*>::reverse_iterator ObjectList< TYPE >::reverse_iterator

Definition at line 50 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.

## Constructor & Destructor Documentation

template<class TYPE>

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

Constructors.

Definition at line 63 of file ObjectList.h.

        : m_list(0) { }

template<class TYPE>

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

Definition at line 65 of file ObjectList.h.

        : m_list(0) { }

template<class TYPE>

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

Copy Constructor.

Definition at line 68 of file ObjectList.h.

        : m_list(value.m_list) { }

template<class TYPE>

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

Destructor.

Definition at line 72 of file ObjectList.h.

                            {
        clear();
      }

## Member Function Documentation

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.

                                                 {
        try {
          typename ObjectList<TYPE>::value_type ptr =
                dynamic_cast<typename ObjectList<TYPE>::value_type>(pObject);
          if ( 0 != ptr ) {
            push_back(ptr);
            return m_list.size()-1;
          }
        }
        catch(...) {
        }
        return -1;
      }

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.

                                                 {
        return m_list.back();
      }

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.

                                                             {
        return m_list.back();
      }

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.

                                                 {
        return m_list.begin();
      }

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.

                                                             {
        return m_list.begin();
      }

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.

                                   {
        static CLID clid = TYPE::classID() + CLID_ObjectList;
        return clid;
      }

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.

                      {
        erase(begin(), end());
      }

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.

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

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.

                                                                  {
        long i = 0;
        typename ObjectList<TYPE>::const_iterator   iter;
        for( iter = begin(); iter != end(); iter++ )  {
          if( dist == i ) {
            return *iter;
          }
          i++;
        }
        return 0;
      }

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.

                          {
        return m_list.empty();
      }

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.

                                               {
        return m_list.end();
      }

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.

                                                           {
        return m_list.end();
      }

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.

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

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.

                                                               {
        if( 0 != (*position)->parent() ) {
          // Set the back pointer to 0 to avoid repetitional searching
          // for the object in the container, and deleting the object
          (*position)->setParent (0);
          delete *position;
        }
        // Removing from the container itself
        m_list.erase(position);
      }

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.

                                                                               {
        s << "class ObjectList :    size = "
          << std::setw(12)
          << size() << "\n";
        // Output the base class
        //ObjectContainerBase::fillStream(s);
        if ( 0 != size() ) {
          s << "\nContents of the STL list :";
          long   count = 0;
          typename ObjectList<TYPE>::const_iterator iter;
          for( iter = m_list.begin(); iter != m_list.end(); iter++, count++ ) {
            s << "\nIndex "
              << std::setw(12)
              << count
              << " of object of type "<< **iter;
          }
        }
        return s;
      }

template<class TYPE>

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

Return reference to the first element.

Definition at line 155 of file ObjectList.h.

                                                  {
        return m_list.front();
      }

template<class TYPE>

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

Return const_reference to the first element.

Definition at line 160 of file ObjectList.h.

                                                              {
        return m_list.front();
      }

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.

                                                             {
        long i = 0;
        typename ObjectList<TYPE>::const_iterator   iter;
        for( iter = begin(); iter != end(); iter++ )  {
          if( *iter == obj ) {
            return i;
          }
          i++;
        }
        return -1;
      }

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.

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

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.

                                                           {
        return m_list.max_size();
      }

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.

                                                                         {
        return m_list.size();
      }

template<class TYPE>

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

Clone operator.

Definition at line 86 of file ObjectList.h.

                                                                         {
        this->processingVersion = right.m_processingVersion;
        this->detectorDataObject = right.m_detectorDataObject;
        m_list = right.m_list;
        return *this;
      }

template<class TYPE>

void ObjectList< TYPE >::pop_back | ( | ) | `[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.

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

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.

                                                                       {
        if( 0 != value->parent() ) {
          const_cast<ObjectContainerBase*>(value->parent())->remove(value);
        }
        value->setParent(this);
        m_list.push_back(value);
      }

template<class TYPE>

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

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

Definition at line 115 of file ObjectList.h.

                                                          {
        return m_list.rbegin();
      }

template<class TYPE>

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

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

Definition at line 120 of file ObjectList.h.

                                                                      {
        return m_list.rbegin();
      }

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.

                                                  {
        // Find the object of value value
        long idx = 0;
        typename ObjectList<TYPE>::iterator   iter;
        for( iter = begin(); iter != end(); iter++, idx++ )  {
          if( value == *iter ) {
            break;
          }
        }
        if( end() == iter )  {
          // Object cannot be released from the conatiner,
          // as it is not contained in it
          return -1;
        }
        else  {
          // Set the back pointer to 0 to avoid repetitional searching
          // for the object in the container and deleting the object
          (*iter)->setParent (0);
          erase(iter);
          return idx;
        }
      }

template<class TYPE>

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

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

Definition at line 130 of file ObjectList.h.

                                                                    {
        return m_list.rend();
      }

template<class TYPE>

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

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

Definition at line 125 of file ObjectList.h.

                                                        {
        return m_list.rend();
      }

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.

                                                       {
        return m_list.size();
      }

## 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_v22r4/GaudiKernel/GaudiKernel/ObjectList.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines