ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleShallowCloneContainerCnv_p1.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5*/
6
7// ParticleShallowCloneContainerCnv_p1.cxx
8// Implementation file for class ParticleShallowCloneContainerCnv_p1
9// Author: Karsten Koeneke - February 2013
11
13
14// ParticleEvent includes
17
18
19// ParticleEventTPCnv includes
23
24// preallocate converters
26
27
28void
31 MsgStream& msg ) const
32{
33// msg << MSG::DEBUG << "Loading ParticleShallowCloneContainer from persistent state..."
34// << endmsg;
35
36 // elements are managed by DataPool
38
40 const std::size_t nElems = pers->size();
41 if ( pool.capacity() - pool.allocated() < nElems ) {
42 pool.reserve( pool.allocated() + nElems );
43 }
44
45 trans->reserve( nElems );
46 for ( ParticleShallowCloneContainer_p1::const_iterator
47 itr = pers->begin(),
48 itrEnd = pers->end();
49 itr != itrEnd;
50 ++itr )
51 {
52 Analysis::ParticleShallowClone * p = pool.nextElementPtr();
53 s_cpCnv.persToTrans( &(*itr), p, msg );
54 trans->push_back( p );
55 }
56// msg << MSG::DEBUG << "Loading ParticleShallowCloneContainer from persistent state [OK]"
57// << endmsg;
58 return;
59}
60
61void
64 MsgStream& msg ) const
65{
66// msg << MSG::DEBUG
67// << "Creating persistent state of ParticleShallowCloneContainer..."
68// << endmsg;
69
70 std::size_t size = trans->size();
71 pers->resize(size);
72
73 // convert vector entries one by one
75 ParticleShallowCloneContainer_p1::iterator persItr = pers->begin();
76 while(size)
77 {
78 s_cpCnv.transToPers( *transItr, &(*persItr), msg );
79 ++persItr; ++transItr; --size;
80 }
81
82// msg << MSG::DEBUG
83// << "Creating persistent state of ParticleShallowCloneContainer [OK]"
84// << endmsg;
85 return;
86}
static const CompositeParticleCnv_p1 s_cpCnv
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.
virtual void transToPers(const ParticleShallowCloneContainer *trans, ParticleShallowCloneContainer_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation ParticleShallowCloneContainer_p1 from its transient rep...
virtual void persToTrans(const ParticleShallowCloneContainer_p1 *pers, ParticleShallowCloneContainer *trans, MsgStream &msg) const override
Method creating the transient representation of ParticleShallowCloneContainer from its persistent rep...
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
pool namespace
Definition libname.h:15
MsgStream & msg
Definition testRead.cxx:32