#include <GaudiKernel/ObjectVector.h>
Inheritance diagram for ObjectVector< TYPE >:
inline code of class DataObject | |
void | setRegistry (IRegistry *pRegistry) |
Set pointer to Registry. | |
IRegistry * | registry () const |
Get pointer to Registry. | |
LinkManager * | linkMgr () const |
Retrieve Link manager. | |
unsigned char | version () const |
Retrieve version number of this object representation. | |
void | setVersion (unsigned char vsn) |
Set version number of this object representation. | |
unsigned long | refCount () const |
Return the refcount. | |
std::ostream & | operator<< (std::ostream &s, const DataObject &obj) |
Output operator (ASCII). | |
Public Types | |
typedef TYPE | contained_type |
typedef std::vector< TYPE * >::value_type | value_type |
typedef std::vector< TYPE * >::reference | reference |
typedef std::vector< TYPE * >::const_reference | const_reference |
typedef std::vector< TYPE * >::iterator | iterator |
typedef std::vector< TYPE * >::const_iterator | const_iterator |
typedef std::vector< TYPE * >::reverse_iterator | reverse_iterator |
typedef std::vector< TYPE * >::const_reverse_iterator | const_reverse_iterator |
typedef std::vector< TYPE * >::pointer | pointer |
typedef std::vector< TYPE * >::const_pointer | const_pointer |
typedef size_t | size_type |
size_type, to conform the STL container interface | |
Public Member Functions | |
ObjectVector () | |
Constructors. | |
ObjectVector (const char *) | |
ObjectVector (const ObjectVector< TYPE > &value) | |
Copy constructor. | |
virtual | ~ObjectVector () |
Destructor. | |
virtual const CLID & | clID () const |
Retrieve class ID. | |
const ObjectVector< TYPE > & | operator= (const ObjectVector< TYPE > &right) |
Clone operator. | |
ObjectVector< TYPE >::iterator | begin () |
Return an iterator pointing to the beginning of the container. | |
ObjectVector< TYPE >::const_iterator | begin () const |
Return a const_iterator pointing to the beginning of the container. | |
ObjectVector< TYPE >::iterator | end () |
Return an iterator pointing to the end of the container. | |
ObjectVector< TYPE >::const_iterator | end () const |
Return a const_iterator pointing to the end of the container. | |
ObjectVector< TYPE >::reverse_iterator | rbegin () |
Return a reverse_iterator pointing to the beginning of the reversed container. | |
ObjectVector< TYPE >::const_reverse_iterator | rbegin () const |
Return a const_reverse_iterator pointing to the beginning of the reversed container. | |
ObjectVector< TYPE >::reverse_iterator | rend () |
Return a reverse_iterator pointing to the end of the reversed container. | |
ObjectVector< TYPE >::const_reverse_iterator | rend () const |
Return a const_reverse_iterator pointing to the end of the reversed container. | |
ObjectVector< TYPE >::size_type | size () const |
Return the size of the container. | |
virtual ObjectVector< TYPE >::size_type | numberOfObjects () const |
The same as size(), return number of objects in the container. | |
ObjectVector< TYPE >::size_type | max_size () const |
Return the largest possible size of the container. | |
ObjectVector< TYPE >::size_type | capacity () const |
Return number of elements for which memory has been allocated It is always greater than or equal to size(). | |
void | reserve (typename ObjectVector< TYPE >::size_type value) |
Reserve place for "value" objects in the container. | |
bool | empty () const |
Return true if the size of the container is 0. | |
ObjectVector< TYPE >::reference | front () |
Return reference to the first element. | |
ObjectVector< TYPE >::const_reference | front () const |
Return const_reference to the first element. | |
ObjectVector< TYPE >::reference | back () |
Return reference to the last element. | |
ObjectVector< TYPE >::const_reference | back () const |
Return const_reference to the last element. | |
void | push_back (typename ObjectVector< 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). | |
ObjectVector< TYPE >::iterator | insert (typename ObjectVector< TYPE >::iterator position, typename ObjectVector< TYPE >::const_reference value) |
Insert "value" before "position". | |
void | erase (typename ObjectVector< TYPE >::iterator position) |
Erase the object at "position" from the container. The removed object will be deleted. | |
void | erase (typename ObjectVector< TYPE >::iterator first, typename ObjectVector< 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. | |
ObjectVector< TYPE >::reference | operator[] (typename ObjectVector< TYPE >::size_type n) |
Return the reference to the n'th object in the container. | |
ObjectVector< TYPE >::const_reference | operator[] (typename ObjectVector< TYPE >::size_type n) const |
Return the const_reference to the n'th object in the container. | |
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 (index). | |
virtual std::ostream & | fillStream (std::ostream &s) const |
Fill the output stream (ASCII). | |
virtual unsigned long | addRef () |
Add reference to object. | |
virtual unsigned long | release () |
release reference to object | |
const std::string & | name () const |
Retreive DataObject name. It is the name when registered in the store. | |
virtual StreamBuffer & | serialize (StreamBuffer &s) |
Serialization mechanism: Serialize the object for reading. | |
virtual StreamBuffer & | serialize (StreamBuffer &s) const |
Serialization mechanism: Serialize the object for writing. | |
Static Public Member Functions | |
static const CLID & | classID () |
Retrieve class ID. | |
Private Attributes | |
std::vector< TYPE * > | m_vector |
The STL vector itself. |
It is based on Standard Library (STL) std::vector (see STL Programmer's Guide) ObjectVector has all functions of the std::vector interface, and in addition a number of Gaudi specific functions.
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.
Pere Mato
Definition at line 39 of file ObjectVector.h.
typedef TYPE ObjectVector< TYPE >::contained_type |
Definition at line 42 of file ObjectVector.h.
typedef std::vector<TYPE*>::value_type ObjectVector< TYPE >::value_type |
Definition at line 43 of file ObjectVector.h.
typedef std::vector<TYPE*>::reference ObjectVector< TYPE >::reference |
Definition at line 45 of file ObjectVector.h.
typedef std::vector<TYPE*>::const_reference ObjectVector< TYPE >::const_reference |
Definition at line 46 of file ObjectVector.h.
typedef std::vector<TYPE*>::iterator ObjectVector< TYPE >::iterator |
Definition at line 48 of file ObjectVector.h.
typedef std::vector<TYPE*>::const_iterator ObjectVector< TYPE >::const_iterator |
Definition at line 49 of file ObjectVector.h.
typedef std::vector<TYPE*>::reverse_iterator ObjectVector< TYPE >::reverse_iterator |
Definition at line 51 of file ObjectVector.h.
typedef std::vector<TYPE*>::const_reverse_iterator ObjectVector< TYPE >::const_reverse_iterator |
Definition at line 52 of file ObjectVector.h.
typedef std::vector<TYPE*>::pointer ObjectVector< TYPE >::pointer |
Definition at line 57 of file ObjectVector.h.
typedef std::vector<TYPE*>::const_pointer ObjectVector< TYPE >::const_pointer |
Definition at line 58 of file ObjectVector.h.
typedef size_t ObjectContainerBase::size_type [inherited] |
size_type, to conform the STL container interface
Reimplemented in SharedObjectsContainer< TYPE >.
Definition at line 33 of file ObjectContainerBase.h.
ObjectVector< TYPE >::ObjectVector | ( | ) | [inline] |
ObjectVector< TYPE >::ObjectVector | ( | const char * | ) | [inline] |
ObjectVector< TYPE >::ObjectVector | ( | const ObjectVector< TYPE > & | value | ) | [inline] |
Copy constructor.
Definition at line 68 of file ObjectVector.h.
00069 : ObjectContainerBase(), m_vector(value.m_vector) { }
virtual ObjectVector< TYPE >::~ObjectVector | ( | ) | [inline, virtual] |
Destructor.
Definition at line 72 of file ObjectVector.h.
00072 { 00073 for( typename ObjectVector<TYPE>::iterator i = begin(); i != end(); i++ ) { 00074 // Set the back pointer to 0 to avoid repetitional searching 00075 // for the object in the container, and deleting the object 00076 (*i)->setParent (0); 00077 delete *i; 00078 } 00079 }
virtual const CLID& ObjectVector< TYPE >::clID | ( | ) | const [inline, virtual] |
Retrieve class ID.
Reimplemented from DataObject.
Definition at line 82 of file ObjectVector.h.
00082 { 00083 return ObjectVector<TYPE>::classID(); 00084 }
static const CLID& ObjectVector< TYPE >::classID | ( | ) | [inline, static] |
Retrieve class ID.
Reimplemented from DataObject.
Definition at line 86 of file ObjectVector.h.
00086 { 00087 static CLID clid = TYPE::classID() + CLID_ObjectVector; 00088 return clid; 00089 }
const ObjectVector<TYPE>& ObjectVector< TYPE >::operator= | ( | const ObjectVector< TYPE > & | right | ) | [inline] |
ObjectVector<TYPE>::iterator ObjectVector< TYPE >::begin | ( | ) | [inline] |
Return an iterator pointing to the beginning of the container.
Definition at line 98 of file ObjectVector.h.
00098 { 00099 return m_vector.begin(); 00100 }
ObjectVector<TYPE>::const_iterator ObjectVector< TYPE >::begin | ( | ) | const [inline] |
Return a const_iterator pointing to the beginning of the container.
Definition at line 103 of file ObjectVector.h.
00103 { 00104 return m_vector.begin(); 00105 }
ObjectVector<TYPE>::iterator ObjectVector< TYPE >::end | ( | ) | [inline] |
Return an iterator pointing to the end of the container.
Definition at line 108 of file ObjectVector.h.
00108 { 00109 return m_vector.end(); 00110 }
ObjectVector<TYPE>::const_iterator ObjectVector< TYPE >::end | ( | ) | const [inline] |
Return a const_iterator pointing to the end of the container.
Definition at line 113 of file ObjectVector.h.
00113 { 00114 return m_vector.end(); 00115 }
ObjectVector<TYPE>::reverse_iterator ObjectVector< TYPE >::rbegin | ( | ) | [inline] |
Return a reverse_iterator pointing to the beginning of the reversed container.
Definition at line 118 of file ObjectVector.h.
00118 { 00119 return m_vector.rbegin(); 00120 }
ObjectVector<TYPE>::const_reverse_iterator ObjectVector< TYPE >::rbegin | ( | ) | const [inline] |
Return a const_reverse_iterator pointing to the beginning of the reversed container.
Definition at line 124 of file ObjectVector.h.
00124 { 00125 return m_vector.rbegin(); 00126 }
ObjectVector<TYPE>::reverse_iterator ObjectVector< TYPE >::rend | ( | ) | [inline] |
Return a reverse_iterator pointing to the end of the reversed container.
Definition at line 129 of file ObjectVector.h.
00129 { 00130 return m_vector.rend(); 00131 }
ObjectVector<TYPE>::const_reverse_iterator ObjectVector< TYPE >::rend | ( | ) | const [inline] |
Return a const_reverse_iterator pointing to the end of the reversed container.
Definition at line 134 of file ObjectVector.h.
00134 { 00135 return m_vector.rend(); 00136 }
ObjectVector<TYPE>::size_type ObjectVector< 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 142 of file ObjectVector.h.
00142 { 00143 return m_vector.size(); 00144 }
virtual ObjectVector<TYPE>::size_type ObjectVector< TYPE >::numberOfObjects | ( | ) | const [inline, virtual] |
The same as size(), return number of objects in the container.
Implements ObjectContainerBase.
Definition at line 147 of file ObjectVector.h.
00147 { 00148 return m_vector.size(); 00149 }
ObjectVector<TYPE>::size_type ObjectVector< TYPE >::max_size | ( | ) | const [inline] |
Return the largest possible size of the container.
Definition at line 152 of file ObjectVector.h.
00152 { 00153 return m_vector.max_size(); 00154 }
ObjectVector<TYPE>::size_type ObjectVector< TYPE >::capacity | ( | ) | const [inline] |
Return number of elements for which memory has been allocated It is always greater than or equal to size().
Definition at line 158 of file ObjectVector.h.
00158 { 00159 return m_vector.capacity(); 00160 }
void ObjectVector< TYPE >::reserve | ( | typename ObjectVector< TYPE >::size_type | value | ) | [inline] |
Reserve place for "value" objects in the container.
If "value" is less than or equal to capacity(), this call has no effect, otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is >= n, otherwise, capacity() is unchanged. In either case, size() is unchanged
Definition at line 169 of file ObjectVector.h.
00169 { 00170 m_vector.reserve( value ); 00171 }
bool ObjectVector< TYPE >::empty | ( | ) | const [inline] |
Return true if the size of the container is 0.
Definition at line 174 of file ObjectVector.h.
00174 { 00175 return m_vector.empty(); 00176 }
ObjectVector<TYPE>::reference ObjectVector< TYPE >::front | ( | ) | [inline] |
Return reference to the first element.
Definition at line 179 of file ObjectVector.h.
00179 { 00180 return m_vector.front(); 00181 }
ObjectVector<TYPE>::const_reference ObjectVector< TYPE >::front | ( | ) | const [inline] |
Return const_reference to the first element.
Definition at line 184 of file ObjectVector.h.
00184 { 00185 return m_vector.front(); 00186 }
ObjectVector<TYPE>::reference ObjectVector< TYPE >::back | ( | ) | [inline] |
Return reference to the last element.
Definition at line 189 of file ObjectVector.h.
00189 { 00190 return m_vector.back(); 00191 }
ObjectVector<TYPE>::const_reference ObjectVector< TYPE >::back | ( | ) | const [inline] |
Return const_reference to the last element.
Definition at line 194 of file ObjectVector.h.
00194 { 00195 return m_vector.back(); 00196 }
void ObjectVector< TYPE >::push_back | ( | typename ObjectVector< TYPE >::const_reference | value | ) | [inline] |
push_back = append = insert a new element at the end of the container
Definition at line 199 of file ObjectVector.h.
00199 { 00200 if( 0 != value->parent() ) { 00201 const_cast<ObjectContainerBase*>(value->parent())->remove(value); 00202 } 00203 value->setParent(this); 00204 m_vector.push_back(value); 00205 }
virtual long ObjectVector< TYPE >::add | ( | ContainedObject * | pObject | ) | [inline, virtual] |
Add an object to the container.
Implements ObjectContainerBase.
Definition at line 208 of file ObjectVector.h.
00208 { 00209 try { 00210 typename ObjectVector<TYPE>::value_type ptr = 00211 dynamic_cast<typename ObjectVector<TYPE>::value_type>(pObject); 00212 if ( 0 != ptr ) { 00213 push_back(ptr); 00214 return m_vector.size()-1; 00215 } 00216 } 00217 catch(...) { 00218 } 00219 return -1; 00220 }
void ObjectVector< 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 224 of file ObjectVector.h.
00224 { 00225 typename ObjectVector<TYPE>::value_type position = m_vector.back(); 00226 // Set the back pointer to 0 to avoid repetitional searching 00227 // for the object in the container, and deleting the object 00228 position->setParent (0); 00229 delete position; 00230 // Removing from the container itself 00231 m_vector.pop_back(); 00232 }
virtual long ObjectVector< 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 236 of file ObjectVector.h.
00236 { 00237 // Find the object of the value value 00238 typename ObjectVector<TYPE>::iterator i; 00239 for( i = begin(); i != end(); i++ ) { 00240 if( value == *i ) { 00241 break; 00242 } 00243 } 00244 if( end() == i ) { 00245 // Object cannot be released from the conatiner, 00246 // as it is not contained in it 00247 return StatusCode::FAILURE; 00248 } 00249 else { 00250 // Set the back pointer to 0 to avoid repetitional searching 00251 // for the object in the container and deleting the object 00252 (*i)->setParent (0); 00253 erase(i); 00254 return StatusCode::SUCCESS; 00255 } 00256 }
ObjectVector<TYPE>::iterator ObjectVector< TYPE >::insert | ( | typename ObjectVector< TYPE >::iterator | position, | |
typename ObjectVector< TYPE >::const_reference | value | |||
) | [inline] |
Insert "value" before "position".
Definition at line 259 of file ObjectVector.h.
00260 { 00261 value->setParent(this); 00262 typename ObjectVector<TYPE>::iterator i = m_vector.insert(position, value); 00263 return i; 00264 }
void ObjectVector< TYPE >::erase | ( | typename ObjectVector< TYPE >::iterator | position | ) | [inline] |
Erase the object at "position" from the container. The removed object will be deleted.
Definition at line 267 of file ObjectVector.h.
00267 { 00268 if( 0 != (*position)->parent() ) { 00269 // Set the back pointer to 0 to avoid repetitional searching 00270 // for the object in the container, and deleting the object 00271 (*position)->setParent (0); 00272 delete *position; 00273 } 00274 // Removing from the container itself 00275 m_vector.erase(position); 00276 }
void ObjectVector< TYPE >::erase | ( | typename ObjectVector< TYPE >::iterator | first, | |
typename ObjectVector< TYPE >::iterator | last | |||
) | [inline] |
Erase the range [first, last) from the container. The removed object will be deleted.
Definition at line 279 of file ObjectVector.h.
00280 { 00281 for(typename ObjectVector<TYPE>::iterator i = first; i != last; i++ ) { 00282 // Set the back pointer to 0 to avoid repetitional searching 00283 // for the object in the container, and deleting the object 00284 (*i)->setParent(0); 00285 delete *i; 00286 } 00287 // Removing from the container itself 00288 m_vector.erase(first, last); 00289 }
void ObjectVector< TYPE >::clear | ( | ) | [inline] |
Clear the entire content of the container and delete all contained objects.
Definition at line 292 of file ObjectVector.h.
ObjectVector<TYPE>::reference ObjectVector< TYPE >::operator[] | ( | typename ObjectVector< TYPE >::size_type | n | ) | [inline] |
Return the reference to the n'th object in the container.
Definition at line 298 of file ObjectVector.h.
ObjectVector<TYPE>::const_reference ObjectVector< TYPE >::operator[] | ( | typename ObjectVector< TYPE >::size_type | n | ) | const [inline] |
Return the const_reference to the n'th object in the container.
Definition at line 304 of file ObjectVector.h.
virtual long ObjectVector< 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 311 of file ObjectVector.h.
00311 { 00312 long i; 00313 for( i = 0; i < (long)m_vector.size(); i++ ) { 00314 if( m_vector[i] == obj ) { 00315 return i; 00316 } 00317 } 00318 return -1; 00319 }
virtual ContainedObject* ObjectVector< TYPE >::containedObject | ( | long | dist | ) | const [inline, virtual] |
Return const pointer to an object of a given distance (index).
Implements ObjectContainerBase.
Definition at line 322 of file ObjectVector.h.
00322 { 00323 return m_vector[dist]; 00324 }
virtual std::ostream& ObjectVector< TYPE >::fillStream | ( | std::ostream & | s | ) | const [inline, virtual] |
Fill the output stream (ASCII).
Reimplemented from DataObject.
Definition at line 327 of file ObjectVector.h.
00327 { 00328 s << "class ObjectVector : size = " 00329 << std::setw(12) 00330 << size() << "\n"; 00331 // Output the base class 00332 //ObjectContainerBase::fillStream(s); 00333 if ( 0 != size() ) { 00334 s << "\nContents of the STL vector :"; 00335 long count = 0; 00336 typename ObjectVector<TYPE>::const_iterator iter; 00337 for( iter = m_vector.begin(); iter != m_vector.end(); iter++, count++ ) { 00338 s << "\nIndex " 00339 << std::setw(12) 00340 << count 00341 << " of object of type " << **iter; 00342 } 00343 } 00344 return s; 00345 }
virtual unsigned long DataObject::addRef | ( | ) | [virtual, inherited] |
Add reference to object.
virtual unsigned long DataObject::release | ( | ) | [virtual, inherited] |
release reference to object
const std::string& DataObject::name | ( | ) | const [inherited] |
Retreive DataObject name. It is the name when registered in the store.
Reimplemented in NTuple::File, and ServiceHistory.
virtual StreamBuffer& DataObject::serialize | ( | StreamBuffer & | s | ) | [virtual, inherited] |
Serialization mechanism: Serialize the object for reading.
Reimplemented in RefTableBase< FROM, MAPENTRY >, RefTableBase< FROM, SmartRefVector< TO > >, and RefTableBase< FROM, SmartRef< TO > >.
virtual StreamBuffer& DataObject::serialize | ( | StreamBuffer & | s | ) | const [virtual, inherited] |
Serialization mechanism: Serialize the object for writing.
Reimplemented in RefTableBase< FROM, MAPENTRY >, RefTableBase< FROM, SmartRefVector< TO > >, and RefTableBase< FROM, SmartRef< TO > >.
void DataObject::setRegistry | ( | IRegistry * | pRegistry | ) | [inline, inherited] |
Set pointer to Registry.
Definition at line 67 of file DataObject.h.
00067 { 00068 m_pRegistry = pRegistry; 00069 }
IRegistry* DataObject::registry | ( | ) | const [inline, inherited] |
Get pointer to Registry.
Definition at line 71 of file DataObject.h.
00071 { 00072 return m_pRegistry; 00073 }
LinkManager* DataObject::linkMgr | ( | ) | const [inline, inherited] |
Retrieve Link manager.
Definition at line 75 of file DataObject.h.
00075 { 00076 return m_pLinkMgr; 00077 }
unsigned char DataObject::version | ( | ) | const [inline, inherited] |
Retrieve version number of this object representation.
Definition at line 79 of file DataObject.h.
00079 { 00080 return m_version; 00081 }
void DataObject::setVersion | ( | unsigned char | vsn | ) | [inline, inherited] |
Set version number of this object representation.
Definition at line 83 of file DataObject.h.
00083 { 00084 m_version = vsn; 00085 }
unsigned long DataObject::refCount | ( | ) | const [inline, inherited] |
Return the refcount.
Definition at line 87 of file DataObject.h.
00087 { 00088 return m_refCount; 00089 }
std::ostream& operator<< | ( | std::ostream & | s, | |
const DataObject & | obj | |||
) | [friend, inherited] |
Output operator (ASCII).
Definition at line 96 of file DataObject.h.
00096 { 00097 return obj.fillStream(s); 00098 }
std::vector<TYPE*> ObjectVector< TYPE >::m_vector [private] |