#include <SharedObjectsContainer.h>
Inheritance diagram for SharedObjectsContainer< 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. | |
virtual std::ostream & | fillStream (std::ostream &s) const |
Fill the output stream (ASCII). | |
std::ostream & | operator<< (std::ostream &s, const DataObject &obj) |
Output operator (ASCII). | |
Public Types | |
typedef std::vector< const TYPE * > | ConstVector |
the actual container type | |
typedef ConstVector::value_type | value_type |
various types (to make STL happy) | |
typedef ConstVector::size_type | size_type |
size_type, to conform the STL container interface | |
typedef ConstVector::reference | reference |
typedef ConstVector::const_reference | const_reference |
typedef ConstVector::iterator | iterator |
typedef ConstVector::const_iterator | const_iterator |
typedef ConstVector::reverse_iterator | reverse_iterator |
typedef ConstVector::const_reverse_iterator | const_reverse_iterator |
Public Member Functions | |
SharedObjectsContainer () | |
SharedObjectsContainer (const ConstVector &data) | |
template<class DATA> | |
SharedObjectsContainer (DATA first, DATA last) | |
the templated constructor from the pair of iterators | |
template<class DATA, class PREDICATE> | |
SharedObjectsContainer (DATA first, DATA last, const PREDICATE &cut) | |
the templated constructor from the pair of iterators and the predicate. | |
SharedObjectsContainer (const SharedObjectsContainer &right) | |
copy constructor | |
~SharedObjectsContainer () | |
destructor | |
virtual const CLID & | clID () const |
Retrieve the unique class ID (virtual). | |
const ConstVector & | data () const |
get the access to the underlying container (const) | |
operator const ConstVector & () const | |
cast to the underlying container | |
size_type | size () const |
get the actual size of the container | |
bool | empty () const |
empty container? | |
void | push_back (const TYPE *object) |
insert one object into the container | |
void | insert (const TYPE *object) |
insert one object into the container | |
template<class DATA> | |
void | insert (DATA first, DATA last) |
add the sequence of objects into the container | |
template<class DATA, class PREDICATE> | |
void | insert (DATA first, DATA last, const PREDICATE &cut) |
add the sequence of 'good'objects into the container | |
template<class OUTPUT, class PREDICATE> | |
OUTPUT | get (const PREDICATE &cut, OUTPUT output) const |
get from the container all objects which satisfy the certain criteria | |
void | erase (iterator i) |
erase the object by iterator | |
template<class PREDICATE> | |
void | erase (const PREDICATE &cut) |
erase the objects which satisfy the criteria | |
bool | erase (const TYPE *object) |
erase the first occurance of the certain element | |
reference | operator[] (size_type index) |
index access | |
const_reference | operator[] (size_type index) const |
index access (const-version) | |
reference | operator() (size_type index) |
'functional'-access | |
const_reference | operator() (size_type index) const |
'functional'-access (const version) | |
reference | at (size_type index) |
checked access | |
const_reference | at (size_type index) const |
checked access (const-version) | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
reference | front () |
the first element (only for non-empty vectors) | |
const_reference | front () const |
the first element (only for non-empty vectors) (const-version) | |
reference | back () |
the last element (only for non-empty vectors) | |
const_reference | back () const |
the last element (only for non-empty vectors) (const-version) | |
bool | operator== (const SharedObjectsContainer &right) const |
equal content with other container ? | |
bool | operator== (const ConstVector &right) const |
equal content with corresponding vector ? | |
bool | operator< (const SharedObjectsContainer &right) const |
comparisons with other container | |
bool | operator< (const ConstVector &right) const |
comparisons with corresponding vector | |
virtual long | index (const ContainedObject *object) const |
Distance of a given object from the beginning of its container. | |
virtual ContainedObject * | containedObject (long index) const |
Pointer to an object of a given distance. | |
virtual size_type | numberOfObjects () const |
Number of objects in the container. | |
virtual long | add (ContainedObject *object) |
Virtual functions (forwards to the concrete container definitions) Add an object to the container. | |
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). | |
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 the unuqie class ID (static). | |
Private Attributes | |
ConstVector | m_data |
This concept seem to be very useful for LHCb HLT, DaVinci, tracking, alignments.
Definition at line 30 of file SharedObjectsContainer.h.
typedef std::vector<const TYPE*> SharedObjectsContainer< TYPE >::ConstVector |
typedef ConstVector::value_type SharedObjectsContainer< TYPE >::value_type |
typedef ConstVector::size_type SharedObjectsContainer< TYPE >::size_type |
size_type, to conform the STL container interface
Reimplemented from ObjectContainerBase.
Definition at line 38 of file SharedObjectsContainer.h.
typedef ConstVector::reference SharedObjectsContainer< TYPE >::reference |
Definition at line 39 of file SharedObjectsContainer.h.
typedef ConstVector::const_reference SharedObjectsContainer< TYPE >::const_reference |
Definition at line 40 of file SharedObjectsContainer.h.
typedef ConstVector::iterator SharedObjectsContainer< TYPE >::iterator |
Definition at line 41 of file SharedObjectsContainer.h.
typedef ConstVector::const_iterator SharedObjectsContainer< TYPE >::const_iterator |
Definition at line 42 of file SharedObjectsContainer.h.
typedef ConstVector::reverse_iterator SharedObjectsContainer< TYPE >::reverse_iterator |
Definition at line 43 of file SharedObjectsContainer.h.
typedef ConstVector::const_reverse_iterator SharedObjectsContainer< TYPE >::const_reverse_iterator |
Definition at line 44 of file SharedObjectsContainer.h.
SharedObjectsContainer< TYPE >::SharedObjectsContainer | ( | ) | [inline] |
Definition at line 49 of file SharedObjectsContainer.h.
00050 : ObjectContainerBase () , m_data() {} ;
SharedObjectsContainer< TYPE >::SharedObjectsContainer | ( | const ConstVector & | data | ) | [inline] |
Definition at line 52 of file SharedObjectsContainer.h.
00053 : ObjectContainerBase () , m_data ( data ) {}
SharedObjectsContainer< TYPE >::SharedObjectsContainer | ( | DATA | first, | |
DATA | last | |||
) | [inline] |
the templated constructor from the pair of iterators
first | 'begin'-iterator of the input sequence | |
last | 'last'-iterator of the input sequence |
Definition at line 60 of file SharedObjectsContainer.h.
00062 : DataObject () 00063 , m_data ( first , last ) 00064 {}
SharedObjectsContainer< TYPE >::SharedObjectsContainer | ( | DATA | first, | |
DATA | last, | |||
const PREDICATE & | cut | |||
) | [inline] |
the templated constructor from the pair of iterators and the predicate.
Only the elements which satisfy the criteria goes into the container e.g. create the container only with "basic" particles:
typedef SharedObjectsContainer<LHCb::Particle> PARTICLES ; // some sequence of someting, convertiblle to "const LHCb::Particle*": SEQUENCE source = ... ; PARTICLES* particles = new PARTICLES ( source.begin() , source.end () , std::mem_fun(&LHCb::Particle::isBasic) ) ;
first | 'begin'-iterator if the input sequence | |
last | 'last'-iterator of the input sequence | |
cut | pre predicate |
Definition at line 90 of file SharedObjectsContainer.h.
00093 : DataObject () 00094 , m_data () 00095 { 00096 insert ( first , last , cut ) ; 00097 }
SharedObjectsContainer< TYPE >::SharedObjectsContainer | ( | const SharedObjectsContainer< TYPE > & | right | ) | [inline] |
copy constructor
Definition at line 99 of file SharedObjectsContainer.h.
00100 : DataObject ( right ) , m_data ( right.m_data ) {}
SharedObjectsContainer< TYPE >::~SharedObjectsContainer | ( | ) | [inline] |
virtual const CLID& SharedObjectsContainer< TYPE >::clID | ( | ) | const [inline, virtual] |
Retrieve the unique class ID (virtual).
Reimplemented from DataObject.
Definition at line 107 of file SharedObjectsContainer.h.
00108 { return SharedObjectsContainer<TYPE>::classID(); }
static const CLID& SharedObjectsContainer< TYPE >::classID | ( | ) | [inline, static] |
Retrieve the unuqie class ID (static).
Reimplemented from DataObject.
Definition at line 110 of file SharedObjectsContainer.h.
00111 { 00112 static const CLID s_clid = 00113 ( ( static_cast<CLID> ( -1 ) << 16 ) // 16 used and 16 empty bits 00114 & !CLID_ObjectVector // not an ObjectVector 00115 & !CLID_ObjectList // not an ObjectList 00116 & !static_cast<CLID> ( 0x00030000 ) // not a KeyedContainer/map 00117 & !static_cast<CLID> ( 0x00040000 ) )// not a KeyedContainer/hashmap 00118 + TYPE::classID() ; // the specific CLID from the contents 00119 // 00120 return s_clid; 00121 }
const ConstVector& SharedObjectsContainer< TYPE >::data | ( | ) | const [inline] |
get the access to the underlying container (const)
Definition at line 126 of file SharedObjectsContainer.h.
00126 { return m_data ; }
SharedObjectsContainer< TYPE >::operator const ConstVector & | ( | ) | const [inline] |
cast to the underlying container
Definition at line 128 of file SharedObjectsContainer.h.
00128 { return data () ; }
size_type SharedObjectsContainer< TYPE >::size | ( | ) | const [inline] |
get the actual size of the container
Definition at line 133 of file SharedObjectsContainer.h.
00133 { return m_data.size () ; }
bool SharedObjectsContainer< TYPE >::empty | ( | ) | const [inline] |
empty container?
Definition at line 135 of file SharedObjectsContainer.h.
00135 { return m_data.empty () ; }
void SharedObjectsContainer< TYPE >::push_back | ( | const TYPE * | object | ) | [inline] |
insert one object into the container
object | object to be added |
Definition at line 139 of file SharedObjectsContainer.h.
00139 { m_data.push_back ( object ) ; }
void SharedObjectsContainer< TYPE >::insert | ( | const TYPE * | object | ) | [inline] |
insert one object into the container
object | object to be added |
Definition at line 143 of file SharedObjectsContainer.h.
00143 { m_data.push_back ( object ) ; }
void SharedObjectsContainer< TYPE >::insert | ( | DATA | first, | |
DATA | last | |||
) | [inline] |
add the sequence of objects into the container
first | 'begin'-iterator for the sequnce | |
last | 'end'-iterator for the sequence |
Definition at line 150 of file SharedObjectsContainer.h.
void SharedObjectsContainer< TYPE >::insert | ( | DATA | first, | |
DATA | last, | |||
const PREDICATE & | cut | |||
) | [inline] |
add the sequence of 'good'objects into the container
Only the objects which satisfy the predicate go to the container, e.g. put into container only particles which transverse momentum in excess of 1 * GeV:
namespace bl = boost::lambda ; typedef SharedObjectsContainer<LHCb::Particle> PARTICLES ; // some sequence of someting, convertible to "const LHCb::Particle*": SEQUENCE source = ... ; PARTICLES* particles = ... ; particles -> insert ( source.begin() , source.end () , bl::bind(&LHCb::Particle::pt,bl::_1) > 1 * Gaudi::Units::GeV ) ;
first | 'begin'-iterator for the sequnce | |
last | 'end'-iterator for the sequence | |
cut | the predicate to be applied |
Definition at line 180 of file SharedObjectsContainer.h.
00183 { 00184 m_data.reserve ( m_data.size() + std::distance ( first , last ) ) ; 00185 for ( ; first != last ; ++first ) 00186 { if ( cut ( *first ) ) { m_data.push_back ( *first ) ; } } 00187 }
OUTPUT SharedObjectsContainer< TYPE >::get | ( | const PREDICATE & | cut, | |
OUTPUT | output | |||
) | const [inline] |
get from the container all objects which satisfy the certain criteria
E.g. get all particles with transverse momentum in excess of 1 * GeV
namespace bl = boost::lambda ; typedef SharedObjectsContainer<LHCb::Particle> PARTICLES ; typedef std::vector<const LHCb::Particle*> TARGET ; PARTICLES* particles = ... ; TARGET target ; particles -> get ( bl::bind(&LHCb::Particle::pt,bl::_1) > 1 * Gaudi::Units::GeV , std::back_inserter ( target ) ) ;
Essentially this functionality is very useful due to missing "std::copy_if".
cut | the predicate | |
outptut | the output iterator |
Definition at line 216 of file SharedObjectsContainer.h.
00218 { 00219 for ( const_iterator iobj = begin() ; end() != iobj ; ++iobj ) 00220 { if ( cut ( *iobj ) ) { *output = *iobj ; ++output ; } } 00221 return output ; 00222 }
void SharedObjectsContainer< TYPE >::erase | ( | iterator | i | ) | [inline] |
erase the object by iterator
Definition at line 224 of file SharedObjectsContainer.h.
00224 { m_data.erase ( i ) ; }
void SharedObjectsContainer< TYPE >::erase | ( | const PREDICATE & | cut | ) | [inline] |
erase the objects which satisfy the criteria
E.g. remove all particles with small transverse momentum
namespace bl = boost::lambda ; typedef SharedObjectsContainer<LHCb::Particle> PARTICLES ; PARTICLES* particles = ... ; particles -> erase ( bl::bind(&LHCb::Particle::pt,bl::_1) < 1 * Gaudi::Units::GeV ) ;
cut | predicate |
Definition at line 243 of file SharedObjectsContainer.h.
bool SharedObjectsContainer< TYPE >::erase | ( | const TYPE * | object | ) | [inline] |
erase the first occurance of the certain element
To remove all occurances one can use:
typedef SharedObjectsContainer<LHCb::Particle> PARTICLES ; PARTICLES* particles = ... ; const LHCb::Particle* B = ... ; // remove all occurances while ( particles -> erase ( B ) ) {} ;
object | the element to be removed |
Definition at line 263 of file SharedObjectsContainer.h.
00264 { 00265 iterator i = std::find ( begin() , end() , object ) ; 00266 if ( end() == i ) { return false ; } 00267 m_data.erase ( i ) ; 00268 return true ; 00269 }
reference SharedObjectsContainer< TYPE >::operator[] | ( | size_type | index | ) | [inline] |
const_reference SharedObjectsContainer< TYPE >::operator[] | ( | size_type | index | ) | const [inline] |
reference SharedObjectsContainer< TYPE >::operator() | ( | size_type | index | ) | [inline] |
const_reference SharedObjectsContainer< TYPE >::operator() | ( | size_type | index | ) | const [inline] |
reference SharedObjectsContainer< TYPE >::at | ( | size_type | index | ) | [inline] |
const_reference SharedObjectsContainer< TYPE >::at | ( | size_type | index | ) | const [inline] |
iterator SharedObjectsContainer< TYPE >::begin | ( | ) | [inline] |
iterator SharedObjectsContainer< TYPE >::end | ( | ) | [inline] |
const_iterator SharedObjectsContainer< TYPE >::begin | ( | ) | const [inline] |
const_iterator SharedObjectsContainer< TYPE >::end | ( | ) | const [inline] |
reverse_iterator SharedObjectsContainer< TYPE >::rbegin | ( | ) | [inline] |
reverse_iterator SharedObjectsContainer< TYPE >::rend | ( | ) | [inline] |
const_reverse_iterator SharedObjectsContainer< TYPE >::rbegin | ( | ) | const [inline] |
const_reverse_iterator SharedObjectsContainer< TYPE >::rend | ( | ) | const [inline] |
reference SharedObjectsContainer< TYPE >::front | ( | ) | [inline] |
the first element (only for non-empty vectors)
Definition at line 300 of file SharedObjectsContainer.h.
const_reference SharedObjectsContainer< TYPE >::front | ( | ) | const [inline] |
the first element (only for non-empty vectors) (const-version)
Definition at line 302 of file SharedObjectsContainer.h.
reference SharedObjectsContainer< TYPE >::back | ( | ) | [inline] |
the last element (only for non-empty vectors)
Definition at line 304 of file SharedObjectsContainer.h.
const_reference SharedObjectsContainer< TYPE >::back | ( | ) | const [inline] |
the last element (only for non-empty vectors) (const-version)
Definition at line 306 of file SharedObjectsContainer.h.
bool SharedObjectsContainer< TYPE >::operator== | ( | const SharedObjectsContainer< TYPE > & | right | ) | const [inline] |
bool SharedObjectsContainer< TYPE >::operator== | ( | const ConstVector & | right | ) | const [inline] |
equal content with corresponding vector ?
Definition at line 314 of file SharedObjectsContainer.h.
00315 { return m_data == right ; }
bool SharedObjectsContainer< TYPE >::operator< | ( | const SharedObjectsContainer< TYPE > & | right | ) | const [inline] |
bool SharedObjectsContainer< TYPE >::operator< | ( | const ConstVector & | right | ) | const [inline] |
comparisons with corresponding vector
Definition at line 320 of file SharedObjectsContainer.h.
00321 { return m_data < right ; }
virtual long SharedObjectsContainer< TYPE >::index | ( | const ContainedObject * | object | ) | const [inline, virtual] |
Distance of a given object from the beginning of its container.
object | the object to be checked |
Implements ObjectContainerBase.
Definition at line 328 of file SharedObjectsContainer.h.
00329 { 00330 const_iterator _i = std::find ( begin() , end() , object ) ; 00331 return end() != _i ? ( _i - begin() ) : -1 ; // RETURN 00332 }
virtual ContainedObject* SharedObjectsContainer< TYPE >::containedObject | ( | long | index | ) | const [inline, virtual] |
Pointer to an object of a given distance.
index | th eindex to be checked |
Implements ObjectContainerBase.
Definition at line 337 of file SharedObjectsContainer.h.
00338 { 00339 if ( 0 > index || !(index < (long) size () ) ) { return 0 ; } // RETURN 00340 const ContainedObject* co = m_data[index] ; 00341 return const_cast<ContainedObject*>( co ) ; 00342 }
virtual size_type SharedObjectsContainer< TYPE >::numberOfObjects | ( | ) | const [inline, virtual] |
Number of objects in the container.
Implements ObjectContainerBase.
Definition at line 344 of file SharedObjectsContainer.h.
00344 { return m_data.size() ; }
virtual long SharedObjectsContainer< TYPE >::add | ( | ContainedObject * | object | ) | [inline, virtual] |
Virtual functions (forwards to the concrete container definitions) Add an object to the container.
On success the object's index is returned.
Implements ObjectContainerBase.
Definition at line 349 of file SharedObjectsContainer.h.
00350 { 00351 if ( 0 == object ) { return -1 ; } // RETURN 00352 TYPE* _obj = dynamic_cast<TYPE*> ( object ) ; 00353 if ( 0 == _obj ) { return -1 ; } // RETURN 00354 const size_type pos = size() ; 00355 push_back ( _obj ) ; 00356 return pos ; 00357 }
virtual long SharedObjectsContainer< TYPE >::remove | ( | ContainedObject * | value | ) | [inline, virtual] |
Release object from the container (the pointer will be removed from the container, but the object itself will remain alive).
If the object was found it's index is returned.
Implements ObjectContainerBase.
Definition at line 362 of file SharedObjectsContainer.h.
00363 { 00364 iterator _i = std::find ( begin() , end() , value ) ; 00365 if ( end() == _i ) { return -1 ; } // RETURN 00366 const size_type pos = _i - begin() ; 00367 m_data.erase ( _i ) ; 00368 return pos ; // RETURN 00369 }
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 }
virtual std::ostream& DataObject::fillStream | ( | std::ostream & | s | ) | const [inline, virtual, inherited] |
Fill the output stream (ASCII).
Reimplemented in ObjectList< TYPE >, and ObjectVector< TYPE >.
Definition at line 91 of file DataObject.h.
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 }
ConstVector SharedObjectsContainer< TYPE >::m_data [private] |
Definition at line 374 of file SharedObjectsContainer.h.