1#ifndef DATAMODEL_DATAVECTOR_H
2#define DATAMODEL_DATAVECTOR_H
19#ifndef DATAMODEL_OWNERSHIPPOLICY_H
20# include "DataModel/OwnershipPolicy.h"
23#ifndef BOOST_CONCEPT_CHECKS_HPP
24# include <boost/concept_check.hpp>
27#ifndef GAUDIKERNEL_SYSTEM_H
28# include "GaudiKernel/System.h"
36 template <
typename Element>
bool operator()( Element*
f, Element*
s )
const {
38 if ( !m_quiet && areEq &&
f != 0 )
40 std::cout <<
"WARNING: duplicated pointer found in a DataVector of "
41 << System::typeinfoName(
typeid( *
f ) ) <<
" owning its elements! "
42 << std::hex <<
f << std::dec << std::endl;
52# define DEFQUIET false
56 template <
class ForwIter>
93#ifndef __ATLAS_SEAL_DICT__
98 typedef std::vector<T*> PtrVector;
104 const PtrVector&
stdcont()
const {
return m_pCont; }
126 : m_ownPolicy( ownPolicy ), m_pCont() {}
131 : m_ownPolicy( ownPolicy ) {
141 : m_ownPolicy(
SG::VIEW_ELEMENTS ), m_pCont( rhs.
stdcont() ) {
147 template <
class InputIterator>
150 : m_ownPolicy( ownPolicy ), m_pCont( first, last ) {}
162 template <
class InputIterator>
void assign( InputIterator first, InputIterator last ) {
164 insert( begin(), first, last );
174 while (
iter != new_end )
delete *(
iter++ );
181#define FUNFWD( func ) \
182 func() { return m_pCont.func(); }
183#define CONSTFUNFWD( func ) \
184 func() const { return m_pCont.func(); }
185#define FUNFWDN( func ) \
186 func( size_type n ) { return m_pCont.func( n ); }
187#define CONSTFUNFWDN( func ) \
188 func( size_type n ) const { return m_pCont.func( n ); }
207 if ( sz < size() ) {
erase( begin() + sz, end() ); }
213 insert( end(), sz - size(), 0 );
226 std::advance( m_proxied, index );
232 *m_proxied = *( rhs.m_proxied );
242 operator T*
const()
const {
return *m_proxied; }
272 return m_pCont.insert( position, pElem );
276 template <
class InputIterator>
278 m_pCont.insert( position, first, last );
282 if ( m_ownPolicy ==
SG::OWN_ELEMENTS && position != end() )
delete position;
283 return m_pCont.erase( position );
287 if ( first == last )
return first;
292 while (
iter != new_end )
delete *(
iter++ );
294 return m_pCont.erase( first, last );
297 std::swap( m_ownPolicy, rhs.m_ownPolicy );
298 m_pCont.swap( rhs.m_pCont );
319 m_pCont.insert( position,
n, pElem );
331#define COMPOP( oper ) \
332 template <class T> bool operator oper( const DataVector<T> lhs, const DataVector<T> rhs ) { \
333 return lhs.stdcont() oper rhs.stdcont(); \
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
void swap(DataVector< T > lhs, DataVector< T > rhs)
EvtComplex cont(const EvtTensor4C &t1, const EvtTensor4C &t2)
ElementProxy & operator=(value_type rhs)
lvalue uses assignment
ElementProxy & operator=(const ElementProxy &rhs)
lvalue uses assignment
ElementProxy(iterator iter)
ElementProxy(PtrVector &cont, size_type index)
an STL vector of pointers that by default owns its pointed elements.
iterator erase(iterator position)
the ownership policy will determine whether to erase the pointee
PtrVector::const_iterator const_iterator
const T * CONSTFUNFWDN(operator[])
standard return value is const_reference i.e. const T*&!
ElementProxy operator[](size_type n)
standard return value is reference!
void insert(iterator position, InputIterator first, InputIterator last)
the ownership policy will determine who owns the inserted elements
DataVector(InputIterator first, InputIterator last, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
DataVector(const DataVector< T > &rhs)
size_type CONSTFUNFWD(size)
PtrVector::allocator_type allocator_type
void assign(InputIterator first, InputIterator last)
the ownership policy will determine who owns the assigned elements
void push_back(value_type pElem)
size_type CONSTFUNFWD(max_size)
void swap(DataVector< T > &rhs)
void resize(size_type sz)
Non standard. When increasing size always set the new elements to 0.
const_iterator CONSTFUNFWD(rend)
iterator erase(iterator first, iterator last)
the ownership policy will determine whether to erase the pointee
DataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Non standard: always set elements to 0.
const_iterator CONSTFUNFWD(end)
PtrVector::const_reverse_iterator const_reverse_iterator
const PtrVector & stdcont() const
access the underlying std vector;
PtrVector::iterator iterator
PtrVector::size_type size_type
const T * CONSTFUNFWD(front)
const_iterator CONSTFUNFWD(begin)
const T * CONSTFUNFWDN(at)
size_type CONSTFUNFWD(capacity)
iterator insert(iterator position, value_type pElem)
the ownership policy will determine who owns the inserted elements
PtrVector::reverse_iterator reverse_iterator
PtrVector::difference_type difference_type
const_iterator CONSTFUNFWD(rbegin)
const T *& const_reference
DataVector< T > & operator=(const DataVector< T > &rhs)
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
const T * CONSTFUNFWD(back)
ElementProxy at(size_type n)
CompareAndPrint(bool quiet)
bool operator()(Element *f, Element *s) const
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
@ OWN_ELEMENTS
this data object owns its elements
ForwIter remove_duplicates(ForwIter b, ForwIter e, bool quiet=DEFQUIET)