1 #ifndef GAUDIKERNEL_SHAREDOBJECTSCONTAINER_H
2 #define GAUDIKERNEL_SHAREDOBJECTSCONTAINER_H 1
12 #include "GaudiKernel/Kernel.h"
13 #include "GaudiKernel/ClassID.h"
14 #include "GaudiKernel/ObjectContainerBase.h"
35 typedef typename ConstVector::value_type
value_type ;
36 typedef typename ConstVector::size_type
size_type ;
39 typedef typename ConstVector::iterator
iterator ;
82 template <
class DATA,
class PREDICATE>
86 insert ( first , last , cut ) ;
99 static const CLID s_clid =
100 ( (
static_cast<CLID> ( -1 ) << 16 )
103 & !
static_cast<CLID> ( 0x00030000 )
104 & !static_cast<CLID> ( 0x00040000 ) )
113 inline const ConstVector&
data ()
const {
return m_data ; }
115 operator const ConstVector& ()
const {
return data () ; }
120 size_type
size ()
const {
return m_data.size () ; }
126 void push_back (
const TYPE*
object ) {
m_data.push_back (
object ) ; }
130 void insert (
const TYPE*
object ) {
m_data.push_back (
object ) ; }
135 template <
class DATA>
138 DATA last ) {
m_data.insert (
end() , first ,last ) ; }
165 template <
class DATA,
class PREDICATE>
169 const PREDICATE& cut )
171 m_data.reserve (
m_data.size() + std::distance ( first , last ) ) ;
172 for ( ; first != last ; ++first )
173 {
if ( cut ( *first ) ) {
m_data.push_back ( *first ) ; } }
202 template <
class OUTPUT,
class PREDICATE>
203 OUTPUT
get (
const PREDICATE& cut ,
204 OUTPUT output )
const
206 for ( const_iterator iobj =
begin() ;
end() != iobj ; ++iobj )
207 {
if ( cut ( *iobj ) ) { *output = *iobj ; ++output ; } }
229 template <
class PREDICATE>
230 void erase (
const PREDICATE& cut )
250 bool erase (
const TYPE*
object )
252 iterator i = std::find (
begin() ,
end() ,
object ) ;
253 if (
end() == i ) {
return false ; }
269 reference
at ( size_type
index ) {
return m_data.at(index) ; }
271 const_reference
at ( size_type index )
const {
return m_data.at(index) ; }
278 const_iterator
end ()
const {
return m_data .
end () ; }
282 const_reverse_iterator
rend ()
const {
return m_data .
rend () ; }
301 bool operator== (
const ConstVector& right )
const
302 {
return m_data == right ; }
307 bool operator < (
const ConstVector& right )
const
308 {
return m_data < right ; }
317 const_iterator _i = std::find (
begin() ,
end() ,
object ) ;
318 return end() != _i ? ( _i -
begin() ) : -1 ;
326 if ( 0 > index || !(index < (
long)
size () ) ) {
return 0 ; }
338 if ( 0 ==
object ) {
return -1 ; }
339 TYPE* _obj =
dynamic_cast<TYPE*
> ( object ) ;
340 if ( 0 == _obj ) {
return -1 ; }
341 const size_type pos =
size() ;
352 if (
end() == _i ) {
return -1 ; }
353 const size_type pos = _i -
begin() ;
367 #endif // GAUDIKERNEL_SHAREDOBJECTSCONTAINER_H
virtual const CLID & clID() const
Retrieve the unique class ID (virtual)
reference front()
the first element (only for non-empty vectors)
Very simple class to represent the container of objects which are not ownered by the container...
virtual ContainedObject * containedObject(long index) const
Pointer to an object of a given distance.
reference operator()(size_type index)
'functional'-access
bool operator==(const SharedObjectsContainer &right) const
equal content with other container ?
void push_back(const TYPE *object)
insert one object into the container
bool operator<(const SharedObjectsContainer &right) const
comparisons with other container
ConstVector::size_type size_type
ConstVector::reverse_iterator reverse_iterator
size_type size() const
get the actual size of the container
virtual long add(ContainedObject *object)
Virtual functions (forwards to the concrete container definitions) Add an object to the container...
reverse_iterator rbegin()
ConstVector::iterator iterator
ConstVector::const_reference const_reference
void insert(const TYPE *object)
insert one object into the container
virtual long index(const ContainedObject *object) const
Distance of a given object from the beginning of its container.
ConstVector::const_iterator const_iterator
const ConstVector & data() const
get the access to the underlying container (const)
virtual ~SharedObjectsContainer()
destructor
reference at(size_type index)
checked access
unsigned int CLID
Class ID definition.
virtual size_type numberOfObjects() const
Number of objects in the container.
bool empty() const
empty container?
reference operator[](size_type index)
index access
std::vector< const TYPE * > ConstVector
the actual container type
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
static const CLID & classID()
Retrieve the unuqie class ID (static)
ConstVector::reference reference
reference back()
the last element (only for non-empty vectors)
ObjectContainerBase is the base class for Gaudi container classes.
TO * reference(FROM *from)
void erase(iterator i)
erase the object by iterator
ConstVector::const_reverse_iterator const_reverse_iterator
ConstVector::value_type value_type
various types (to make STL happy)