43AuxStoreInternal::~AuxStoreInternal()
58 size_t size = other.m_vecs.size();
60 for (
size_t i = 0; i <
size; i++) {
62 m_vecs[i] = other.m_vecs[i]->clone();
70bool AuxStoreInternal::standalone()
const
86const void* AuxStoreInternal::getData (auxid_t auxid)
const
88 const IAuxTypeVector* v = getVector (auxid);
102const IAuxTypeVector* AuxStoreInternal::getVector (auxid_t auxid)
const
105 if (auxid >=
m_vecs.size() || !m_vecs[auxid]) {
133void* AuxStoreInternal::getData (auxid_t auxid,
size_t size,
size_t capacity)
147AuxStoreInternal::addVector (std::unique_ptr<IAuxTypeVector>
vec,
164 if (!
vec->isLinked()) {
166 if (
vec->size() <
sz)
177 std::atomic_thread_fence (std::memory_order_seq_cst);
207AuxStoreInternal::getDecoration (auxid_t auxid,
size_t size,
size_t capacity)
210 if (m_vecs.size() <= auxid) {
211 m_vecs.resize (auxid+1);
213 if (m_vecs[auxid] == 0) {
214 m_vecs[
auxid] = AuxTypeRegistry::instance().makeVector (auxid,
size, capacity);
215 std::unique_ptr<IAuxTypeVector> linked =
m_vecs[
auxid]->linkedVector();
216 auxid_t linked_id = null_auxid;
218 linked_id = linked->auxid();
219 m_vecs[linked_id] = std::move (linked);
225 if (linked_id != null_auxid) {
228 std::atomic_thread_fence (std::memory_order_seq_cst);
231 if (linked_id != null_auxid) {
236 throw ExcStoreLocked (auxid);
257bool AuxStoreInternal::resize (
size_t sz)
261 throw ExcStoreLocked (
"resize");
267 if (v && !
v->isLinked()) {
284void AuxStoreInternal::reserve (
size_t sz)
288 throw ExcStoreLocked (
"reserve");
289 for (std::unique_ptr<IAuxTypeVector>& v : m_vecs) {
290 if (v && !
v->isLinked())
318void AuxStoreInternal::shift (
size_t pos, ptrdiff_t offs)
322 throw ExcStoreLocked (
"shift");
323 for (std::unique_ptr<IAuxTypeVector>& v : m_vecs) {
324 if (v && !
v->isLinked())
325 v->shift (pos, offs);
349bool AuxStoreInternal::insertMove (
size_t pos,
354 const AuxTypeRegistry&
r = AuxTypeRegistry::instance();
357 throw ExcStoreLocked (
"insertMove");
359 size_t other_size =
other.size();
368 if (
other.getData (
id)) {
369 void* src_ptr =
other.getData (
id, other_size, other_size);
371 if (!v_dst->
insertMove (pos, src_ptr, 0, other_size,
377 const void* orig = v_dst->
toPtr();
378 v_dst->
shift (pos, other_size);
379 if (orig != v_dst->
toPtr())
389 if (
r.isLinked (
id))
continue;
390 if (
other.getData (
id)) {
391 void* src_ptr =
other.getData (
id, other_size, other_size);
394 if (
sz < other_size)
sz = other_size +
pos;
396 v->resize (
sz - other_size);
397 (void)
v->insertMove (pos, src_ptr, 0, other_size,
417AuxStoreInternal::getAuxIDs()
const
427AuxStoreInternal::getDecorIDs()
const
440 return SG::getCopyIDs (m_auxids, m_decorations, warnUnlocked, {});
448bool AuxStoreInternal::isDecoration (auxid_t auxid)
const
461AuxStoreInternal::getWritableAuxIDs()
const
483 std::ostringstream
ss;
484 ss <<
"Requested variable "
486 <<
" (" <<
auxid <<
") doesn't exist";
511void* AuxStoreInternal::getIODataInternal (auxid_t auxid,
bool quiet)
514 if (auxid >= m_vecs.size() || !m_vecs[auxid]) {
516 std::ostringstream
ss;
517 ss <<
"Requested variable "
519 <<
" (" << auxid <<
") doesn't exist";
543const void* AuxStoreInternal::getIOData (auxid_t auxid)
const
560const std::type_info* AuxStoreInternal::getIOType (auxid_t auxid)
const
564 if (!
r.isLinked (auxid))
565 return r.getType (auxid);
568 if (auxid <
m_vecs.size() && m_vecs[auxid]) {
569 const std::type_info* ret =
m_vecs[
auxid]->objType();
580AuxStoreInternal::getDynamicAuxIDs()
const
592void AuxStoreInternal::lock()
609bool AuxStoreInternal::clearDecorations()
612 bool anycleared =
false;
613 for (auxid_t
id : m_decorations) {
630size_t AuxStoreInternal::size()
const
642size_t AuxStoreInternal::size_noLock()
const
645 if (
id <
m_vecs.size() && m_vecs[
id] && !m_vecs[
id]->isLinked() &&
646 m_vecs[
id]->size() > 0)
664bool AuxStoreInternal::setOption (auxid_t
id,
const AuxDataOption& option)
670 if (
id <
m_vecs.size() && m_vecs[
id] != 0)
676 if (!PackedParameters::isValidOption (option))
return false;
683 if (m_vecs[
id]->setOption (option))
return true;
687 if (!PackedParameters::isValidOption (option))
return false;
692 return m_vecs[
id]->setOption (option);
704void AuxStoreInternal::addAuxID (auxid_t auxid)
726 std::unique_ptr<IAuxTypeVector> linked =
m_vecs[
auxid]->linkedVector();
728 auxid_t linked_id = linked->auxid();
729 m_vecs[linked_id] = std::move (linked);
781void AuxStoreInternal::lockDecoration (
SG::auxid_t auxid)
784 m_decorations.reset (auxid);
797IAuxTypeVector* AuxStoreInternal::linkedVector (
SG::auxid_t auxid)
799 const AuxTypeRegistry&
r = AuxTypeRegistry::instance();
800 auxid_t linked_id =
r.linkedVariable (auxid);
802 if (linked_id <
m_vecs.size())
803 return m_vecs[linked_id].get();
817const IAuxTypeVector* AuxStoreInternal::linkedVector (
SG::auxid_t auxid)
const
819 const AuxTypeRegistry&
r = AuxTypeRegistry::instance();
820 auxid_t linked_id =
r.linkedVariable (auxid);
822 if (linked_id <
m_vecs.size())
823 return m_vecs[linked_id].get();
840 [[maybe_unused]]
bool warnUnlocked,
841 [[maybe_unused]] std::span<const std::string> noWarn)
844#ifndef XAOD_STANDALONE
848 if (out.test (decor)) {
850 if (std::ranges::find (noWarn,
r.getName (decor)) == noWarn.end()) {
851 std::ostringstream
ss;
852 ss <<
"skipped unlocked decoration during copy " <<
r.getName(decor)
853 <<
" (" << decor <<
")";
An auxiliary data store that holds data internally.
Handle mappings between names and auxid_t.
std::vector< size_t > vec
Exceptions that can be thrown from AthContainers.
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
Describe how the contents of a PackedContainer are to be saved.
size_t size() const
Number of registered mappings.
Handle mappings between names and auxid_t.
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Exception — Attempted to modify auxiliary data in a locked store.
Abstract interface for manipulating vectors of arbitrary types.
bool isLinked() const
Return true if this variable is linked from another one.
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.
A set of aux data identifiers.
bool exists(const std::string &filename)
does a file exist
Helper for emitting error messages.
#define ATHCONTAINERS_WARNING(ctx, msg)
#define ATHCONTAINERS_ERROR(ctx, msg)
H5::CompType packed(H5::CompType in)
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.
bool standalone() const
Return the standalone flag.
void addAuxID(auxid_t auxid)
Add a new auxid to the set of those being managed by this store.
virtual SG::auxid_set_t getCopyIDs(bool warnUnlocked=false) const override
Return the set of variables to copy in a deep copy.
virtual IAuxTypeVector * getVectorInternal_noLock(SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check)
Implementation of getVectorInternal; no locking.
SG::auxid_set_t m_decorations
Record which variables are decorations.
SG::auxid_t auxid() const
Return the aux id for this variable.
const void * getIODataInternal(auxid_t auxid, bool quiet) const
Return a pointer to the data to be stored for one aux data item.
virtual bool isDecoration(auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
AthContainers_detail::lock_guard< mutex_t > guard_t
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_auxids
Set of auxid's for which we've created a vector.
virtual size_t size() const override
Return the number of elements in the store.
bool m_locked
Has this container been locked?
AuxStoreInternal(bool standalone=false)
An auxiliary data store that holds data internally.
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items for this object.
size_t size_noLock() const
Return the number of elements in the store; no locking.
bool m_standalone
Are we being written in standalone mode?
size_t auxid_t
Identifier for a particular aux data item.