ATLAS Offline Software
Loading...
Searching...
No Matches
JetSamplingCollectionCnv_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// JetSamplingCollectionCnv_p1.cxx
8// Implementation file for class JetSamplingCollectionCnv_p1
9// Author: S.Binet<binet@cern.ch>
11
12// DataModel includes
14
15// JetEvent includes
18
19
20// JetEventTPCnv includes
24
25// preallocate converters
26static const JetSamplingCnv_p1 jetSamplingCnv;
27
28
29void
32 MsgStream& msg ) const
33{
34// msg << MSG::DEBUG << "Loading JetSamplingCollection from persistent state..."
35// << endmsg;
36
37
38 // elements are managed by DataPool
40
42 const std::size_t nJetSampling = pers->size();
43 if ( pool.capacity() - pool.allocated() < nJetSampling ) {
44 pool.reserve( pool.allocated() + nJetSampling );
45 }
46
47 trans->reserve( nJetSampling );
48 for ( JetSamplingCollection_p1::const_iterator
49 itr = pers->begin(),
50 itrEnd = pers->end();
51 itr != itrEnd;
52 ++itr ) {
53 JetSampling * jetSampling = pool.nextElementPtr();
54 jetSamplingCnv.persToTrans( &(*itr), jetSampling, msg );
55 trans->push_back( jetSampling );
56 }
57// msg << MSG::DEBUG << "Loading JetSamplingCollection from persistent state [OK]"
58// << endmsg;
59 }
60
61void
64 MsgStream& msg ) const
65{
66// msg << MSG::DEBUG << "Creating persistent state of JetSamplingCollection..."
67// << endmsg;
68
69 std::size_t size = trans->size();
70 pers->resize(size);
71
72 // convert vector entries one by one
74 JetSamplingCollection_p1::iterator persItr = pers->begin();
75 while(size) {
76 jetSamplingCnv.transToPers( *transItr, &(*persItr), msg );
77 ++persItr; ++transItr; --size;
78 }
79
80// msg << MSG::DEBUG << "Creating persistent state of JetSamplingCollection [OK]"
81// << endmsg;
82 }
83
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 JetSamplingCollection *trans, JetSamplingCollection_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation JetSamplingCollection_p1 from its transient representat...
virtual void persToTrans(const JetSamplingCollection_p1 *pers, JetSamplingCollection *trans, MsgStream &msg) const override
Method creating the transient representation of JetSamplingCollection from its persistent representat...
@ 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