![]() |
|
|
Generated: 18 Jul 2008 |
#include <GaudiKernel/ObjectList.h>
Inheritance diagram for ObjectList< TYPE >:


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.
Definition at line 38 of file ObjectList.h.
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 * >::size_type | size_type |
| 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 long | 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. | |
| typedef TYPE ObjectList< TYPE >::contained_type |
Definition at line 41 of file ObjectList.h.
| typedef std::list<TYPE*>::value_type ObjectList< TYPE >::value_type |
Definition at line 42 of file ObjectList.h.
| typedef std::list<TYPE*>::reference ObjectList< TYPE >::reference |
Definition at line 44 of file ObjectList.h.
| typedef std::list<TYPE*>::const_reference ObjectList< TYPE >::const_reference |
Definition at line 45 of file ObjectList.h.
| typedef std::list<TYPE*>::size_type ObjectList< TYPE >::size_type |
Definition at line 47 of file ObjectList.h.
| typedef std::list<TYPE*>::iterator ObjectList< TYPE >::iterator |
Definition at line 49 of file ObjectList.h.
| typedef std::list<TYPE*>::const_iterator ObjectList< TYPE >::const_iterator |
Definition at line 50 of file ObjectList.h.
| typedef std::list<TYPE*>::reverse_iterator ObjectList< TYPE >::reverse_iterator |
Definition at line 52 of file ObjectList.h.
| typedef std::list<TYPE*>::const_reverse_iterator ObjectList< TYPE >::const_reverse_iterator |
Definition at line 53 of file ObjectList.h.
| typedef std::vector<TYPE*>::pointer ObjectList< TYPE >::pointer |
Definition at line 59 of file ObjectList.h.
| typedef std::vector<TYPE*>::const_pointer ObjectList< TYPE >::const_pointer |
Definition at line 60 of file ObjectList.h.
| ObjectList< TYPE >::ObjectList | ( | ) | [inline] |
| ObjectList< TYPE >::ObjectList | ( | const char * | name | ) | [inline] |
| ObjectList< TYPE >::ObjectList | ( | const ObjectList< TYPE > & | value | ) | [inline] |
| virtual ObjectList< TYPE >::~ObjectList | ( | ) | [inline, virtual] |
Destructor.
Definition at line 74 of file ObjectList.h.
References ObjectList< TYPE >::clear().
00074 { 00075 clear(); 00076 }
| virtual const CLID& ObjectList< TYPE >::clID | ( | ) | const [inline, virtual] |
Retrieve pointer to class defininition structure.
Reimplemented from DataObject.
Definition at line 79 of file ObjectList.h.
References ObjectList< TYPE >::classID().
00079 { 00080 return ObjectList<TYPE>::classID(); 00081 }
| static const CLID& ObjectList< TYPE >::classID | ( | ) | [inline, static] |
Retrieve reference to class definition structure (static access).
Reimplemented from DataObject.
Definition at line 82 of file ObjectList.h.
References CLID_ObjectList.
Referenced by ObjectList< TYPE >::clID().
00082 { 00083 static CLID clid = TYPE::classID() + CLID_ObjectList; 00084 return clid; 00085 }
| const ObjectList<TYPE>& ObjectList< TYPE >::operator= | ( | const ObjectList< TYPE > & | right | ) | [inline] |
Clone operator.
Definition at line 88 of file ObjectList.h.
References ObjectList< TYPE >::m_list.
00088 { 00089 this->processingVersion = right.m_processingVersion; 00090 this->detectorDataObject = right.m_detectorDataObject; 00091 m_list = right.m_list; 00092 return *this; 00093 }
| ObjectList<TYPE>::iterator ObjectList< TYPE >::begin | ( | ) | [inline] |
Return an iterator pointing to the beginning of the container.
Definition at line 96 of file ObjectList.h.
References std::list< _Tp, _Alloc >::begin(), and ObjectList< TYPE >::m_list.
Referenced by ObjectList< TYPE >::clear(), ObjectList< TYPE >::containedObject(), ObjectList< TYPE >::index(), and ObjectList< TYPE >::remove().
| ObjectList<TYPE>::const_iterator ObjectList< TYPE >::begin | ( | ) | const [inline] |
Return a const_iterator pointing to the beginning of the container.
Definition at line 101 of file ObjectList.h.
References std::list< _Tp, _Alloc >::begin(), and ObjectList< TYPE >::m_list.
| ObjectList<TYPE>::iterator ObjectList< TYPE >::end | ( | ) | [inline] |
Return an iterator pointing to the end of the container.
Definition at line 106 of file ObjectList.h.
References std::list< _Tp, _Alloc >::end(), and ObjectList< TYPE >::m_list.
Referenced by ObjectList< TYPE >::clear(), ObjectList< TYPE >::containedObject(), ObjectList< TYPE >::index(), and ObjectList< TYPE >::remove().
| ObjectList<TYPE>::const_iterator ObjectList< TYPE >::end | ( | ) | const [inline] |
Return a const_iterator pointing to the end of the container.
Definition at line 111 of file ObjectList.h.
References std::list< _Tp, _Alloc >::end(), and ObjectList< TYPE >::m_list.
| ObjectList<TYPE>::reverse_iterator ObjectList< TYPE >::rbegin | ( | ) | [inline] |
Return a reverse_iterator pointing to the beginning of the reversed container.
Definition at line 117 of file ObjectList.h.
References ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::rbegin().
| 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 122 of file ObjectList.h.
References ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::rbegin().
| ObjectList<TYPE>::reverse_iterator ObjectList< TYPE >::rend | ( | ) | [inline] |
Return a reverse_iterator pointing to the end of the reversed container.
Definition at line 127 of file ObjectList.h.
References ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::rend().
| 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 132 of file ObjectList.h.
References ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::rend().
| 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 138 of file ObjectList.h.
References ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::size().
Referenced by ObjectList< TYPE >::fillStream().
| virtual long ObjectList< TYPE >::numberOfObjects | ( | ) | const [inline, virtual] |
The same as size(), return number of objects in the container.
Implements ObjectContainerBase.
Definition at line 142 of file ObjectList.h.
References ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::size().
| ObjectList<TYPE>::size_type ObjectList< TYPE >::max_size | ( | ) | const [inline] |
Return the largest possible size of the container.
Definition at line 147 of file ObjectList.h.
References ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::max_size().
| bool ObjectList< TYPE >::empty | ( | ) | const [inline] |
Return true if the size of the container is 0.
Definition at line 152 of file ObjectList.h.
References std::list< _Tp, _Alloc >::empty(), and ObjectList< TYPE >::m_list.
| ObjectList<TYPE>::reference ObjectList< TYPE >::front | ( | ) | [inline] |
Return reference to the first element.
Definition at line 157 of file ObjectList.h.
References std::list< _Tp, _Alloc >::front(), and ObjectList< TYPE >::m_list.
| ObjectList<TYPE>::const_reference ObjectList< TYPE >::front | ( | ) | const [inline] |
Return const_reference to the first element.
Definition at line 162 of file ObjectList.h.
References std::list< _Tp, _Alloc >::front(), and ObjectList< TYPE >::m_list.
| ObjectList<TYPE>::reference ObjectList< TYPE >::back | ( | ) | [inline] |
Return reference to the last element.
Definition at line 167 of file ObjectList.h.
References std::list< _Tp, _Alloc >::back(), and ObjectList< TYPE >::m_list.
| ObjectList<TYPE>::const_reference ObjectList< TYPE >::back | ( | ) | const [inline] |
Return const_reference to the last element.
Definition at line 172 of file ObjectList.h.
References std::list< _Tp, _Alloc >::back(), and ObjectList< TYPE >::m_list.
| 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 177 of file ObjectList.h.
References ObjectList< TYPE >::m_list, std::list< _Tp, _Alloc >::push_back(), and ObjectList< TYPE >::remove().
Referenced by ObjectList< TYPE >::add().
00177 { 00178 if( 0 != value->parent() ) { 00179 const_cast<ObjectContainerBase*>(value->parent())->remove(value); 00180 } 00181 value->setParent(this); 00182 m_list.push_back(value); 00183 }
| virtual long ObjectList< TYPE >::add | ( | ContainedObject * | pObject | ) | [inline, virtual] |
Add an object to the container.
Implements ObjectContainerBase.
Definition at line 186 of file ObjectList.h.
References ObjectList< TYPE >::m_list, ObjectList< TYPE >::push_back(), and std::list< _Tp, _Alloc >::size().
00186 { 00187 try { 00188 typename ObjectList<TYPE>::value_type ptr = 00189 dynamic_cast<typename ObjectList<TYPE>::value_type>(pObject); 00190 if ( 0 != ptr ) { 00191 push_back(ptr); 00192 return m_list.size()-1; 00193 } 00194 } 00195 catch(...) { 00196 } 00197 return -1; 00198 }
| 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 202 of file ObjectList.h.
References std::list< _Tp, _Alloc >::back(), ObjectList< TYPE >::m_list, and std::list< _Tp, _Alloc >::pop_back().
00202 { 00203 typename ObjectList<TYPE>::value_type position = m_list.back(); 00204 // Set the back pointer to 0 to avoid repetitional searching 00205 // for the object in the container, and deleting the object 00206 position->setParent (0); 00207 delete position; 00208 // Removing from the container itself 00209 m_list.pop_back(); 00210 }
| 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 214 of file ObjectList.h.
References ObjectList< TYPE >::begin(), ObjectList< TYPE >::end(), and ObjectList< TYPE >::erase().
Referenced by ObjectList< TYPE >::push_back().
00214 { 00215 // Find the object of value value 00216 long idx = 0; 00217 typename ObjectList<TYPE>::iterator iter; 00218 for( iter = begin(); iter != end(); iter++, idx++ ) { 00219 if( value == *iter ) { 00220 break; 00221 } 00222 } 00223 if( end() == iter ) { 00224 // Object cannot be released from the conatiner, 00225 // as it is not contained in it 00226 return -1; 00227 } 00228 else { 00229 // Set the back pointer to 0 to avoid repetitional searching 00230 // for the object in the container and deleting the object 00231 (*iter)->setParent (0); 00232 erase(iter); 00233 return idx; 00234 } 00235 }
| 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 238 of file ObjectList.h.
References std::list< _Tp, _Alloc >::insert(), and ObjectList< TYPE >::m_list.
00239 { 00240 value->setParent(this); 00241 typename ObjectList<TYPE>::iterator i = m_list.insert(position, value); 00242 return i; 00243 }
| 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 246 of file ObjectList.h.
References std::list< _Tp, _Alloc >::erase(), and ObjectList< TYPE >::m_list.
Referenced by ObjectList< TYPE >::clear(), and ObjectList< TYPE >::remove().
00246 { 00247 if( 0 != (*position)->parent() ) { 00248 // Set the back pointer to 0 to avoid repetitional searching 00249 // for the object in the container, and deleting the object 00250 (*position)->setParent (0); 00251 delete *position; 00252 } 00253 // Removing from the container itself 00254 m_list.erase(position); 00255 }
| 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 258 of file ObjectList.h.
References std::list< _Tp, _Alloc >::erase(), and ObjectList< TYPE >::m_list.
00259 { 00260 for( typename ObjectList<TYPE>::iterator iter = first; iter != last; iter++ ) { 00261 // Set the back pointer to 0 to avoid repetitional searching 00262 // for the object in the container, and deleting the object 00263 (*iter)->setParent (0); 00264 delete *iter; 00265 } 00266 // Removing from the container itself 00267 m_list.erase(first, last); 00268 }
| void ObjectList< TYPE >::clear | ( | ) | [inline] |
Clear the entire content of the container and delete all contained objects.
Definition at line 271 of file ObjectList.h.
References ObjectList< TYPE >::begin(), ObjectList< TYPE >::end(), and ObjectList< TYPE >::erase().
Referenced by ObjectList< TYPE >::~ObjectList().
| 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 277 of file ObjectList.h.
References ObjectList< TYPE >::begin(), and ObjectList< TYPE >::end().
00277 { 00278 long i = 0; 00279 typename ObjectList<TYPE>::const_iterator iter; 00280 for( iter = begin(); iter != end(); iter++ ) { 00281 if( *iter == obj ) { 00282 return i; 00283 } 00284 i++; 00285 } 00286 return -1; 00287 }
| 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 290 of file ObjectList.h.
References ObjectList< TYPE >::begin(), and ObjectList< TYPE >::end().
00290 { 00291 long i = 0; 00292 typename ObjectList<TYPE>::const_iterator iter; 00293 for( iter = begin(); iter != end(); iter++ ) { 00294 if( dist == i ) { 00295 return *iter; 00296 } 00297 i++; 00298 } 00299 return 0; 00300 }
| virtual std::ostream& ObjectList< TYPE >::fillStream | ( | std::ostream & | s | ) | const [inline, virtual] |
Fill the output stream (ASCII).
Reimplemented from DataObject.
Definition at line 303 of file ObjectList.h.
References std::list< _Tp, _Alloc >::begin(), count(), std::list< _Tp, _Alloc >::end(), ObjectList< TYPE >::m_list, Gaudi::Units::s, std::setw(), and ObjectList< TYPE >::size().
00303 { 00304 s << "class ObjectList : size = " 00305 << std::setw(12) 00306 << size() << "\n"; 00307 // Output the base class 00308 //ObjectContainerBase::fillStream(s); 00309 if ( 0 != size() ) { 00310 s << "\nContents of the STL list :"; 00311 long count = 0; 00312 typename ObjectList<TYPE>::const_iterator iter; 00313 for( iter = m_list.begin(); iter != m_list.end(); iter++, count++ ) { 00314 s << "\nIndex " 00315 << std::setw(12) 00316 << count 00317 << " of object of type "<< **iter; 00318 } 00319 } 00320 return s; 00321 }
std::list<TYPE*> ObjectList< TYPE >::m_list [private] |
The STL list.
Definition at line 326 of file ObjectList.h.
Referenced by ObjectList< TYPE >::add(), ObjectList< TYPE >::back(), ObjectList< TYPE >::begin(), ObjectList< TYPE >::empty(), ObjectList< TYPE >::end(), ObjectList< TYPE >::erase(), ObjectList< TYPE >::fillStream(), ObjectList< TYPE >::front(), ObjectList< TYPE >::insert(), ObjectList< TYPE >::max_size(), ObjectList< TYPE >::numberOfObjects(), ObjectList< TYPE >::operator=(), ObjectList< TYPE >::pop_back(), ObjectList< TYPE >::push_back(), ObjectList< TYPE >::rbegin(), ObjectList< TYPE >::rend(), and ObjectList< TYPE >::size().