All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 >:
Collaboration diagram for ObjectList< TYPE >:

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 Types inherited from ObjectContainerBase
typedef size_t size_type
 size_type, to conform the STL container interface More...
 

Public Member Functions

 ObjectList ()
 Constructors. More...
 
 ObjectList (const ObjectList< TYPE > &value)
 Copy Constructor. More...
 
virtual ~ObjectList ()
 Destructor. More...
 
virtual const CLIDclID () const
 Retrieve pointer to class definition structure. More...
 
ObjectList< TYPE >::iterator begin ()
 Return an iterator pointing to the beginning of the container. More...
 
ObjectList< TYPE >::const_iterator begin () const
 Return a const_iterator pointing to the beginning of the container. More...
 
ObjectList< TYPE >::iterator end ()
 Return an iterator pointing to the end of the container. More...
 
ObjectList< TYPE >::const_iterator end () const
 Return a const_iterator pointing to the end of the container. More...
 
ObjectList< TYPE >
::reverse_iterator 
rbegin ()
 Return a reverse_iterator pointing to the beginning of the reversed container. More...
 
ObjectList< TYPE >
::const_reverse_iterator 
rbegin () const
 Return a const_reverse_iterator pointing to the beginning of the reversed container. More...
 
ObjectList< TYPE >
::reverse_iterator 
rend ()
 Return a reverse_iterator pointing to the end of the reversed container. More...
 
ObjectList< TYPE >
::const_reverse_iterator 
rend () const
 Return a const_reverse_iterator pointing to the end of the reversed container. More...
 
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. More...
 
virtual ObjectList< TYPE >
::size_type 
numberOfObjects () const
 The same as size(), return number of objects in the container. More...
 
ObjectList< TYPE >::size_type max_size () const
 Return the largest possible size of the container. More...
 
bool empty () const
 Return true if the size of the container is 0. More...
 
ObjectList< TYPE >::reference front ()
 Return reference to the first element. More...
 
ObjectList< TYPE >::const_reference front () const
 Return const_reference to the first element. More...
 
ObjectList< TYPE >::reference back ()
 Return reference to the last element. More...
 
ObjectList< TYPE >::const_reference back () const
 Return const_reference to the last element. More...
 
void push_back (typename ObjectList< TYPE >::const_reference value)
 push_back = append = insert a new element at the end of the container More...
 
virtual long add (ContainedObject *pObject)
 Add an object to the container. More...
 
void pop_back ()
 pop_back = remove the last element from the container The removed object will be deleted (see the method release) More...
 
virtual long remove (ContainedObject *value)
 Release object from the container (the pointer will be removed from the container, but the object itself will remain alive) (see the method pop_back) More...
 
ObjectList< TYPE >::iterator insert (typename ObjectList< TYPE >::iterator position, typename ObjectList< TYPE >::const_reference value)
 Insert "value" before "position". More...
 
void erase (typename ObjectList< TYPE >::iterator position)
 Erase the object at "position" from the container. The removed object will be deleted. More...
 
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. More...
 
void clear ()
 Clear the entire content of the container and delete all contained objects. More...
 
virtual long index (const ContainedObject *obj) const
 Return distance of a given object from the beginning of its container It corresponds to the "index" ( from 0 to size()-1 ) If "obj" not fount, return -1. More...
 
virtual ContainedObjectcontainedObject (long dist) const
 Return const pointer to an object of a given distance. More...
 
virtual std::ostream & fillStream (std::ostream &s) const
 Fill the output stream (ASCII) More...
 
- Public Member Functions inherited from DataObject
 DataObject ()
 Standard Constructor. More...
 
 DataObject (const DataObject &)
 Copy Constructor. More...
 
virtual ~DataObject ()
 Standard Destructor. More...
 
virtual unsigned long addRef ()
 Add reference to object. More...
 
virtual unsigned long release ()
 release reference to object More...
 
const std::string & name () const
 Retreive DataObject name. It is the name when registered in the store. More...
 
virtual StatusCode update ()
 Provide empty placeholder for internal object reconfiguration callback. More...
 
void setRegistry (IRegistry *pRegistry)
 Set pointer to Registry. More...
 
IRegistryregistry () const
 Get pointer to Registry. More...
 
LinkManagerlinkMgr () const
 Retrieve Link manager. More...
 
unsigned char version () const
 Retrieve version number of this object representation. More...
 
void setVersion (unsigned char vsn)
 Set version number of this object representation. More...
 
unsigned long refCount () const
 Return the refcount. More...
 

Static Public Member Functions

static const CLIDclassID ()
 
- Static Public Member Functions inherited from DataObject
static const CLIDclassID ()
 Retrieve reference to class definition structure (static access) More...
 

Private Attributes

std::list< TYPE * > m_list
 The STL list. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ObjectContainerBase
 ObjectContainerBase ()
 Constructor. More...
 
virtual ~ObjectContainerBase ()
 Destructor. More...
 

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 13 of file ContainedObject.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.

64  : m_list(0) { }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList< TYPE >::ObjectList ( const ObjectList< TYPE > &  value)
inline

Copy Constructor.

Definition at line 66 of file ObjectList.h.

67  : m_list(value.m_list) { }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
virtual ObjectList< TYPE >::~ObjectList ( )
inlinevirtual

Destructor.

Definition at line 70 of file ObjectList.h.

70  {
71  clear();
72  }
void clear()
Clear the entire content of the container and delete all contained objects.
Definition: ObjectList.h:259

Member Function Documentation

template<class TYPE>
virtual long ObjectList< TYPE >::add ( ContainedObject pObject)
inlinevirtual

Add an object to the container.

Implements ObjectContainerBase.

Definition at line 174 of file ObjectList.h.

174  {
175  try {
176  typename ObjectList<TYPE>::value_type ptr =
177  dynamic_cast<typename ObjectList<TYPE>::value_type>(pObject);
178  if ( 0 != ptr ) {
179  push_back(ptr);
180  return m_list.size()-1;
181  }
182  }
183  catch(...) {
184  }
185  return -1;
186  }
std::list< TYPE * >::value_type value_type
Definition: ObjectList.h:42
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
void push_back(typename ObjectList< TYPE >::const_reference value)
push_back = append = insert a new element at the end of the container
Definition: ObjectList.h:165
template<class TYPE>
ObjectList<TYPE>::reference ObjectList< TYPE >::back ( )
inline

Return reference to the last element.

Definition at line 155 of file ObjectList.h.

155  {
156  return m_list.back();
157  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList<TYPE>::const_reference ObjectList< TYPE >::back ( ) const
inline

Return const_reference to the last element.

Definition at line 160 of file ObjectList.h.

160  {
161  return m_list.back();
162  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList<TYPE>::iterator ObjectList< TYPE >::begin ( )
inline

Return an iterator pointing to the beginning of the container.

Definition at line 84 of file ObjectList.h.

84  {
85  return m_list.begin();
86  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList<TYPE>::const_iterator ObjectList< TYPE >::begin ( ) const
inline

Return a const_iterator pointing to the beginning of the container.

Definition at line 89 of file ObjectList.h.

89  {
90  return m_list.begin();
91  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
static const CLID& ObjectList< TYPE >::classID ( )
inlinestatic

Definition at line 78 of file ObjectList.h.

78  {
79  static CLID clid = TYPE::classID() + CLID_ObjectList;
80  return clid;
81  }
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
template<class TYPE>
void ObjectList< TYPE >::clear ( )
inline

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

Definition at line 259 of file ObjectList.h.

259  {
260  erase(begin(), end());
261  }
ObjectList< TYPE >::iterator begin()
Return an iterator pointing to the beginning of the container.
Definition: ObjectList.h:84
void erase(typename ObjectList< TYPE >::iterator position)
Erase the object at "position" from the container. The removed object will be deleted.
Definition: ObjectList.h:234
ObjectList< TYPE >::iterator end()
Return an iterator pointing to the end of the container.
Definition: ObjectList.h:94
template<class TYPE>
virtual const CLID& ObjectList< TYPE >::clID ( ) const
inlinevirtual

Retrieve pointer to class definition structure.

Reimplemented from DataObject.

Definition at line 75 of file ObjectList.h.

75  {
77  }
static const CLID & classID()
Definition: ObjectList.h:78
template<class TYPE>
virtual ContainedObject* ObjectList< TYPE >::containedObject ( long  dist) const
inlinevirtual

Return const pointer to an object of a given distance.

Implements ObjectContainerBase.

Definition at line 278 of file ObjectList.h.

278  {
279  long i = 0;
280  typename ObjectList<TYPE>::const_iterator iter;
281  for( iter = begin(); iter != end(); iter++ ) {
282  if( dist == i ) {
283  return *iter;
284  }
285  i++;
286  }
287  return 0;
288  }
std::list< TYPE * >::const_iterator const_iterator
Definition: ObjectList.h:48
ObjectList< TYPE >::iterator begin()
Return an iterator pointing to the beginning of the container.
Definition: ObjectList.h:84
list i
Definition: ana.py:128
ObjectList< TYPE >::iterator end()
Return an iterator pointing to the end of the container.
Definition: ObjectList.h:94
template<class TYPE>
bool ObjectList< TYPE >::empty ( ) const
inline

Return true if the size of the container is 0.

Definition at line 140 of file ObjectList.h.

140  {
141  return m_list.empty();
142  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList<TYPE>::iterator ObjectList< TYPE >::end ( )
inline

Return an iterator pointing to the end of the container.

Definition at line 94 of file ObjectList.h.

94  {
95  return m_list.end();
96  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList<TYPE>::const_iterator ObjectList< TYPE >::end ( ) const
inline

Return a const_iterator pointing to the end of the container.

Definition at line 99 of file ObjectList.h.

99  {
100  return m_list.end();
101  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
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 234 of file ObjectList.h.

234  {
235  if( 0 != (*position)->parent() ) {
236  // Set the back pointer to 0 to avoid repetitional searching
237  // for the object in the container, and deleting the object
238  (*position)->setParent (0);
239  delete *position;
240  }
241  // Removing from the container itself
242  m_list.erase(position);
243  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
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 246 of file ObjectList.h.

247  {
248  for( typename ObjectList<TYPE>::iterator iter = first; iter != last; iter++ ) {
249  // Set the back pointer to 0 to avoid repetitional searching
250  // for the object in the container, and deleting the object
251  (*iter)->setParent (0);
252  delete *iter;
253  }
254  // Removing from the container itself
255  m_list.erase(first, last);
256  }
std::list< TYPE * >::iterator iterator
Definition: ObjectList.h:47
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
virtual std::ostream& ObjectList< TYPE >::fillStream ( std::ostream &  s) const
inlinevirtual

Fill the output stream (ASCII)

Reimplemented from DataObject.

Definition at line 291 of file ObjectList.h.

291  {
292  s << "class ObjectList : size = "
293  << std::setw(12)
294  << size() << "\n";
295  // Output the base class
296  //ObjectContainerBase::fillStream(s);
297  if ( 0 != size() ) {
298  s << "\nContents of the STL list :";
299  long count = 0;
300  typename ObjectList<TYPE>::const_iterator iter;
301  for( iter = m_list.begin(); iter != m_list.end(); iter++, count++ ) {
302  s << "\nIndex "
303  << std::setw(12)
304  << count
305  << " of object of type "<< **iter;
306  }
307  }
308  return s;
309  }
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.
Definition: ObjectList.h:126
std::list< TYPE * >::const_iterator const_iterator
Definition: ObjectList.h:48
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
string s
Definition: gaudirun.py:210
template<class TYPE>
ObjectList<TYPE>::reference ObjectList< TYPE >::front ( )
inline

Return reference to the first element.

Definition at line 145 of file ObjectList.h.

145  {
146  return m_list.front();
147  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList<TYPE>::const_reference ObjectList< TYPE >::front ( ) const
inline

Return const_reference to the first element.

Definition at line 150 of file ObjectList.h.

150  {
151  return m_list.front();
152  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
virtual long ObjectList< TYPE >::index ( const ContainedObject obj) const
inlinevirtual

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

Implements ObjectContainerBase.

Definition at line 265 of file ObjectList.h.

265  {
266  long i = 0;
267  typename ObjectList<TYPE>::const_iterator iter;
268  for( iter = begin(); iter != end(); iter++ ) {
269  if( *iter == obj ) {
270  return i;
271  }
272  i++;
273  }
274  return -1;
275  }
std::list< TYPE * >::const_iterator const_iterator
Definition: ObjectList.h:48
ObjectList< TYPE >::iterator begin()
Return an iterator pointing to the beginning of the container.
Definition: ObjectList.h:84
list i
Definition: ana.py:128
ObjectList< TYPE >::iterator end()
Return an iterator pointing to the end of the container.
Definition: ObjectList.h:94
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 226 of file ObjectList.h.

227  {
228  value->setParent(this);
229  typename ObjectList<TYPE>::iterator i = m_list.insert(position, value);
230  return i;
231  }
std::list< TYPE * >::iterator iterator
Definition: ObjectList.h:47
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
list i
Definition: ana.py:128
template<class TYPE>
ObjectList<TYPE>::size_type ObjectList< TYPE >::max_size ( ) const
inline

Return the largest possible size of the container.

Definition at line 135 of file ObjectList.h.

135  {
136  return m_list.max_size();
137  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
virtual ObjectList<TYPE>::size_type ObjectList< TYPE >::numberOfObjects ( ) const
inlinevirtual

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

Implements ObjectContainerBase.

Definition at line 130 of file ObjectList.h.

130  {
131  return m_list.size();
132  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
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 190 of file ObjectList.h.

190  {
191  typename ObjectList<TYPE>::value_type position = m_list.back();
192  // Set the back pointer to 0 to avoid repetitional searching
193  // for the object in the container, and deleting the object
194  position->setParent (0);
195  delete position;
196  // Removing from the container itself
197  m_list.pop_back();
198  }
std::list< TYPE * >::value_type value_type
Definition: ObjectList.h:42
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
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 165 of file ObjectList.h.

165  {
166  if( 0 != value->parent() ) {
167  const_cast<ObjectContainerBase*>(value->parent())->remove(value);
168  }
169  value->setParent(this);
170  m_list.push_back(value);
171  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
ObjectContainerBase is the base class for Gaudi container classes.
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 105 of file ObjectList.h.

105  {
106  return m_list.rbegin();
107  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
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 110 of file ObjectList.h.

110  {
111  return m_list.rbegin();
112  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
virtual long ObjectList< TYPE >::remove ( ContainedObject value)
inlinevirtual

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

Implements ObjectContainerBase.

Definition at line 202 of file ObjectList.h.

202  {
203  // Find the object of value value
204  long idx = 0;
205  typename ObjectList<TYPE>::iterator iter;
206  for( iter = begin(); iter != end(); iter++, idx++ ) {
207  if( value == *iter ) {
208  break;
209  }
210  }
211  if( end() == iter ) {
212  // Object cannot be released from the container,
213  // as it is not contained in it
214  return -1;
215  }
216  else {
217  // Set the back pointer to 0 to avoid repetitional searching
218  // for the object in the container and deleting the object
219  (*iter)->setParent (0);
220  erase(iter);
221  return idx;
222  }
223  }
ObjectList< TYPE >::iterator begin()
Return an iterator pointing to the beginning of the container.
Definition: ObjectList.h:84
std::list< TYPE * >::iterator iterator
Definition: ObjectList.h:47
void erase(typename ObjectList< TYPE >::iterator position)
Erase the object at "position" from the container. The removed object will be deleted.
Definition: ObjectList.h:234
ObjectList< TYPE >::iterator end()
Return an iterator pointing to the end of the container.
Definition: ObjectList.h:94
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 115 of file ObjectList.h.

115  {
116  return m_list.rend();
117  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
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 120 of file ObjectList.h.

120  {
121  return m_list.rend();
122  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314
template<class TYPE>
ObjectList<TYPE>::size_type ObjectList< TYPE >::size ( ) 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 126 of file ObjectList.h.

126  {
127  return m_list.size();
128  }
std::list< TYPE * > m_list
The STL list.
Definition: ObjectList.h:314

Member Data Documentation

template<class TYPE>
std::list<TYPE*> ObjectList< TYPE >::m_list
private

The STL list.

Definition at line 314 of file ObjectList.h.


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