ATLAS Offline Software
Loading...
Searching...
No Matches
RootAuxDynStore Class Referenceabstract

#include <RootAuxDynStore.h>

Inheritance diagram for RootAuxDynStore:
Collaboration diagram for RootAuxDynStore:

Public Member Functions

 RootAuxDynStore (RootAuxDynReader &reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
virtual ~RootAuxDynStore ()
virtual const void * getData (SG::auxid_t auxid) const override
 implementation of the IAuxStore interface
virtual const SG::IAuxTypeVectorgetVector (SG::auxid_t auxid) const override
 Return vector interface for one aux data item.
virtual void * getData (SG::auxid_t auxid, size_t size, size_t capacity) override
 Return the data vector for one aux data item.
virtual const void * getIOData (SG::auxid_t auxid) const override
 implementation of the IAuxStoreIO interface
virtual void * getDecoration (SG::auxid_t auxid, size_t size, size_t capacity) override
 Return the data vector for one aux data decoration item.
virtual bool isDecoration (SG::auxid_t auxid) const override
 Test if a particular variable is tagged as a decoration.
virtual size_t size () const override
 Return the number of elements in the store.
bool standalone () const
 Return the standalone flag.
virtual bool resize (size_t sz) override
 Change the size of all aux data vectors.
virtual void reserve (size_t sz) override
 Change the capacity of all aux data vectors.
virtual void shift (size_t pos, ptrdiff_t offs) override
 Shift the elements of the container.
virtual bool insertMove (size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore=SG::auxid_set_t(0)) override
 Move all elements from other to this store.
virtual const SG::auxid_set_tgetAuxIDs () const override
 Return a set of identifiers for existing data items in this store.
virtual const SG::auxid_set_tgetDecorIDs () const override
 Return a set of identifiers for decorations in this store.
virtual const SG::auxid_set_tgetWritableAuxIDs () const override
 Return a set of identifiers for writable data items in this store.
virtual const std::type_info * getIOType (SG::auxid_t auxid) const override
 Return the type of the data to be stored for one aux data item.
virtual const SG::auxid_set_tgetDynamicAuxIDs () const override
 Get the list of all variables that need to be handled.
virtual void lock () override
 Lock the container.
virtual bool clearDecorations () override
 Clear all decorations.
virtual bool setOption (auxid_t id, const AuxDataOption &option) override
 Set an option for an auxiliary data variable.
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration.
virtual IAuxTypeVector * linkedVector (SG::auxid_t auxid) override
 Return interface for a linked variable.
virtual const IAuxTypeVector * linkedVector (SG::auxid_t auxid) const override
 Return interface for a linked variable.
virtual SG::auxid_set_t getSelectedAuxIDs () const
 Get a list of dynamic variables that need to be written out.

Static Public Attributes

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

Protected Types

typedef AthContainers_detail::mutex mutex_t
 Mutex used to synchronize modifications to the cache vector.
typedef AthContainers_detail::lock_guard< mutex_tguard_t

Protected Member Functions

virtual bool readData (SG::auxid_t auxid)=0
 read data from ROOT and store it in m_vecs. Returns False on error
const void * getIODataInternal (auxid_t auxid, bool quiet) const
 Return a pointer to the data to be stored for one aux data item.
void * getIODataInternal (auxid_t auxid, bool quiet)
 Return a pointer to the data to be stored for one aux data item.
void addAuxID (auxid_t auxid)
 Add a new auxid to the set of those being managed by this store.
virtual void * getDataInternal (SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check)
 Return the data vector for one aux data item.
void addVector (std::unique_ptr< IAuxTypeVector > vec, bool isDecoration)
 Explicitly add a vector to the store.

Protected Attributes

long long m_entry
mutex_t m_mutex
std::recursive_mutex * m_iomutex
 Optional mutex used to serialize I/O with RootStorageSvc (not owned)

Private Member Functions

virtual IAuxTypeVector * getVectorInternal_noLock (SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check)
 Implementation of getVectorInternal; no locking.
size_t size_noLock () const
 Return the number of elements in the store; no locking.

Private Attributes

bool m_standalone
 Are we being written in standalone mode?
std::vector< std::unique_ptr< IAuxTypeVector > > m_vecs
 The collection of vectors of aux data that we're managing, indexed by auxid.
SG::auxid_set_t m_decorations
 Record which variables are decorations.
SG::auxid_set_t m_auxids
 Set of auxid's for which we've created a vector.
bool m_locked
 Has this container been locked?

Detailed Description

Definition at line 16 of file RootAuxDynStore.h.

Member Typedef Documentation

◆ guard_t

◆ mutex_t

Mutex used to synchronize modifications to the cache vector.

Definition at line 66 of file RootAuxDynStore.h.

Constructor & Destructor Documentation

◆ RootAuxDynStore()

RootAuxDynStore::RootAuxDynStore ( RootAuxDynReader & reader,
long long entry,
bool standalone,
std::recursive_mutex * iomtx = nullptr )

Definition at line 12 of file RootAuxDynStore.cxx.

14 : SG::AuxStoreInternal( standalone ),
15 m_entry(entry),
16 m_iomutex(iomtx)
17{
18 for( auto id : reader.auxIDs() ) {
19 addAuxID(id);
20 }
21 lock();
22}
std::recursive_mutex * m_iomutex
Optional mutex used to serialize I/O with RootStorageSvc (not owned)
bool standalone() const
Return the standalone flag.
virtual void lock() override
Lock the container.
void addAuxID(auxid_t auxid)
Add a new auxid to the set of those being managed by this store.
reader
read the goodrunslist xml file(s)
Definition collisions.py:22

◆ ~RootAuxDynStore()

virtual RootAuxDynStore::~RootAuxDynStore ( )
inlinevirtual

Definition at line 22 of file RootAuxDynStore.h.

22{}

Member Function Documentation

◆ addAuxID()

void SG::AuxStoreInternal::addAuxID ( auxid_t auxid)
protectedinherited

Add a new auxid to the set of those being managed by this store.

Parameters
auxidThe auxid to add.

Definition at line 690 of file AuxStoreInternal.cxx.

691{
692 m_auxids.insert (auxid);
693}
SG::auxid_set_t m_auxids
Set of auxid's for which we've created a vector.

◆ addVector()

void SG::AuxStoreInternal::addVector ( std::unique_ptr< IAuxTypeVector > vec,
bool isDecoration )
protectedinherited

Explicitly add a vector to the store.

Parameters
vecVector data being added.
isDecorationShould this variable be marked as a decoration?

For internal use. The auxid must not already exist in the store.

Definition at line 146 of file AuxStoreInternal.cxx.

148{
149 guard_t guard (m_mutex);
150 auxid_t auxid = vec->auxid();
151 if (m_locked)
152 throw ExcStoreLocked (auxid);
153
154 // Resize the vector if needed.
155 if (m_vecs.size() <= auxid) {
156 m_vecs.resize (auxid+1);
157 }
158
159 // Give up if the variable is already present in the store.
160 if (m_vecs[auxid]) std::abort();
161
162 // Make sure the length is consistent with the rest of the store.
163 if (!vec->isLinked()) {
164 size_t sz = this->size_noLock();
165 if (vec->size() < sz)
166 vec->resize (sz);
167 }
168
169 // Add it to the store.
170 m_vecs[auxid] = std::move (vec);
171
172 // Need to be sure that the addition to the decoration bitset is visible
173 // to other threads before the addition to the variable bitset.
174 if (isDecoration) {
175 m_decorations.insert (auxid);
176 std::atomic_thread_fence (std::memory_order_seq_cst);
177 }
178 addAuxID (auxid);
179}
std::vector< size_t > vec
static Double_t sz
bool m_locked
Has this container been locked?
std::vector< std::unique_ptr< IAuxTypeVector > > m_vecs
The collection of vectors of aux data that we're managing, indexed by auxid.
SG::auxid_set_t m_decorations
Record which variables are decorations.
virtual bool isDecoration(auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
size_t size_noLock() const
Return the number of elements in the store; no locking.
AthContainers_detail::lock_guard< mutex_t > guard_t
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27

◆ clearDecorations()

bool SG::AuxStoreInternal::clearDecorations ( )
overridevirtualinherited

Clear all decorations.

Erase all decorations from the store, restoring the state to when lock was called. Be sure to clear the cache of the referencing container!

Returns true if there were any decorations that were cleared, false if the store did not contain any decorations.

Implements SG::IConstAuxStore.

Definition at line 595 of file AuxStoreInternal.cxx.

596{
597 guard_t guard (m_mutex);
598 bool anycleared = false;
599 for (auxid_t id : m_decorations) {
600 m_vecs[id].reset();
601 m_auxids.erase (id);
602 anycleared = true;
603 }
604 if (anycleared) {
605 m_decorations.clear();
606 }
607 return anycleared;
608}

◆ getAuxIDs()

const SG::auxid_set_t & SG::AuxStoreInternal::getAuxIDs ( ) const
overridevirtualinherited

Return a set of identifiers for existing data items in this store.

This should include identifiers for all items, const and non-const.

Implements SG::IConstAuxStore.

Definition at line 414 of file AuxStoreInternal.cxx.

415{
416 return m_auxids;
417}

◆ getData() [1/2]

const void * RootAuxDynStore::getData ( SG::auxid_t auxid) const
overridevirtual

implementation of the IAuxStore interface

Reimplemented from SG::AuxStoreInternal.

Definition at line 25 of file RootAuxDynStore.cxx.

26{
27 const SG::IAuxTypeVector* v = getVector( auxid );
28 if( v ) {
29 return v->toPtr();
30 }
31 return nullptr;
32}
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.

◆ getData() [2/2]

void * RootAuxDynStore::getData ( SG::auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Return the data vector for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.
sizeThe current size of the container (in case the data item does not already exist).
capacityThe current capacity of the container (in case the data item does not already exist).

Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.

If the data item does not exist, it should be created and initialized to default values. size and capacity give the size for the new aux data item vector.

Reimplemented from SG::AuxStoreInternal.

Definition at line 50 of file RootAuxDynStore.cxx.

51{
52 // MN: how do we add new attributes to this store? A:for now we don't
53 throw("Non-const access to RootAuxDynStore is not supported");
54}

◆ getDataInternal()

void * SG::AuxStoreInternal::getDataInternal ( SG::auxid_t auxid,
size_t size,
size_t capacity,
bool no_lock_check )
protectedvirtualinherited

Return the data vector for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.
sizeThe current size of the container (in case the data item does not already exist).
capacityThe current capacity of the container (in case the data item does not already exist).
no_lock_checkIf true, then skip the test for a locked container.

Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.

If the data item does not exist, it should be created and initialized to default values. size and capacity give the size for the new aux data item vector.

Definition at line 749 of file AuxStoreInternal.cxx.

753{
754 guard_t guard (m_mutex);
755 return getVectorInternal_noLock (auxid, size, capacity, no_lock_check)->toPtr();
756}
virtual IAuxTypeVector * getVectorInternal_noLock(SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check)
Implementation of getVectorInternal; no locking.
virtual size_t size() const override
Return the number of elements in the store.
virtual void * toPtr()=0
Return a pointer to the start of the vector's data.

◆ getDecoration()

void * RootAuxDynStore::getDecoration ( SG::auxid_t auxid,
size_t size,
size_t capacity )
overridevirtual

Return the data vector for one aux data decoration item.

Parameters
auxidThe identifier of the desired aux data item.
sizeThe current size of the container (in case the data item does not already exist).
capacityThe current capacity of the container (in case the data item does not already exist).
auxidThe identifier of the desired aux data item.
sizeThe current size of the container (in case the data item does not already exist).
capacityThe current capacity of the container (in case the data item does not already exist).

Each aux data item is stored as a vector, with one entry per entry in the owning container. This returns a pointer to the start of the vector.

The base class implementation works except for the case where we have not yet created a vector for an item in the root file. We need to detect that case and raise an exception.

Reimplemented from SG::AuxStoreInternal.

Definition at line 87 of file RootAuxDynStore.cxx.

88{
89 guard_t guard (m_mutex);
90 if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
92 {
93 throw SG::ExcStoreLocked (auxid);
94 }
95 return SG::AuxStoreInternal::getDecoration (auxid, size, capacity);
96}
AthContainers_detail::lock_guard< mutex_t > guard_t
virtual size_t size() const override
Return the number of elements in the store.
const void * getIODataInternal(auxid_t auxid, bool quiet) const
Return a pointer to the data to be stored for one aux data item.
virtual const SG::auxid_set_t & getAuxIDs() const override
Return a set of identifiers for existing data items in this store.
virtual void * getDecoration(auxid_t auxid, size_t size, size_t capacity) override
Return the data vector for one aux data decoration item.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ getDecorIDs()

const SG::auxid_set_t & SG::AuxStoreInternal::getDecorIDs ( ) const
overridevirtualinherited

Return a set of identifiers for decorations in this store.

Implements SG::IConstAuxStore.

Definition at line 424 of file AuxStoreInternal.cxx.

425{
426 return m_decorations;
427}

◆ getDynamicAuxIDs()

const SG::auxid_set_t & SG::AuxStoreInternal::getDynamicAuxIDs ( ) const
overridevirtualinherited

Get the list of all variables that need to be handled.

Implements SG::IAuxStoreIO.

Definition at line 566 of file AuxStoreInternal.cxx.

567{
568 return getAuxIDs();
569}

◆ getIOData()

const void * RootAuxDynStore::getIOData ( SG::auxid_t auxid) const
overridevirtual

implementation of the IAuxStoreIO interface

Reimplemented from SG::AuxStoreInternal.

Definition at line 57 of file RootAuxDynStore.cxx.

58{
59 guard_t guard (m_mutex);
60 const void* ret = SG::AuxStoreInternal::getIODataInternal (auxid, true);
61 if (!ret) {
62 auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
63 if( this_nc->readData(auxid) ) {
65 }
66 }
67 return ret;
68}
#define ATLAS_THREAD_SAFE
RootAuxDynStore(RootAuxDynReader &reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
virtual const void * getIOData(SG::auxid_t auxid) const override
Return a pointer to the data to be stored for one aux data item.

◆ getIODataInternal() [1/2]

void * SG::AuxStoreInternal::getIODataInternal ( auxid_t auxid,
bool quiet )
protectedinherited

Return a pointer to the data to be stored for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.
quietIf true, then don't print an error on failure.

This will usually be a pointer to a std::vector; however, it may be something different for a standalone object.

Returns 0 and reports an error if the requested aux data item does not exist.

Definition at line 497 of file AuxStoreInternal.cxx.

498{
499 guard_t guard (m_mutex);
500 if (auxid >= m_vecs.size() || !m_vecs[auxid]) {
501 if (!quiet) {
502 std::ostringstream ss;
503 ss << "Requested variable "
505 << " (" << auxid << ") doesn't exist";
506 ATHCONTAINERS_ERROR("AuxStoreInternal::getIODataInternal", ss.str());
507 }
508 return 0;
509 }
510
511 if (m_standalone) {
512 if (!SG::AuxTypeRegistry::instance().isLinked (auxid))
513 return m_vecs[auxid]->toPtr();
514 }
515 return m_vecs[auxid]->toVector();
516}
static Double_t ss
bool m_standalone
Are we being written in standalone mode?
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
#define ATHCONTAINERS_ERROR(ctx, msg)
Definition error.h:54

◆ getIODataInternal() [2/2]

const void * SG::AuxStoreInternal::getIODataInternal ( auxid_t auxid,
bool quiet ) const
protectedinherited

Return a pointer to the data to be stored for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.
quietIf true, then don't print an error on failure.

This will usually be a pointer to a std::vector; however, it may be something different for a standalone object.

Returns 0 and reports an error if the requested aux data item does not exist.

Definition at line 464 of file AuxStoreInternal.cxx.

465{
466 guard_t guard (m_mutex);
467 if (auxid >= m_vecs.size() || !m_vecs[auxid]) {
468 if (!quiet) {
469 std::ostringstream ss;
470 ss << "Requested variable "
472 << " (" << auxid << ") doesn't exist";
473 ATHCONTAINERS_ERROR("AuxStoreInternal::getIODataInternal", ss.str());
474 }
475 return 0;
476 }
477
478 if (m_standalone) {
479 if (!SG::AuxTypeRegistry::instance().isLinked (auxid))
480 return m_vecs[auxid]->toPtr();
481 }
482 return m_vecs[auxid]->toVector();
483}

◆ getIOType()

const std::type_info * SG::AuxStoreInternal::getIOType ( SG::auxid_t auxid) const
overridevirtualinherited

Return the type of the data to be stored for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.

For an aux data item of type T, this will usually be std::vector<T>. For standalone objects, however, it will usually be T; and std::vector<char> will be used instead of std::vector<bool>.

Returns 0 if the requested aux data item does not exist.

Implements SG::IAuxStoreIO.

Definition at line 546 of file AuxStoreInternal.cxx.

547{
548 if (m_standalone) {
549 const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
550 if (!r.isLinked (auxid))
551 return r.getType (auxid);
552 }
553 guard_t guard (m_mutex);
554 if (auxid < m_vecs.size() && m_vecs[auxid]) {
555 const std::type_info* ret = m_vecs[auxid]->objType();
556 if (ret) return ret;
557 }
559}
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
int r
Definition globals.cxx:22

◆ getSelectedAuxIDs()

virtual SG::auxid_set_t SG::IAuxStoreIO::getSelectedAuxIDs ( ) const
inlinevirtualinherited

Get a list of dynamic variables that need to be written out.

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

Definition at line 86 of file IAuxStoreIO.h.

86 {
87 // default all are selected
88 return getDynamicAuxIDs();
89 }
virtual const SG::auxid_set_t & getDynamicAuxIDs() const =0
Get the list of all dynamically created variables.

◆ getVector()

const SG::IAuxTypeVector * RootAuxDynStore::getVector ( SG::auxid_t auxid) const
overridevirtual

Return vector interface for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.

This should return nullptr if the item doesn't exist.

Reimplemented from SG::AuxStoreInternal.

Definition at line 35 of file RootAuxDynStore.cxx.

36{
37 guard_t guard (m_mutex);
38 // lock
39 const SG::IAuxTypeVector* ret = SG::AuxStoreInternal::getVector (auxid);
40 if (!ret) {
41 auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
42 if( this_nc->readData(auxid) ) {
44 }
45 }
46 return ret;
47}
virtual const IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.

◆ getVectorInternal_noLock()

IAuxTypeVector * SG::AuxStoreInternal::getVectorInternal_noLock ( SG::auxid_t auxid,
size_t size,
size_t capacity,
bool no_lock_check )
privatevirtualinherited

Implementation of getVectorInternal; no locking.

Definition at line 698 of file AuxStoreInternal.cxx.

702{
703 if (m_vecs.size() <= auxid) {
704 m_vecs.resize (auxid+1);
705 }
706 if (m_vecs[auxid] == 0) {
707 if (m_locked && !no_lock_check)
708 throw ExcStoreLocked (auxid);
709 const AuxTypeRegistry& r = AuxTypeRegistry::instance();
710 m_vecs[auxid] = r.makeVector (auxid, size, capacity);
711 addAuxID (auxid);
712 std::unique_ptr<IAuxTypeVector> linked = m_vecs[auxid]->linkedVector();
713 if (linked) {
714 auxid_t linked_id = linked->auxid();
715 m_vecs[linked_id] = std::move (linked);
716 addAuxID (linked_id);
717 }
718 }
719 else {
720 // Make sure the vector has at least the requested size.
721 // One way in which it could be short: setOption was called and created
722 // a variable in a store that had no other variables.
723 if (m_vecs[auxid]->size() < size) {
724 m_vecs[auxid]->resize (size);
725 m_vecs[auxid]->reserve (capacity);
726 }
727 }
728 return m_vecs[auxid].get();
729}

◆ getWritableAuxIDs()

const SG::auxid_set_t & SG::AuxStoreInternal::getWritableAuxIDs ( ) const
overridevirtualinherited

Return a set of identifiers for writable data items in this store.

This should include only non-const identifiers.

Implements SG::IAuxStore.

Definition at line 447 of file AuxStoreInternal.cxx.

448{
449 return getAuxIDs();
450}

◆ insertMove()

bool SG::AuxStoreInternal::insertMove ( size_t pos,
IAuxStore & other,
const SG::auxid_set_t & ignore = SG::auxid_set_t(0) )
overridevirtualinherited

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.

Implements SG::IAuxStore.

Definition at line 346 of file AuxStoreInternal.cxx.

349{
350 guard_t guard (m_mutex);
351 const AuxTypeRegistry& r = AuxTypeRegistry::instance();
352
353 if (m_locked)
354 throw ExcStoreLocked ("insertMove");
355 bool nomove = true;
356 size_t other_size = other.size();
357 if (other_size == 0)
358 return true;
359 for (SG::auxid_t id : m_auxids) {
360 SG::IAuxTypeVector* v_dst = nullptr;
361 if (id < m_vecs.size())
362 v_dst = m_vecs[id].get();
363 // Skip linked vars --- they should be taken care of by the parent var.
364 if (v_dst && !v_dst->isLinked()) {
365 if (other.getData (id)) {
366 void* src_ptr = other.getData (id, other_size, other_size);
367 if (src_ptr) {
368 if (!v_dst->insertMove (pos, src_ptr, 0, other_size,
369 other))
370 nomove = false;
371 }
372 }
373 else {
374 const void* orig = v_dst->toPtr();
375 v_dst->shift (pos, other_size);
376 if (orig != v_dst->toPtr())
377 nomove = false;
378 }
379 }
380 }
381
382 // Add any new variables not present in the original container.
383 for (SG::auxid_t id : other.getAuxIDs()) {
384 if (!m_auxids.test(id) && !ignore.test(id))
385 {
386 if (r.isLinked (id)) continue;
387 if (other.getData (id)) {
388 void* src_ptr = other.getData (id, other_size, other_size);
389 if (src_ptr) {
390 size_t sz = size_noLock();
391 if (sz < other_size) sz = other_size + pos;
392 IAuxTypeVector* v = getVectorInternal_noLock (id, sz, sz, false);
393 v->resize (sz - other_size);
394 (void)v->insertMove (pos, src_ptr, 0, other_size,
395 other);
396 nomove = false;
397 }
398 }
399 }
400 }
401
402 return nomove;
403}
bool isLinked() const
Return true if this variable is linked from another one.
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.

◆ isDecoration()

bool RootAuxDynStore::isDecoration ( SG::auxid_t auxid) const
overridevirtual

Test if a particular variable is tagged as a decoration.

Parameters
auxidThe identifier of the desired aux data item.
auxidThe identifier of the desired aux data item.

See getDecoration() above.

Reimplemented from SG::AuxStoreInternal.

Definition at line 105 of file RootAuxDynStore.cxx.

106{
107 guard_t guard( m_mutex );
108 if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
110 {
111 return false;
112 }
114}

◆ linkedVector() [1/2]

const IAuxTypeVector * SG::AuxStoreInternal::linkedVector ( SG::auxid_t auxid) const
overridevirtualinherited

Return interface for a linked variable.

Parameters
auxidThe ID of the parent variable.

If auxid has a linked variable, then return the IAuxTypeVector describing it. Otherwise, return nullptr. May return nullptr unconditionally if this store does not support linked variables.

Reimplemented from SG::IConstAuxStore.

Definition at line 803 of file AuxStoreInternal.cxx.

804{
805 const AuxTypeRegistry& r = AuxTypeRegistry::instance();
806 auxid_t linked_id = r.linkedVariable (auxid);
807 guard_t guard (m_mutex);
808 if (linked_id < m_vecs.size())
809 return m_vecs[linked_id].get();
810 return nullptr;
811}

◆ linkedVector() [2/2]

IAuxTypeVector * SG::AuxStoreInternal::linkedVector ( SG::auxid_t auxid)
overridevirtualinherited

Return interface for a linked variable.

Parameters
auxidThe ID of the parent variable.

If auxid has a linked variable, then return the IAuxTypeVector describing it. Otherwise, return nullptr. May return nullptr unconditionally if this store does not support linked variables.

Reimplemented from SG::IAuxStore.

Definition at line 783 of file AuxStoreInternal.cxx.

784{
785 const AuxTypeRegistry& r = AuxTypeRegistry::instance();
786 auxid_t linked_id = r.linkedVariable (auxid);
787 guard_t guard (m_mutex);
788 if (linked_id < m_vecs.size())
789 return m_vecs[linked_id].get();
790 return nullptr;
791}

◆ lock()

void SG::AuxStoreInternal::lock ( )
overridevirtualinherited

Lock the container.

After this, only decorations can be changed/modified. If the container is already locked, this is a no-op.

Implements SG::IConstAuxStore.

Definition at line 578 of file AuxStoreInternal.cxx.

579{
580 guard_t guard (m_mutex);
581 m_locked = true;
582}

◆ lockDecoration()

void SG::AuxStoreInternal::lockDecoration ( SG::auxid_t auxid)
overridevirtualinherited

Lock a decoration.

Parameters
auxidIdentifier of the decoration to lock.

A decoration is locked by changing from a decoration to an ordinary variable. If the container itself is locked, then modifications to the variable are not permitted after this call.

Implements SG::IConstAuxStore.

Definition at line 767 of file AuxStoreInternal.cxx.

768{
769 guard_t guard (m_mutex);
770 m_decorations.reset (auxid);
771}

◆ readData()

virtual bool RootAuxDynStore::readData ( SG::auxid_t auxid)
protectedpure virtual

read data from ROOT and store it in m_vecs. Returns False on error

Implemented in RNTupleAuxDynStore, and TBranchAuxDynStore.

◆ reserve()

void SG::AuxStoreInternal::reserve ( size_t sz)
overridevirtualinherited

Change the capacity of all aux data vectors.

Parameters
szThe new capacity.

This should be called when the capacity of the container changes (by reserve). This should change the capacity for the vectors for all aux data items.

Implements SG::IAuxStore.

Definition at line 281 of file AuxStoreInternal.cxx.

282{
283 guard_t guard (m_mutex);
284 if (m_locked)
285 throw ExcStoreLocked ("reserve");
286 for (std::unique_ptr<IAuxTypeVector>& v : m_vecs) {
287 if (v && !v->isLinked())
288 v->reserve (sz);
289 }
290}

◆ resize()

bool SG::AuxStoreInternal::resize ( size_t sz)
overridevirtualinherited

Change the size of all aux data vectors.

Parameters
szThe new size.

This should be called when the size of the container changes. This should resize the vectors for all aux data items.

If the size of the container grows, the new elements should be default-initialized; if it shrinks, destructors should be run as appropriate.

Should return true if it is known that none of the data pointers changed (and thus the cache does not need to be cleared), false otherwise.

Implements SG::IAuxStore.

Definition at line 254 of file AuxStoreInternal.cxx.

255{
256 guard_t guard (m_mutex);
257 if (m_locked)
258 throw ExcStoreLocked ("resize");
259 bool nomoves = true;
260 for (SG::auxid_t id : m_auxids) {
261 SG::IAuxTypeVector* v = nullptr;
262 if (id < m_vecs.size())
263 v = m_vecs[id].get();
264 if (v && !v->isLinked()) {
265 if (!v->resize (sz))
266 nomoves = false;
267 }
268 }
269 return nomoves;
270}

◆ setOption()

bool SG::AuxStoreInternal::setOption ( auxid_t id,
const AuxDataOption & option )
overridevirtualinherited

Set an option for an auxiliary data variable.

Parameters
idThe variable for which we want to set the option.
optionThe option setting to make.

The interpretation of option depends on the associated auxiliary store. See PackedParameters.h for option settings for writing packed data. Returns true on success, false otherwise.

Reimplemented from SG::IAuxStore.

Definition at line 650 of file AuxStoreInternal.cxx.

651{
652 // Does this variable exist in this store?
653 bool exists = false;
654 {
655 guard_t guard (m_mutex);
656 if (id < m_vecs.size() && m_vecs[id] != 0)
657 exists = true;
658 }
659
660 // If not, and we have a packing parameter request, then create the variable.
661 if (!exists) {
662 if (!PackedParameters::isValidOption (option)) return false;
663 size_t sz = size();
664 getDataInternal (id, sz, sz, true);
665 }
666
667 // Try the option setting.
668 guard_t guard (m_mutex);
669 if (m_vecs[id]->setOption (option)) return true;
670
671 // It didn't work. If this is a packing request, then try to convert
672 // the variable to packed form and retry.
673 if (!PackedParameters::isValidOption (option)) return false;
674 std::unique_ptr<IAuxTypeVector> packed = m_vecs[id]->toPacked();
675 if (packed) {
676 // Converted to packed form. Replace the object and retry.
677 m_vecs[id] = std::move (packed);
678 return m_vecs[id]->setOption (option);
679 }
680
681 // Didn't work.
682 return false;
683}
virtual void * getDataInternal(SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check)
Return the data vector for one aux data item.
virtual bool setOption(auxid_t id, const AuxDataOption &option) override
Set an option for an auxiliary data variable.
static bool isValidOption(const AuxDataOption &option)
Test to see if option is a recognized packing option.
bool exists(const std::string &filename)
does a file exist
H5::CompType packed(H5::CompType in)
Definition common.cxx:16

◆ shift()

void SG::AuxStoreInternal::shift ( size_t pos,
ptrdiff_t offs )
overridevirtualinherited

Shift the elements of the container.

Parameters
posThe starting index for the shift.
offsThe (signed) amount of the shift.

This operation shifts the elements in the vectors for all aux data items, to implement an insertion or deletion. offs may be either positive or negative.

If offs is positive, then the container is growing. The container size should be increased by offs, the element at pos moved to pos + offs, and similarly for following elements. The elements between pos and pos + offs should be default-initialized.

If offs is negative, then the container is shrinking. The element at pos should be moved to pos + offs, and similarly for following elements. The container should then be shrunk by -offs elements (running destructors as appropriate).

Implements SG::IAuxStore.

Definition at line 315 of file AuxStoreInternal.cxx.

316{
317 guard_t guard (m_mutex);
318 if (m_locked)
319 throw ExcStoreLocked ("shift");
320 for (std::unique_ptr<IAuxTypeVector>& v : m_vecs) {
321 if (v && !v->isLinked())
322 v->shift (pos, offs);
323 }
324}

◆ size()

size_t RootAuxDynStore::size ( ) const
overridevirtual

Return the number of elements in the store.

May return 0 for a store with no aux data.

NOTE: this method will attempt to read data if size unknown (0) May return 0 for a store with no aux data.

Reimplemented from SG::AuxStoreInternal.

Definition at line 121 of file RootAuxDynStore.cxx.

122{
123 const std::size_t s = SG::AuxStoreInternal::size();
124 if( s != 0 ) {
125 return s;
126 }
127
128 for( SG::auxid_t id : getAuxIDs() ) {
129 if( getData( id ) != nullptr ) {
131 }
132 }
133
134 return 0;
135}
virtual const void * getData(SG::auxid_t auxid) const override
implementation of the IAuxStore interface

◆ size_noLock()

size_t SG::AuxStoreInternal::size_noLock ( ) const
privateinherited

Return the number of elements in the store; no locking.

Return the number of elements in the store.

(No locking.)

May return 0 for a store with no aux data.

Definition at line 628 of file AuxStoreInternal.cxx.

629{
630 for (SG::auxid_t id : m_auxids) {
631 if (id < m_vecs.size() && m_vecs[id] && !m_vecs[id]->isLinked() &&
632 m_vecs[id]->size() > 0)
633 {
634 return m_vecs[id]->size();
635 }
636 }
637 return 0;
638}

◆ standalone()

bool SG::AuxStoreInternal::standalone ( ) const
inherited

Return the standalone flag.

Definition at line 69 of file AuxStoreInternal.cxx.

70{
71 return m_standalone;
72}

Member Data Documentation

◆ m_auxids

SG::auxid_set_t SG::AuxStoreInternal::m_auxids
privateinherited

Set of auxid's for which we've created a vector.

Definition at line 454 of file AuxStoreInternal.h.

◆ m_decorations

SG::auxid_set_t SG::AuxStoreInternal::m_decorations
privateinherited

Record which variables are decorations.

Definition at line 451 of file AuxStoreInternal.h.

◆ m_entry

long long RootAuxDynStore::m_entry
protected

Definition at line 63 of file RootAuxDynStore.h.

◆ m_iomutex

std::recursive_mutex* RootAuxDynStore::m_iomutex
protected

Optional mutex used to serialize I/O with RootStorageSvc (not owned)

Definition at line 71 of file RootAuxDynStore.h.

◆ m_locked

bool SG::AuxStoreInternal::m_locked
privateinherited

Has this container been locked?

Definition at line 457 of file AuxStoreInternal.h.

◆ m_mutex

mutex_t RootAuxDynStore::m_mutex
mutableprotected

Definition at line 68 of file RootAuxDynStore.h.

◆ m_standalone

bool SG::AuxStoreInternal::m_standalone
privateinherited

Are we being written in standalone mode?

Definition at line 444 of file AuxStoreInternal.h.

◆ m_vecs

std::vector<std::unique_ptr<IAuxTypeVector> > SG::AuxStoreInternal::m_vecs
privateinherited

The collection of vectors of aux data that we're managing, indexed by auxid.

Definition at line 448 of file AuxStoreInternal.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 199 of file IAuxStore.h.


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