ATLAS Offline Software
Loading...
Searching...
No Matches
CompositeParticleContainerCnv_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// CompositeParticleContainerCnv_p1.cxx
8// Implementation file for class CompositeParticleContainerCnv_p1
9// Author: S.Binet<binet@cern.ch>
11
13
14// ParticleEvent includes
15#include "ParticleEvent/CompositeParticle.h"
16#include "ParticleEvent/CompositeParticleContainer.h"
17
18
19// ParticleEventTPCnv includes
23
24// preallocate converters
26
27
28void
31 MsgStream& msg ) const
32{
33// msg << MSG::DEBUG << "Loading CompositeParticleContainer 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 ( CompositeParticleContainer_p1::const_iterator
47 itr = pers->begin(),
48 itrEnd = pers->end();
49 itr != itrEnd;
50 ++itr ) {
51 CompositeParticle * p = pool.nextElementPtr();
52 s_cpCnv.persToTrans( &(*itr), p, msg );
53 trans->push_back( p );
54 }
55// msg << MSG::DEBUG << "Loading CompositeParticleContainer from persistent state [OK]"
56// << endmsg;
57 return;
58}
59
60void
63 MsgStream& msg ) const
64{
65// msg << MSG::DEBUG
66// << "Creating persistent state of CompositeParticleContainer..."
67// << endmsg;
68
69 std::size_t size = trans->size();
70 pers->resize(size);
71
72 // convert vector entries one by one
74 CompositeParticleContainer_p1::iterator persItr = pers->begin();
75 while(size) {
76 s_cpCnv.transToPers( *transItr, &(*persItr), msg );
77 ++persItr; ++transItr; --size;
78 }
79
80// msg << MSG::DEBUG
81// << "Creating persistent state of CompositeParticleContainer [OK]"
82// << endmsg;
83 return;
84}
static const CompositeParticleCnv_p1 s_cpCnv
virtual void transToPers(const CompositeParticleContainer *trans, CompositeParticleContainer_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation CompositeParticleContainer_p1 from its transient repres...
virtual void persToTrans(const CompositeParticleContainer_p1 *pers, CompositeParticleContainer *trans, MsgStream &msg) const override
Method creating the transient representation of CompositeParticleContainer from its persistent repres...
class which is made from the composition of other particles.
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.
@ 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