ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::ByteStreamAuxContainer_v1 Class Referenceabstract

Base class for dynamic auxiliary stores saved into ByteStream. More...

#include <ByteStreamAuxContainer_v1.h>

Inheritance diagram for xAOD::ByteStreamAuxContainer_v1:

Public Types

typedef SG::auxid_t auxid_t
 The aux ID type definition from IConstAuxStore.
typedef SG::auxid_set_t auxid_set_t
 The aux ID set type definition from IConstAuxStore.
template<class T, class ALLOC = std::allocator<T>>
using AuxVariable_t = std::vector<T, ALLOC>
 Declare how to wrap variables for this sort of base.

Public Member Functions

 ByteStreamAuxContainer_v1 ()
 Default constructor.
 ByteStreamAuxContainer_v1 (const ByteStreamAuxContainer_v1 &parent)
 Copy constructor.
virtual ~ByteStreamAuxContainer_v1 ()
 Destructor.
ByteStreamAuxContainer_v1operator= (const ByteStreamAuxContainer_v1 &rhs)
 Assignment operator.
void reset ()
 Function resetting the internal (cached) state of the object.
template<typename T>
auxid_t getAuxID (const std::string &name, std::vector< T > &, SG::AuxVarFlags flags=SG::AuxVarFlags::None)
 Get the auxiliary ID for one of the persistent variables.
template<typename T>
void regAuxVar (auxid_t auxid, const std::string &name, std::vector< T > &vec)
 Register one of the user defined persistent variables internally.
virtual void toTransient (const EventContext &ctx) override
 Perform post-read processing on this store.
virtual bool insertMove (size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore=SG::auxid_set_t())=0
 Move all elements from other to this store.
virtual bool setOption (auxid_t, const AuxDataOption &)
 Set an option for a given auxiliary variable.
virtual IAuxTypeVector * linkedVector (SG::auxid_t)
Functions implementing the SG::IConstAuxStore interface
virtual const void * getData (auxid_t auxid) const override
 Get a pointer to a given array.
virtual const SG::IAuxTypeVectorgetVector (auxid_t auxid) const override final
 Return vector interface for one aux data item.
virtual const auxid_set_tgetAuxIDs () const override
 Get the types(names) of variables handled by this container.
virtual const auxid_set_tgetDecorIDs () const override
 Get the types(names) of decorations handled by this container.
virtual void * getDecoration (auxid_t auxid, size_t size, size_t capacity) override
 Get a pointer to a given array, as a decoration.
virtual SG::auxid_set_t getCopyIDs (bool warnUnlocked=false) const override
 Get the set of variables that we should deep copy.
virtual bool isDecoration (auxid_t auxid) const override
 Test if a variable is a decoration.
virtual void lock () override
 Lock the container.
virtual bool clearDecorations () override
 Clear all decorations.
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration.
virtual size_t size () const override
 Get the size of the container.
Functions implementing the SG::IAuxStore interface
virtual void * getData (auxid_t auxid, size_t size, size_t capacity) override
 Get a pointer to a given array, creating the array if necessary.
virtual const auxid_set_tgetWritableAuxIDs () const override
 Return a set of writable data identifiers.
virtual bool resize (size_t size) override
 Resize the arrays to a given size.
virtual void reserve (size_t size) override
 Reserve a given size for the arrays.
virtual void shift (size_t pos, ptrdiff_t offs) override
 Shift the contents of the stored arrays.
virtual bool insertMove (size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore) override
 Insert contents of another store via move.
Functions managing the instance name of the container
const charname () const
 Get the name of the container instance.
void setName (const char *name)
 Set the name of the container instance.

Static Public Attributes

static constexpr bool supportsThinning = true
 Mark that this type supports thinning operations.

Private Member Functions

size_t size_noLock () const
 Internal method: return size without taking out the lock.
template<typename T>
SG::IAuxTypeVectorgetVector1 (auxid_t auxid, std::map< std::string, std::vector< T > > &pers, size_t size, size_t capacity, bool quiet, bool forDecor) const
 Function retrieving a simple dynamic variable.
SG::IAuxTypeVectorgetVector1 (auxid_t auxid, size_t size, size_t capacity, bool quiet, bool forDecor) const

Private Attributes

std::string m_name
 Name of the container in memory. Set externally.
Variables persisified into the ByteStream
std::map< std::string, std::vector< int > > m_int ATLAS_THREAD_SAFE
 Variable holding integer auxiliary variables.
std::map< std::string, std::vector< float > > m_float ATLAS_THREAD_SAFE
 Variable holding float auxiliary variables.
std::map< std::string, std::vector< std::vector< int > > > m_vecInt ATLAS_THREAD_SAFE
 Variable holding vector of integer auxiliary variables.
std::map< std::string, std::vector< std::vector< float > > > m_vecFloat ATLAS_THREAD_SAFE
 Variable holding vector of float auxiliary variables.

Transient variables used to implement the IAuxStore interface

typedef AthContainers_detail::mutex mutex_t
 Mutex for multithread synchronization.
typedef AthContainers_detail::lock_guard< mutex_tguard_t
auxid_set_t m_auxids ATLAS_THREAD_SAFE
 Internal list of auxiliary variables.
std::vector< SG::IAuxTypeVector * > m_staticVecs
 Internal list of static managed variables.
std::vector< SG::IAuxTypeVector * > m_dynamicVecs ATLAS_THREAD_SAFE
 Internal list of dynamic managed variables.
bool m_locked
 Has the container been locked?
SG::auxid_set_t m_decorations
 Record which variables are decorations.
mutex_t m_mutex

Detailed Description

Base class for dynamic auxiliary stores saved into ByteStream.

The point of this class is to behave similarly to xAOD::AuxContainerBase. The trigger developers can develop their specific auxiliary store classes on top of this class. The base class can manage the storage of simple variable types, while the classes inheriting from it need to manage any specific variables that they want to store.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 37 of file ByteStreamAuxContainer_v1.h.

Member Typedef Documentation

◆ auxid_set_t

The aux ID set type definition from IConstAuxStore.

Definition at line 46 of file ByteStreamAuxContainer_v1.h.

◆ auxid_t

The aux ID type definition from IConstAuxStore.

Definition at line 44 of file ByteStreamAuxContainer_v1.h.

◆ AuxVariable_t

template<class T, class ALLOC = std::allocator<T>>
using xAOD::ByteStreamAuxContainer_v1::AuxVariable_t = std::vector<T, ALLOC>

Declare how to wrap variables for this sort of base.

Definition at line 135 of file ByteStreamAuxContainer_v1.h.

◆ guard_t

◆ mutex_t

Mutex for multithread synchronization.

Definition at line 200 of file ByteStreamAuxContainer_v1.h.

Constructor & Destructor Documentation

◆ ByteStreamAuxContainer_v1() [1/2]

xAOD::ByteStreamAuxContainer_v1::ByteStreamAuxContainer_v1 ( )

Default constructor.

Definition at line 24 of file ByteStreamAuxContainer_v1.cxx.

25 : SG::IAuxStore(),
26 m_int(), m_float(), m_vecInt(), m_vecFloat(),
27 m_staticVecs(), m_dynamicVecs(),
28 m_locked( false ),
29 m_name( "UNKNOWN" ) {
30
31 }
std::vector< SG::IAuxTypeVector * > m_staticVecs
Internal list of static managed variables.
bool m_locked
Has the container been locked?
std::string m_name
Name of the container in memory. Set externally.

◆ ByteStreamAuxContainer_v1() [2/2]

xAOD::ByteStreamAuxContainer_v1::ByteStreamAuxContainer_v1 ( const ByteStreamAuxContainer_v1 & parent)

Copy constructor.

Definition at line 33 of file ByteStreamAuxContainer_v1.cxx.

35 : SG::IAuxStore( parent ),
36 m_int( parent.m_int ), m_float( parent.m_float ),
37 m_vecInt( parent.m_vecInt ), m_vecFloat( parent.m_vecFloat ),
38 // The auxiliary IDs are copied:
39 m_auxids( parent.m_auxids ),
40 // But the internal pointers are not:
42 m_dynamicVecs(), m_locked( false ),
43 m_name( parent.m_name ) {
44
45 }
SG::auxid_set_t m_auxids
Set of auxid's for which we've created a vector.

◆ ~ByteStreamAuxContainer_v1()

xAOD::ByteStreamAuxContainer_v1::~ByteStreamAuxContainer_v1 ( )
virtual

Destructor.

Definition at line 47 of file ByteStreamAuxContainer_v1.cxx.

47 {
48
49 // Clean up the helper objects:
50 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
51 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
52 for( ; itr != end; ++itr ) {
53 if( *itr ) delete *itr;
54 }
55 itr = m_staticVecs.begin();
56 end = m_staticVecs.end();
57 for( ; itr != end; ++itr ) {
58 if( *itr ) delete *itr;
59 }
60 }

Member Function Documentation

◆ clearDecorations()

bool xAOD::ByteStreamAuxContainer_v1::clearDecorations ( )
overridevirtual

Clear all decorations.

Definition at line 205 of file ByteStreamAuxContainer_v1.cxx.

206 {
207 guard_t guard (m_mutex);
208
209 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
210
211 bool anycleared = false;
212 for (auxid_t auxid : m_decorations) {
213 if (m_dynamicVecs[auxid]) {
214 delete m_dynamicVecs[auxid];
215 m_dynamicVecs[auxid] = nullptr;
216 m_auxids.erase( auxid );
217 anycleared = true;
218
219 const std::string name = r.getName( auxid );
220 const std::type_info* ti = r.getType( auxid );
221 if (ti == &typeid(int))
222 m_int.erase (name);
223 else if (ti == &typeid(float))
224 m_float.erase (name);
225 else if (ti == &typeid(std::vector<int>))
226 m_vecInt.erase (name);
227 else if (ti == &typeid(std::vector<float>))
228 m_vecFloat.erase (name);
229 }
230 }
231 m_decorations.clear();
232
233 return anycleared;
234 }
static AuxTypeRegistry & instance()
Return the singleton registry instance.
SG::auxid_set_t m_decorations
Record which variables are decorations.
const char * name() const
Get the name of the container instance.
SG::auxid_t auxid_t
The aux ID type definition from IConstAuxStore.
AthContainers_detail::lock_guard< mutex_t > guard_t
int r
Definition globals.cxx:22
SG::auxid_t auxid() const
Return the aux id for this variable.

◆ getAuxID()

template<typename T>
auxid_t xAOD::ByteStreamAuxContainer_v1::getAuxID ( const std::string & name,
std::vector< T > & ,
SG::AuxVarFlags flags = SG::AuxVarFlags::None )

Get the auxiliary ID for one of the persistent variables.

◆ getAuxIDs()

const ByteStreamAuxContainer_v1::auxid_set_t & xAOD::ByteStreamAuxContainer_v1::getAuxIDs ( ) const
overridevirtual

Get the types(names) of variables handled by this container.

Definition at line 123 of file ByteStreamAuxContainer_v1.cxx.

123 {
124
125 // Return the full list of IDs:
126 return getWritableAuxIDs();
127 }
virtual const auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.

◆ getCopyIDs()

SG::auxid_set_t xAOD::ByteStreamAuxContainer_v1::getCopyIDs ( bool warnUnlocked = false) const
overridevirtual

Get the set of variables that we should deep copy.

Definition at line 186 of file ByteStreamAuxContainer_v1.cxx.

187 {
188 return SG::getCopyIDs (getAuxIDs(), getDecorIDs(), warnUnlocked, {});
189 }
virtual const auxid_set_t & getDecorIDs() const override
Get the types(names) of decorations handled by this container.
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
virtual SG::auxid_set_t getCopyIDs(bool warnUnlocked=false) const override
Return the set of variables to copy in a deep copy.

◆ getData() [1/2]

const void * xAOD::ByteStreamAuxContainer_v1::getData ( auxid_t auxid) const
overridevirtual

Get a pointer to a given array.

Definition at line 91 of file ByteStreamAuxContainer_v1.cxx.

91 {
92
93 const SG::IAuxTypeVector* v = getVector( auxid );
94 if( v ) {
95 return v->toPtr();
96 }
97 return nullptr;
98 }
virtual const SG::IAuxTypeVector * getVector(auxid_t auxid) const override final
Return vector interface for one aux data item.

◆ getData() [2/2]

void * xAOD::ByteStreamAuxContainer_v1::getData ( auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Get a pointer to a given array, creating the array if necessary.

Implements SG::IAuxStore.

Definition at line 270 of file ByteStreamAuxContainer_v1.cxx.

271 {
272
273 guard_t guard (m_mutex);
274
275 // Check if we have such a static variable:
276 if( ( auxid < m_staticVecs.size() ) && ( m_staticVecs[ auxid ] ) ) {
277 // Set it to the right size:
278 m_staticVecs[ auxid ]->reserve( capacity );
279 m_staticVecs[ auxid ]->resize( size );
280 // We're done already:
281 return m_staticVecs[ auxid ]->toPtr();
282 }
283 // Check if we already know about this dynamic variable:
284 else if( ( auxid < m_dynamicVecs.size() ) &&
285 ( m_dynamicVecs[ auxid ] ) ) {
286 // Set it to the right size:
287 m_dynamicVecs[ auxid ]->reserve( capacity );
288 m_dynamicVecs[ auxid ]->resize( size );
289 // We're done already:
290 return m_dynamicVecs[ auxid ]->toPtr();
291 }
292
293 SG::IAuxTypeVector* v = getVector1 (auxid, size, capacity, false, false);
294 if( v ) {
295 return v->toPtr();
296 }
297 return nullptr;
298 }
virtual size_t size() const override
Get the size of the container.
SG::IAuxTypeVector * getVector1(auxid_t auxid, std::map< std::string, std::vector< T > > &pers, size_t size, size_t capacity, bool quiet, bool forDecor) const
Function retrieving a simple dynamic variable.

◆ getDecoration()

void * xAOD::ByteStreamAuxContainer_v1::getDecoration ( auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Get a pointer to a given array, as a decoration.

Definition at line 137 of file ByteStreamAuxContainer_v1.cxx.

140 {
141 guard_t guard (m_mutex);
142
143 // Does this variable already exist?
144 void* ret = nullptr;
145 if( ( auxid < m_staticVecs.size() ) && ( m_staticVecs[ auxid ] ) ) {
146 ret = m_staticVecs[ auxid ]->toPtr();
147 }
148 // If it's a dynamic one:
149 else if( ( auxid < m_dynamicVecs.size() ) &&
150 ( m_dynamicVecs[ auxid ] ) ) {
151 ret = m_dynamicVecs[ auxid ]->toPtr();
152 }
153
154 if (!ret) {
155 SG::IAuxTypeVector* v = getVector1 (auxid, 0, 0, true, true);
156 if( v ) {
157 ret = v->toPtr();
158 }
159 }
160
161 if (ret) {
162 // Raise exception if locked and not a decoration.
163 if (m_locked) {
164 if ( ! m_decorations.test (auxid) ) {
165 throw SG::ExcStoreLocked (auxid);
166 }
167 }
168 return ret;
169 }
170
171 // Make a new variable.
172 // If locked, mark as a decoration.
173 if (m_locked) {
174 m_decorations.insert (auxid);
175 std::atomic_thread_fence (std::memory_order_seq_cst);
176 }
177 SG::IAuxTypeVector* v = getVector1 (auxid, size, capacity, false, true);
178 if( v ) {
179 ret = v->toPtr();
180 }
181
182 return ret;
183 }

◆ getDecorIDs()

const ByteStreamAuxContainer_v1::auxid_set_t & xAOD::ByteStreamAuxContainer_v1::getDecorIDs ( ) const
overridevirtual

Get the types(names) of decorations handled by this container.

Definition at line 130 of file ByteStreamAuxContainer_v1.cxx.

130 {
131
132 // Return the full list of IDs:
133 return m_decorations;
134 }

◆ getVector()

const SG::IAuxTypeVector * xAOD::ByteStreamAuxContainer_v1::getVector ( auxid_t auxid) const
finaloverridevirtual

Return vector interface for one aux data item.

Definition at line 100 of file ByteStreamAuxContainer_v1.cxx.

100 {
101
102 guard_t guard (m_mutex);
103
104 // If it's a static auxiliary property:
105 if( ( auxid < m_staticVecs.size() ) && ( m_staticVecs[ auxid ] ) ) {
106 // We're done already:
107 return m_staticVecs[ auxid ];
108 }
109 // If it's a dynamic one:
110 else if( ( auxid < m_dynamicVecs.size() ) &&
111 ( m_dynamicVecs[ auxid ] ) ) {
112 // We're done already:
113 return m_dynamicVecs[ auxid ];
114 }
115
116 // Try to retrieve the dynamic variable:
117 // quiet on because this method may be called from isAccessible
118 // and that shouldn't generate any output.
119 return getVector1 (auxid, 0, 0, true, false);
120 }

◆ getVector1() [1/2]

SG::IAuxTypeVector * xAOD::ByteStreamAuxContainer_v1::getVector1 ( auxid_t auxid,
size_t size,
size_t capacity,
bool quiet,
bool forDecor ) const
private

Definition at line 547 of file ByteStreamAuxContainer_v1.cxx.

550 {
551
552 // Private method --- should hold lock before calling this.
553
554 if( *( SG::AuxTypeRegistry::instance().getType( auxid ) ) ==
555 typeid( int ) ) {
556
557 return getVector1( auxid, m_int, size, capacity, quiet, forDecor );
558 }
559 else if( *( SG::AuxTypeRegistry::instance().getType( auxid ) ) ==
560 typeid( float ) ) {
561
562 return getVector1( auxid, m_float, size, capacity, quiet, forDecor );
563 }
564 else if( *( SG::AuxTypeRegistry::instance().getType( auxid ) ) ==
565 typeid( std::vector< int > ) ) {
566
567 return getVector1( auxid, m_vecInt, size, capacity, quiet, forDecor );
568 }
569 else if( *( SG::AuxTypeRegistry::instance().getType( auxid ) ) ==
570 typeid( std::vector< float > ) ) {
571
572 return getVector1( auxid, m_vecFloat, size, capacity, quiet, forDecor );
573 }
574
575 // The object can't handle this variable type...
576 if (!quiet) {
577 std::cerr << "ERROR xAOD::ByteStreamAuxContainer_v1::getData "
578 << "Unknown variable type ("
580 << ") requested for variable "
582 << " (" << auxid << ")"
583 << std::endl;
584 }
585
586 return nullptr;
587 }
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
T getType(const char *cStr)
Return Ringer enumeration of type T identifying string type:

◆ getVector1() [2/2]

template<typename T>
SG::IAuxTypeVector * xAOD::ByteStreamAuxContainer_v1::getVector1 ( auxid_t auxid,
std::map< std::string, std::vector< T > > & pers,
size_t size,
size_t capacity,
bool quiet,
bool forDecor ) const
private

Function retrieving a simple dynamic variable.

Look for variable auxid in pers.

If capacity > 0, a new variable will be created if necessary.

If not found, create it if capacity != 0.

Definition at line 475 of file ByteStreamAuxContainer_v1.cxx.

480 {
481
482 // Private method --- should hold lock before calling this.
483
484 // Look up the name of the variable:
485 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
486 const std::string name = r.getName( auxid );
487
488 // Try to find the variable:
489 typename std::map< std::string, std::vector< T > >::iterator itr =
490 pers.find( name );
491 if( itr == pers.end() ) {
492 // Variable isn't there. Fail if capacity==0.
493 if (capacity == 0) {
494 if (!quiet) {
495 std::cerr << "ERROR xAOD::ByteStreamAuxContainer_v1::getData (const) "
496 << "Variable with unknown name (" << name << ") requested"
497 << std::endl;
498 }
499 return nullptr;
500 }
501
502 if (m_locked && !forDecor)
503 throw SG::ExcStoreLocked ("getData");
504
505 if (r.isLinked(auxid)) {
506 std::cerr << "ERROR xAOD::ByteStreamAuxContainer_v1 doesn't implement linked variables"
507 << std::endl;
508 return nullptr;
509 }
510
511 // Create the variable.
512 itr = pers.insert (std::make_pair (name, std::vector<T>())).first;
513 }
514
515 // Get hold of the variable.
516 std::vector< T >& var = itr->second;
517
518 // Make sure that the internal vector is big enough:
519 if( m_dynamicVecs.size() <= auxid ) {
520 m_dynamicVecs.resize( auxid + 1 );
521 }
522
523 // Just an internal check...
524 if( m_dynamicVecs[ auxid ] ) {
525 std::cerr << "ERROR xAOD::ByteStreamAuxContainer_v1::getData "
526 << "Internal inconsistency detected!" << std::endl;
527 return m_dynamicVecs[ auxid ];
528 }
529
530 // Register the variable:
531 m_dynamicVecs[ auxid ] = new AuxPersVector< T >( auxid, var, false, nullptr );
532
533 if (capacity > 0) {
534 // Set it to the right size:
535 m_dynamicVecs[ auxid ]->reserve( capacity );
536 m_dynamicVecs[ auxid ]->resize( size );
537 }
538
539 // Remember that we are now handling this variable:
540 m_auxids.insert( auxid );
541
542 // Return the pointer to the array:
543 return m_dynamicVecs[ auxid ];
544 }
JetConstituentVector::iterator iterator

◆ getWritableAuxIDs()

const ByteStreamAuxContainer_v1::auxid_set_t & xAOD::ByteStreamAuxContainer_v1::getWritableAuxIDs ( ) const
overridevirtual

Return a set of writable data identifiers.

Implements SG::IAuxStore.

Definition at line 301 of file ByteStreamAuxContainer_v1.cxx.

301 {
302
303 return m_auxids;
304 }

◆ insertMove() [1/2]

virtual bool SG::IAuxStore::insertMove ( size_t pos,
IAuxStore & other,
const SG::auxid_set_t & ignore = SG::auxid_set_t() )
pure virtualinherited

Move all elements from other to this store.

Parameters
posThe starting index of the insertion.
otherStore from which to do the move.
ignoreSet of variables that should not be added to the store.

Let len be the size of other. The store will be increased in size by len elements, with the elements at pos being copied to pos+len. Then, for each auxiliary variable, the entire contents of that variable for other will be moved to this store at index pos. This will be done via move semantics if possible; otherwise, it will be done with a copy. Variables present in this store but not in other will have the corresponding elements default-initialized. Variables in other but not in this store will be added unless they are in ignore.

Returns true if it is known that none of the vectors' memory moved, false otherwise.

◆ insertMove() [2/2]

bool xAOD::ByteStreamAuxContainer_v1::insertMove ( size_t pos,
IAuxStore & other,
const SG::auxid_set_t & ignore )
overridevirtual

Insert contents of another store via move.

Definition at line 373 of file ByteStreamAuxContainer_v1.cxx.

375 {
376
377 guard_t guard( m_mutex );
378
379 // This operation is not allowed on a locked container:
380 if( m_locked ) {
381 throw SG::ExcStoreLocked( "insertMove" );
382 }
383
384 bool nomove = true;
385 size_t other_size = other.size();
386
387 SG::auxid_set_t ignore = ignore_in;
388
389 // Do the operation on the static variables:
390 for (SG::auxid_t id : m_auxids) {
391 SG::IAuxTypeVector* v_dst = nullptr;
392 if (id < m_dynamicVecs.size())
393 v_dst = m_dynamicVecs[id];
394 if (!v_dst && id < m_staticVecs.size())
395 v_dst = m_staticVecs[id];
396 if (v_dst) {
397 ignore.insert (id);
398 if (other.getData (id)) {
399 void* src_ptr = other.getData (id, other_size, other_size);
400 if (src_ptr) {
401 if (!v_dst->insertMove (pos, src_ptr, 0, other_size,
402 other))
403 nomove = false;
404 }
405 }
406 else {
407 const void* orig = v_dst->toPtr();
408 v_dst->shift (pos, other_size);
409 if (orig != v_dst->toPtr())
410 nomove = false;
411 }
412 }
413 }
414
415 // Add any new variables not present in the original container.
416 for (SG::auxid_t id : other.getAuxIDs()) {
417 if (!m_auxids.test(id) &&
418 !ignore.test(id))
419 {
420 if (other.getData (id)) {
421 void* src_ptr = other.getData (id, other_size, other_size);
422 if (src_ptr) {
423 size_t sz = size_noLock();
424 getVector1 (id, sz, sz, true, false);
425 m_dynamicVecs[id]->resize (sz - other_size);
426 (void)m_dynamicVecs[id]->insertMove (pos, src_ptr, 0, other_size,
427 other);
428 nomove = false;
429 }
430 }
431 }
432 }
433
434 return nomove;
435 }
static Double_t sz
virtual void * toPtr()=0
Return a pointer to the start of the vector's data.
virtual bool insertMove(size_t pos, void *src, size_t src_pos, size_t src_n, IAuxStore &srcStore)=0
Insert elements into the vector via move semantics.
virtual bool shift(size_t pos, ptrdiff_t offs)=0
Shift the elements of the vector.
size_t size_noLock() const
Internal method: return size without taking out the lock.
virtual bool insertMove(size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore) override
Insert contents of another store via move.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27

◆ isDecoration()

bool xAOD::ByteStreamAuxContainer_v1::isDecoration ( auxid_t auxid) const
overridevirtual

Test if a variable is a decoration.

Definition at line 192 of file ByteStreamAuxContainer_v1.cxx.

193 {
194 guard_t guard (m_mutex);
195 return m_locked && m_decorations.test (auxid);
196 }

◆ linkedVector()

virtual IAuxTypeVector * SG::IAuxStore::linkedVector ( SG::auxid_t )
inlinevirtualinherited

Reimplemented in xAOD::AuxContainerBase, xAOD::AuxInfoBase, and xAOD::details::AuxStoreBase.

Definition at line 203 of file IAuxStore.h.

204 { return nullptr; }

◆ lock()

void xAOD::ByteStreamAuxContainer_v1::lock ( )
overridevirtual

Lock the container.

Definition at line 199 of file ByteStreamAuxContainer_v1.cxx.

200 {
201 guard_t guard (m_mutex);
202 m_locked = true;
203 }

◆ lockDecoration()

void xAOD::ByteStreamAuxContainer_v1::lockDecoration ( SG::auxid_t auxid)
overridevirtual

Lock a decoration.

Definition at line 238 of file ByteStreamAuxContainer_v1.cxx.

239 {
240 guard_t guard (m_mutex);
241 m_decorations.reset (auxid);
242 }

◆ name()

const char * xAOD::ByteStreamAuxContainer_v1::name ( ) const

Get the name of the container instance.

Definition at line 460 of file ByteStreamAuxContainer_v1.cxx.

460 {
461
462 return m_name.c_str();
463 }

◆ operator=()

ByteStreamAuxContainer_v1 & xAOD::ByteStreamAuxContainer_v1::operator= ( const ByteStreamAuxContainer_v1 & rhs)

Assignment operator.

Definition at line 63 of file ByteStreamAuxContainer_v1.cxx.

64 {
65
66 if (this != &rhs) {
67 // Copy the persistent variables:
68 m_int = rhs.m_int;
69 m_float = rhs.m_float;
70 m_vecInt = rhs.m_vecInt;
71 m_vecFloat = rhs.m_vecFloat;
72
73 // Also copy the list of auxiliary IDs handled:
74 m_auxids = rhs.m_auxids;
75
76 // The static variables should be left alone. Those should still
77 // point to the correct places in memory. But the dynamic variables
78 // need to be cleared out. Those will be re-created when/if needed.
79 for( auto* ptr : m_dynamicVecs ) {
80 delete ptr;
81 }
82 m_dynamicVecs.clear();
83
84 // Copy the container's name:
85 m_name = rhs.m_name;
86 }
87
88 return *this;
89 }
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ regAuxVar()

template<typename T>
void xAOD::ByteStreamAuxContainer_v1::regAuxVar ( auxid_t auxid,
const std::string & name,
std::vector< T > & vec )

Register one of the user defined persistent variables internally.

◆ reserve()

void xAOD::ByteStreamAuxContainer_v1::reserve ( size_t size)
overridevirtual

Reserve a given size for the arrays.

Implements SG::IAuxStore.

Definition at line 331 of file ByteStreamAuxContainer_v1.cxx.

331 {
332
333 guard_t guard (m_mutex);
334
335 if (m_locked)
336 throw SG::ExcStoreLocked ("reserve");
337
338 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
339 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
340 for( ; itr != end; ++itr ) {
341 if( *itr ) ( *itr )->reserve( size );
342 }
343 itr = m_staticVecs.begin();
344 end = m_staticVecs.end();
345 for( ; itr != end; ++itr ) {
346 if( *itr ) ( *itr )->reserve( size );
347 }
348
349 return;
350 }

◆ reset()

void xAOD::ByteStreamAuxContainer_v1::reset ( )

Function resetting the internal (cached) state of the object.

Definition at line 438 of file ByteStreamAuxContainer_v1.cxx.

438 {
439
440 guard_t guard (m_mutex);
441
442 for (SG::IAuxTypeVector* p : m_dynamicVecs)
443 delete p;
444 m_dynamicVecs.clear();
445
446 SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
447#define ADD_IDS(VAR, TYP) \
448 do { typedef std::map< std::string, std::vector< TYP > > CONT; \
449 for (CONT::value_type& p : VAR) \
450 m_auxids.insert (r.getAuxID< TYP > (p.first, emptyStr, SG::AuxVarFlags::SkipNameCheck)); } while(0)
451 ADD_IDS(m_int, int);
452 ADD_IDS(m_float, float);
453 ADD_IDS(m_vecInt, std::vector<int>);
454 ADD_IDS(m_vecFloat, std::vector<float>);
455#undef ADD_IDS
456
457 return;
458 }
#define ADD_IDS(VAR, TYP)

◆ resize()

bool xAOD::ByteStreamAuxContainer_v1::resize ( size_t size)
overridevirtual

Resize the arrays to a given size.

Implements SG::IAuxStore.

Definition at line 306 of file ByteStreamAuxContainer_v1.cxx.

306 {
307
308 guard_t guard (m_mutex);
309
310 if (m_locked)
311 throw SG::ExcStoreLocked ("resize");
312
313 bool nomoves = true;
314 for (SG::IAuxTypeVector* v : m_dynamicVecs) {
315 if(v) {
316 if (!v->resize( size ))
317 nomoves = false;
318 }
319 }
320
321 for (SG::IAuxTypeVector* v : m_staticVecs) {
322 if(v) {
323 if (!v->resize( size ))
324 nomoves = false;
325 }
326 }
327
328 return nomoves;
329 }

◆ setName()

void xAOD::ByteStreamAuxContainer_v1::setName ( const char * name)

Set the name of the container instance.

Definition at line 465 of file ByteStreamAuxContainer_v1.cxx.

465 {
466
467 m_name = name;
468 return;
469 }

◆ setOption()

virtual bool SG::IAuxStore::setOption ( auxid_t ,
const AuxDataOption &  )
inlinevirtualinherited

Set an option for a given auxiliary variable.

Parameters
auxidThe identifier of the desired aux data item.
optionThe option to set.

The interpretation of the option depends on the particular representation of the variable.

Returns true if the option setting was successful; false otherwise.

Reimplemented in xAOD::AuxContainerBase, and xAOD::AuxInfoBase.

Definition at line 189 of file IAuxStore.h.

190 { return false; }

◆ shift()

void xAOD::ByteStreamAuxContainer_v1::shift ( size_t pos,
ptrdiff_t offs )
overridevirtual

Shift the contents of the stored arrays.

Implements SG::IAuxStore.

Definition at line 352 of file ByteStreamAuxContainer_v1.cxx.

352 {
353
354 guard_t guard (m_mutex);
355
356 if (m_locked)
357 throw SG::ExcStoreLocked ("shift");
358
359 std::vector< SG::IAuxTypeVector* >::iterator itr = m_dynamicVecs.begin();
360 std::vector< SG::IAuxTypeVector* >::iterator end = m_dynamicVecs.end();
361 for( ; itr != end; ++itr ) {
362 if( *itr ) ( *itr )->shift( pos, offs );
363 }
364 itr = m_staticVecs.begin();
365 end = m_staticVecs.end();
366 for( ; itr != end; ++itr ) {
367 if( *itr ) ( *itr )->shift( pos, offs );
368 }
369
370 return;
371 }

◆ size()

size_t xAOD::ByteStreamAuxContainer_v1::size ( ) const
overridevirtual

Get the size of the container.

Definition at line 263 of file ByteStreamAuxContainer_v1.cxx.

264 {
265 guard_t guard (m_mutex);
266 return size_noLock();
267 }

◆ size_noLock()

size_t xAOD::ByteStreamAuxContainer_v1::size_noLock ( ) const
private

Internal method: return size without taking out the lock.

Definition at line 245 of file ByteStreamAuxContainer_v1.cxx.

246 {
247 for (SG::auxid_t i : m_auxids) {
248 if (i < m_staticVecs.size() && m_staticVecs[i]) {
249 size_t sz = m_staticVecs[i]->size();
250 if (sz > 0)
251 return sz;
252 }
253 if (i < m_dynamicVecs.size() && m_dynamicVecs[i]) {
254 size_t sz = m_dynamicVecs[i]->size();
255 if (sz > 0)
256 return sz;
257 }
258 }
259
260 return 0;
261 }

◆ toTransient()

void xAOD::ByteStreamAuxContainer_v1::toTransient ( const EventContext & ctx)
overridevirtual

Perform post-read processing on this store.

Parameters
ctxThe current event context.

Implements SG::IAuxStore.

Definition at line 589 of file ByteStreamAuxContainer_v1.cxx.

590 {
591 guard_t guard (m_mutex);
592 for (SG::IAuxTypeVector* v : m_staticVecs) {
593 if(v) {
594 v->toTransient( ctx );
595 }
596 }
597 for (SG::IAuxTypeVector* v : m_dynamicVecs) {
598 if(v) {
599 v->toTransient( ctx );
600 }
601 }
602 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/6]

std::vector< SG::IAuxTypeVector* > m_dynamicVecs xAOD::ByteStreamAuxContainer_v1::ATLAS_THREAD_SAFE
mutableprivate

Internal list of dynamic managed variables.

Definition at line 193 of file ByteStreamAuxContainer_v1.h.

◆ ATLAS_THREAD_SAFE [2/6]

auxid_set_t m_auxids xAOD::ByteStreamAuxContainer_v1::ATLAS_THREAD_SAFE
mutableprivate

Internal list of auxiliary variables.

Definition at line 189 of file ByteStreamAuxContainer_v1.h.

◆ ATLAS_THREAD_SAFE [3/6]

std::map< std::string, std::vector< std::vector< float > > > m_vecFloat xAOD::ByteStreamAuxContainer_v1::ATLAS_THREAD_SAFE
mutableprivate

Variable holding vector of float auxiliary variables.

Definition at line 181 of file ByteStreamAuxContainer_v1.h.

◆ ATLAS_THREAD_SAFE [4/6]

std::map< std::string, std::vector< std::vector< int > > > m_vecInt xAOD::ByteStreamAuxContainer_v1::ATLAS_THREAD_SAFE
mutableprivate

Variable holding vector of integer auxiliary variables.

Definition at line 179 of file ByteStreamAuxContainer_v1.h.

◆ ATLAS_THREAD_SAFE [5/6]

std::map< std::string, std::vector< float > > m_float xAOD::ByteStreamAuxContainer_v1::ATLAS_THREAD_SAFE
mutableprivate

Variable holding float auxiliary variables.

Definition at line 177 of file ByteStreamAuxContainer_v1.h.

◆ ATLAS_THREAD_SAFE [6/6]

std::map< std::string, std::vector< int > > m_int xAOD::ByteStreamAuxContainer_v1::ATLAS_THREAD_SAFE
mutableprivate

Variable holding integer auxiliary variables.

Definition at line 175 of file ByteStreamAuxContainer_v1.h.

◆ m_decorations

SG::auxid_set_t xAOD::ByteStreamAuxContainer_v1::m_decorations
private

Record which variables are decorations.

Definition at line 197 of file ByteStreamAuxContainer_v1.h.

◆ m_locked

bool xAOD::ByteStreamAuxContainer_v1::m_locked
private

Has the container been locked?

Definition at line 195 of file ByteStreamAuxContainer_v1.h.

◆ m_mutex

mutex_t xAOD::ByteStreamAuxContainer_v1::m_mutex
mutableprivate

Definition at line 202 of file ByteStreamAuxContainer_v1.h.

◆ m_name

std::string xAOD::ByteStreamAuxContainer_v1::m_name
private

Name of the container in memory. Set externally.

Definition at line 207 of file ByteStreamAuxContainer_v1.h.

◆ m_staticVecs

std::vector< SG::IAuxTypeVector* > xAOD::ByteStreamAuxContainer_v1::m_staticVecs
private

Internal list of static managed variables.

Definition at line 191 of file ByteStreamAuxContainer_v1.h.

◆ supportsThinning

bool SG::IAuxStore::supportsThinning = true
staticconstexprinherited

Mark that this type supports thinning operations.

See AthContainers/supportsThinning.h and AthenaPoolCnvSvc/T_AthenaPoolCnv.h. Helps guide which pool converter template will be used. If false, the default pool converter will be used rather than the aux store-specific one. Ordinary xAOD type should not touch this, but may be overridden in a derived class to handle certain special cases.

Definition at line 216 of file IAuxStore.h.


The documentation for this class was generated from the following files: