42AuxStoreInternal::~AuxStoreInternal()
50AuxStoreInternal::AuxStoreInternal (
const AuxStoreInternal& other)
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();
59 for (
size_t i = 0; i <
size; i++) {
61 m_vecs[i] = other.m_vecs[i]->clone();
69bool AuxStoreInternal::standalone()
const
85const void* AuxStoreInternal::getData (auxid_t auxid)
const
87 const IAuxTypeVector* v = getVector (auxid);
101const IAuxTypeVector* AuxStoreInternal::getVector (auxid_t auxid)
const
104 if (auxid >=
m_vecs.size() || !m_vecs[auxid]) {
132void* AuxStoreInternal::getData (auxid_t auxid,
size_t size,
size_t capacity)
146AuxStoreInternal::addVector (std::unique_ptr<IAuxTypeVector>
vec,
163 if (!
vec->isLinked()) {
165 if (
vec->size() <
sz)
176 std::atomic_thread_fence (std::memory_order_seq_cst);
206AuxStoreInternal::getDecoration (auxid_t auxid,
size_t size,
size_t capacity)
209 if (m_vecs.size() <= auxid) {
210 m_vecs.resize (auxid+1);
212 if (m_vecs[auxid] == 0) {
213 m_vecs[
auxid] = AuxTypeRegistry::instance().makeVector (auxid,
size, capacity);
214 std::unique_ptr<IAuxTypeVector> linked =
m_vecs[
auxid]->linkedVector();
215 auxid_t linked_id = null_auxid;
217 linked_id = linked->auxid();
218 m_vecs[linked_id] = std::move (linked);
224 if (linked_id != null_auxid) {
227 std::atomic_thread_fence (std::memory_order_seq_cst);
230 if (linked_id != null_auxid) {
235 throw ExcStoreLocked (auxid);
256bool AuxStoreInternal::resize (
size_t sz)
260 throw ExcStoreLocked (
"resize");
266 if (v && !
v->isLinked()) {
283void AuxStoreInternal::reserve (
size_t sz)
287 throw ExcStoreLocked (
"reserve");
288 for (std::unique_ptr<IAuxTypeVector>& v : m_vecs) {
289 if (v && !
v->isLinked())
317void AuxStoreInternal::shift (
size_t pos, ptrdiff_t offs)
321 throw ExcStoreLocked (
"shift");
322 for (std::unique_ptr<IAuxTypeVector>& v : m_vecs) {
323 if (v && !
v->isLinked())
324 v->shift (pos, offs);
348bool AuxStoreInternal::insertMove (
size_t pos,
353 const AuxTypeRegistry&
r = AuxTypeRegistry::instance();
356 throw ExcStoreLocked (
"insertMove");
358 size_t other_size =
other.size();
367 if (
other.getData (
id)) {
368 void* src_ptr =
other.getData (
id, other_size, other_size);
370 if (!v_dst->
insertMove (pos, src_ptr, 0, other_size,
376 const void* orig = v_dst->
toPtr();
377 v_dst->
shift (pos, other_size);
378 if (orig != v_dst->
toPtr())
388 if (
r.isLinked (
id))
continue;
389 if (
other.getData (
id)) {
390 void* src_ptr =
other.getData (
id, other_size, other_size);
393 if (
sz < other_size)
sz = other_size +
pos;
395 v->resize (
sz - other_size);
396 (void)
v->insertMove (pos, src_ptr, 0, other_size,
416AuxStoreInternal::getAuxIDs()
const
426AuxStoreInternal::getDecorIDs()
const
439 return SG::getCopyIDs (m_auxids, m_decorations, warnUnlocked, {});
447bool AuxStoreInternal::isDecoration (auxid_t auxid)
const
460AuxStoreInternal::getWritableAuxIDs()
const
483 "Requested variable {} ({}) doesn't exist",
508void* AuxStoreInternal::getIODataInternal (auxid_t auxid,
bool quiet)
511 if (auxid >= m_vecs.size() || !m_vecs[auxid]) {
514 "Requested variable {} ({}) doesn't exist",
538const void* AuxStoreInternal::getIOData (auxid_t auxid)
const
555const std::type_info* AuxStoreInternal::getIOType (auxid_t auxid)
const
559 if (!
r.isLinked (auxid))
560 return r.getType (auxid);
563 if (auxid <
m_vecs.size() && m_vecs[auxid]) {
564 const std::type_info* ret =
m_vecs[
auxid]->objType();
575AuxStoreInternal::getDynamicAuxIDs()
const
587void AuxStoreInternal::lock()
604bool AuxStoreInternal::clearDecorations()
607 bool anycleared =
false;
608 for (auxid_t
id : m_decorations) {
625size_t AuxStoreInternal::size()
const
637size_t AuxStoreInternal::size_noLock()
const
640 if (
id <
m_vecs.size() && m_vecs[
id] && !m_vecs[
id]->isLinked() &&
641 m_vecs[
id]->size() > 0)
659bool AuxStoreInternal::setOption (auxid_t
id,
const AuxDataOption& option)
665 if (
id <
m_vecs.size() && m_vecs[
id] != 0)
671 if (!PackedParameters::isValidOption (option))
return false;
678 if (m_vecs[
id]->setOption (option))
return true;
682 if (!PackedParameters::isValidOption (option))
return false;
687 return m_vecs[
id]->setOption (option);
699void AuxStoreInternal::addAuxID (auxid_t auxid)
721 std::unique_ptr<IAuxTypeVector> linked =
m_vecs[
auxid]->linkedVector();
723 auxid_t linked_id = linked->auxid();
724 m_vecs[linked_id] = std::move (linked);
776void AuxStoreInternal::lockDecoration (
SG::auxid_t auxid)
779 m_decorations.reset (auxid);
792IAuxTypeVector* AuxStoreInternal::linkedVector (
SG::auxid_t auxid)
794 const AuxTypeRegistry&
r = AuxTypeRegistry::instance();
795 auxid_t linked_id =
r.linkedVariable (auxid);
797 if (linked_id <
m_vecs.size())
798 return m_vecs[linked_id].get();
812const IAuxTypeVector* AuxStoreInternal::linkedVector (
SG::auxid_t auxid)
const
814 const AuxTypeRegistry&
r = AuxTypeRegistry::instance();
815 auxid_t linked_id =
r.linkedVariable (auxid);
817 if (linked_id <
m_vecs.size())
818 return m_vecs[linked_id].get();
833void AuxStoreInternal::toTransient (
const EventContext& ctx,
SG::auxid_t auxid)
836 if (auxid <
m_vecs.size() && m_vecs[auxid]) {
852void AuxStoreInternal::toTransient (
const EventContext& ctx)
857 if (
id <
sz && m_vecs[
id]) {
876 [[maybe_unused]]
bool warnUnlocked,
877 [[maybe_unused]] std::span<const std::string> noWarn)
880#ifndef XAOD_STANDALONE
884 if (out.test (decor)) {
886 if (std::ranges::find (noWarn,
r.getName (decor)) == noWarn.end()) {
888 "skipped unlocked decoration during copy {} ({})",
889 r.getName(decor), 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.
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_ERROR(ctx, msg,...)
#define ATHCONTAINERS_WARNING(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?
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.