ATLAS Offline Software
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SG::AuxStoreInternal Class Reference

An auxiliary data store that holds data internally. More...

#include <AuxStoreInternal.h>

Inheritance diagram for SG::AuxStoreInternal:
Collaboration diagram for SG::AuxStoreInternal:

Public Member Functions

 AuxStoreInternal (bool standalone=false)
 Constructor. More...
 
virtual ~AuxStoreInternal ()
 Destructor. More...
 
 AuxStoreInternal (const AuxStoreInternal &orig)
 Copy constructor. More...
 
AuxStoreInternaloperator= (const AuxStoreInternal &)=delete
 Don't allow assignment. More...
 
bool standalone () const
 Return the standalone flag. More...
 
virtual const void * getData (SG::auxid_t auxid) const override
 Return the data vector for one aux data item. More...
 
virtual const IAuxTypeVectorgetVector (SG::auxid_t auxid) const override
 Return vector interface for one aux data item. More...
 
virtual void * getData (SG::auxid_t auxid, size_t size, size_t capacity) override
 Return the data vector for one aux data item. More...
 
virtual void * getDecoration (auxid_t auxid, size_t size, size_t capacity) override
 Return the data vector for one aux data decoration item. More...
 
virtual bool resize (size_t sz) override
 Change the size of all aux data vectors. More...
 
virtual void reserve (size_t sz) override
 Change the capacity of all aux data vectors. More...
 
virtual void shift (size_t pos, ptrdiff_t offs) override
 Shift the elements of the container. More...
 
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. More...
 
virtual const SG::auxid_set_tgetAuxIDs () const override
 Return a set of identifiers for existing data items in this store. More...
 
virtual const SG::auxid_set_tgetDecorIDs () const override
 Return a set of identifiers for decorations in this store. More...
 
virtual bool isDecoration (auxid_t auxid) const override
 Test if a particular variable is tagged as a decoration. More...
 
virtual const SG::auxid_set_tgetWritableAuxIDs () const override
 Return a set of identifiers for writable data items in this store. More...
 
virtual const void * getIOData (SG::auxid_t auxid) const override
 Return a pointer to the data to be stored for one aux data item. More...
 
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. More...
 
virtual const SG::auxid_set_tgetDynamicAuxIDs () const override
 Get the list of all variables that need to be handled. More...
 
virtual void lock () override
 Lock the container. More...
 
virtual bool clearDecorations () override
 Clear all decorations. More...
 
virtual size_t size () const override
 Return the number of elements in the store. More...
 
virtual bool setOption (auxid_t id, const AuxDataOption &option) override
 Set an option for an auxiliary data variable. More...
 
virtual void lockDecoration (SG::auxid_t auxid) override
 Lock a decoration. More...
 
virtual IAuxTypeVectorlinkedVector (SG::auxid_t auxid) override
 Return interface for a linked variable. More...
 
virtual const IAuxTypeVectorlinkedVector (SG::auxid_t auxid) const override
 Return interface for a linked variable. More...
 
virtual const void * getData (SG::auxid_t auxid) const=0
 Pick up the const version from the base class. More...
 
virtual const IAuxTypeVectorlinkedVector (SG::auxid_t) const
 Return interface for a linked variable. More...
 
virtual SG::auxid_set_t getSelectedAuxIDs () const
 Get a list of dynamic variables that need to be written out. More...
 

Static Public Attributes

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

Protected Member Functions

const void * getIODataInternal (auxid_t auxid, bool quiet) const
 Return a pointer to the data to be stored for one aux data item. More...
 
void * getIODataInternal (auxid_t auxid, bool quiet)
 Return a pointer to the data to be stored for one aux data item. More...
 
void addAuxID (auxid_t auxid)
 Add a new auxid to the set of those being managed by this store. More...
 
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. More...
 
void addVector (std::unique_ptr< IAuxTypeVector > vec, bool isDecoration)
 Explicitly add a vector to the store. More...
 

Private Types

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

Private Member Functions

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

Private Attributes

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

Detailed Description

An auxiliary data store that holds data internally.

When auxiliary data are associated with a container, the data themselves are managed by a separate ‘store’ object, described by the interfaces SG::IAuxStore and SG::IConstAuxStore.

This class is an implementation of those interfaces that stores the data itself. This is suitable, for example, for transient auxiliary data.

Definition at line 41 of file AuxStoreInternal.h.

Member Typedef Documentation

◆ guard_t

typedef AthContainers_detail::lock_guard<mutex_t> SG::AuxStoreInternal::guard_t
private

Definition at line 461 of file AuxStoreInternal.h.

◆ mutex_t

typedef AthContainers_detail::mutex SG::AuxStoreInternal::mutex_t
private

Mutex used to synchronize modifications to the cache vector.

Definition at line 460 of file AuxStoreInternal.h.

Constructor & Destructor Documentation

◆ AuxStoreInternal() [1/2]

SG::AuxStoreInternal::AuxStoreInternal ( bool  standalone = false)

Constructor.

Parameters
standaloneIf true, then write this in standalone mode.

Definition at line 30 of file AuxStoreInternal.cxx.

32  m_locked (false)
33 {
34 }

◆ ~AuxStoreInternal()

SG::AuxStoreInternal::~AuxStoreInternal ( )
virtual

Destructor.

All contained data will be deleted.

Definition at line 42 of file AuxStoreInternal.cxx.

43 {
44 }

◆ AuxStoreInternal() [2/2]

SG::AuxStoreInternal::AuxStoreInternal ( const AuxStoreInternal orig)

Copy constructor.

Definition at line 50 of file AuxStoreInternal.cxx.

51 {
52  guard_t guard (other.m_mutex);
53  m_standalone = other.m_standalone;
54  m_decorations = other.m_decorations;
55  m_auxids = other.m_auxids;
56  m_locked = other.m_locked;
57  size_t size = other.m_vecs.size();
58  m_vecs.resize (size);
59  for (size_t i = 0; i < size; i++) {
60  if (other.m_vecs[i])
61  m_vecs[i] = other.m_vecs[i]->clone();
62  }
63 }

Member Function Documentation

◆ addAuxID()

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

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 }

◆ addVector()

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

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 }

◆ clearDecorations()

bool SG::AuxStoreInternal::clearDecorations ( )
overridevirtual

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) {
606  }
607  return anycleared;
608 }

◆ getAuxIDs()

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

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/3]

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

Return the data vector for one aux data item.

Parameters
auxidThe identifier of the desired aux data item.

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.

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

Implements SG::IConstAuxStore.

Reimplemented in APRTest::AuxStore, and RootAuxDynStore.

Definition at line 85 of file AuxStoreInternal.cxx.

86 {
87  const IAuxTypeVector* v = getVector (auxid);
88  if (v) {
89  return v->toPtr();
90  }
91  return nullptr;
92 }

◆ getData() [2/3]

virtual const void* SG::IConstAuxStore::getData
inherited

Pick up the const version from the base class.

◆ getData() [3/3]

void * SG::AuxStoreInternal::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.

Implements SG::IAuxStore.

Reimplemented in APRTest::AuxStore, and RootAuxDynStore.

Definition at line 132 of file AuxStoreInternal.cxx.

133 {
134  return getDataInternal (auxid, size, capacity, false);
135 }

◆ getDataInternal()

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

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 }

◆ getDecoration()

void * SG::AuxStoreInternal::getDecoration ( 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).

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 then it will be created and initialized with default values. If the container is locked, then the new item will be marked as a decoration. size and capacity give the size for the new aux data item vector.

If the data item already exists, then we return it if either the container is not locked or the item is marked as a decoration. Otherwise we throw an exception.

Implements SG::IConstAuxStore.

Reimplemented in RootAuxDynStore.

Definition at line 204 of file AuxStoreInternal.cxx.

205 {
206  guard_t guard (m_mutex);
207  if (m_vecs.size() <= auxid) {
208  m_vecs.resize (auxid+1);
209  }
210  if (m_vecs[auxid] == 0) {
211  m_vecs[auxid] = AuxTypeRegistry::instance().makeVector (auxid, size, capacity);
212  std::unique_ptr<IAuxTypeVector> linked = m_vecs[auxid]->linkedVector();
213  auxid_t linked_id = null_auxid;
214  if (linked) {
215  linked_id = linked->auxid();
216  m_vecs[linked_id] = std::move (linked);
217  }
218  if (m_locked) {
219  // Need to be sure that the addition to the decoration bitset is visible
220  // to other threads before the addition to the variable bitset.
221  m_decorations.insert (auxid);
222  if (linked_id != null_auxid) {
223  m_decorations.insert (linked_id);
224  }
225  std::atomic_thread_fence (std::memory_order_seq_cst);
226  }
227  addAuxID (auxid);
228  if (linked_id != null_auxid) {
229  addAuxID (linked_id);
230  }
231  }
232  if (m_locked && !m_decorations.test (auxid)) {
233  throw ExcStoreLocked (auxid);
234  }
235  return m_vecs[auxid]->toPtr();
236 }

◆ getDecorIDs()

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

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
overridevirtual

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 * SG::AuxStoreInternal::getIOData ( SG::auxid_t  auxid) const
overridevirtual

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

Parameters
auxidThe identifier of the desired aux data item.

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.

Implements SG::IAuxStoreIO.

Reimplemented in RootAuxDynStore.

Definition at line 529 of file AuxStoreInternal.cxx.

530 {
531  return getIODataInternal (auxid, false);
532 }

◆ getIODataInternal() [1/2]

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

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 }

◆ getIODataInternal() [2/2]

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

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
overridevirtual

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) {
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  }
558  return SG::AuxTypeRegistry::instance().getVecType (auxid);
559 }

◆ 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::ShallowAuxContainer, xAOD::AuxInfoBase, and xAOD::details::AuxStoreBase.

Definition at line 86 of file IAuxStoreIO.h.

86  {
87  // default all are selected
88  return getDynamicAuxIDs();
89  }

◆ getVector()

const IAuxTypeVector * SG::AuxStoreInternal::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.

Implements SG::IConstAuxStore.

Reimplemented in RootAuxDynStore.

Definition at line 101 of file AuxStoreInternal.cxx.

102 {
103  guard_t guard (m_mutex);
104  if (auxid >= m_vecs.size() || !m_vecs[auxid]) {
105  // With the new behavior of SG::Accessor::isAvailable,
106  // we shouldn't print an error message here. Asking the store whether
107  // it has an element using this function is not necessarily an
108  // error condition by now. In any case, the DataVector code will
109  // complain itself in case of an error.
110  return 0;
111  }
112  return m_vecs[auxid].get();
113 }

◆ getVectorInternal_noLock()

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

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
overridevirtual

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) 
)
overridevirtual

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 }

◆ isDecoration()

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

Test if a particular variable is tagged as a decoration.

Parameters
auxidThe identifier of the desired aux data item.

Implements SG::IConstAuxStore.

Reimplemented in RootAuxDynStore.

Definition at line 434 of file AuxStoreInternal.cxx.

435 {
436  return m_decorations.test (auxid);
437 }

◆ linkedVector() [1/3]

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

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/3]

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

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 }

◆ linkedVector() [3/3]

virtual const IAuxTypeVector* SG::IConstAuxStore::linkedVector
inlineinherited

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.

Definition at line 189 of file IConstAuxStore.h.

190  { return nullptr; }

◆ lock()

void SG::AuxStoreInternal::lock ( )
overridevirtual

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)
overridevirtual

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 }

◆ operator=()

AuxStoreInternal& SG::AuxStoreInternal::operator= ( const AuxStoreInternal )
delete

Don't allow assignment.

◆ reserve()

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

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)
overridevirtual

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 
)
overridevirtual

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 }

◆ shift()

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

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 SG::AuxStoreInternal::size ( ) const
overridevirtual

Return the number of elements in the store.

May return 0 for a store with no aux data.

Implements SG::IConstAuxStore.

Reimplemented in RootAuxDynStore, and APRTest::AuxStore.

Definition at line 616 of file AuxStoreInternal.cxx.

617 {
618  guard_t guard (m_mutex);
619  return size_noLock();
620 }

◆ size_noLock()

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

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

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
private

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
private

Record which variables are decorations.

Definition at line 451 of file AuxStoreInternal.h.

◆ m_locked

bool SG::AuxStoreInternal::m_locked
private

Has this container been locked?

Definition at line 457 of file AuxStoreInternal.h.

◆ m_mutex

mutex_t SG::AuxStoreInternal::m_mutex
mutableprivate

Definition at line 462 of file AuxStoreInternal.h.

◆ m_standalone

bool SG::AuxStoreInternal::m_standalone
private

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
private

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

Definition at line 448 of file AuxStoreInternal.h.

◆ supportsThinning

constexpr 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:
SG::IAuxTypeVector::shift
virtual bool shift(size_t pos, ptrdiff_t offs)=0
Shift the elements of the vector.
SG::IAuxTypeVector::isLinked
bool isLinked() const
Return true if this variable is linked from another one.
Definition: IAuxTypeVector.h:226
beamspotman.r
def r
Definition: beamspotman.py:672
SG::AuxStoreInternal::addAuxID
void addAuxID(auxid_t auxid)
Add a new auxid to the set of those being managed by this store.
Definition: AuxStoreInternal.cxx:690
fitman.sz
sz
Definition: fitman.py:527
SG::AuxStoreInternal::size_noLock
size_t size_noLock() const
Return the number of elements in the store; no locking.
Definition: AuxStoreInternal.cxx:628
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:640
SG::AuxStoreInternal::m_auxids
SG::auxid_set_t m_auxids
Set of auxid's for which we've created a vector.
Definition: AuxStoreInternal.h:454
quiet
bool quiet
Definition: TrigGlobEffCorrValidation.cxx:190
SG::AuxStoreInternal::m_mutex
mutex_t m_mutex
Definition: AuxStoreInternal.h:462
ATHCONTAINERS_ERROR
#define ATHCONTAINERS_ERROR(ctx, msg)
Definition: error.h:54
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:882
SG::AuxStoreInternal::standalone
bool standalone() const
Return the standalone flag.
Definition: AuxStoreInternal.cxx:69
SG::AuxStoreInternal::m_decorations
SG::auxid_set_t m_decorations
Record which variables are decorations.
Definition: AuxStoreInternal.h:451
SG::IAuxTypeVector::insertMove
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.
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
SG::AuxStoreInternal::m_locked
bool m_locked
Has this container been locked?
Definition: AuxStoreInternal.h:457
CxxUtils::ConcurrentBitset::clear
ConcurrentBitset & clear()
Clear all bits in the set.
SG::AuxStoreInternal::getAuxIDs
virtual const SG::auxid_set_t & getAuxIDs() const override
Return a set of identifiers for existing data items in this store.
Definition: AuxStoreInternal.cxx:414
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
SG::AuxStoreInternal::m_vecs
std::vector< std::unique_ptr< IAuxTypeVector > > m_vecs
The collection of vectors of aux data that we're managing, indexed by auxid.
Definition: AuxStoreInternal.h:448
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
H5Utils::internal::packed
H5::CompType packed(H5::CompType in)
Definition: common.cxx:16
lumiFormat.i
int i
Definition: lumiFormat.py:85
guard_t
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
Definition: EventIProxyDict.cxx:36
CxxUtils::ConcurrentBitset::insert
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
CxxUtils::ConcurrentBitset::reset
ConcurrentBitset & reset(bit_t bit)
Turn off one bit.
SG::AuxStoreInternal::getIODataInternal
const void * getIODataInternal(auxid_t auxid, bool quiet) const
Return a pointer to the data to be stored for one aux data item.
Definition: AuxStoreInternal.cxx:464
SG::AuxStoreInternal::getVectorInternal_noLock
virtual IAuxTypeVector * getVectorInternal_noLock(SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check)
Implementation of getVectorInternal; no locking.
Definition: AuxStoreInternal.cxx:698
SG::AuxTypeRegistry::getVecType
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
Definition: AuxTypeRegistry.cxx:937
SG::AuxStoreInternal::setOption
virtual bool setOption(auxid_t id, const AuxDataOption &option) override
Set an option for an auxiliary data variable.
Definition: AuxStoreInternal.cxx:650
SG::AuxStoreInternal::getDataInternal
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.
Definition: AuxStoreInternal.cxx:749
SG::AuxStoreInternal::size
virtual size_t size() const override
Return the number of elements in the store.
Definition: AuxStoreInternal.cxx:616
SG::IAuxStoreIO::getDynamicAuxIDs
virtual const SG::auxid_set_t & getDynamicAuxIDs() const =0
Get the list of all dynamically created variables.
SG::AuxTypeRegistry::makeVector
std::unique_ptr< IAuxTypeVector > makeVector(SG::auxid_t auxid, size_t size, size_t capacity) const
Construct a new vector to hold an aux item.
Definition: AuxTypeRegistry.cxx:818
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
SG::PackedParameters::isValidOption
static bool isValidOption(const AuxDataOption &option)
Test to see if option is a recognized packing option.
Definition: PackedParameters.cxx:197
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::AuxStoreInternal::m_standalone
bool m_standalone
Are we being written in standalone mode?
Definition: AuxStoreInternal.h:444
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::AuxStoreInternal::getVector
virtual const IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.
Definition: AuxStoreInternal.cxx:101
SG::AuxStoreInternal::isDecoration
virtual bool isDecoration(auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
Definition: AuxStoreInternal.cxx:434
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
CxxUtils::ConcurrentBitset::erase
ConcurrentBitset & erase(bit_t bit)
Turn off one bit.
SG::IAuxTypeVector::toPtr
virtual void * toPtr()=0
Return a pointer to the start of the vector's data.
CxxUtils::ConcurrentBitset::test
bool test(bit_t bit) const
Test to see if a bit is set.