25 :
m_data{mode, topStore} {}
31 return m_data.m_structMode;
36 m_data.m_structMode = mode;
71 if (
m_data.m_transientStore &&
72 (
m_data.m_transientStore->getAuxIDs().test(auxid))) {
73 return m_data.m_transientStore->getVector(auxid);
82 if ((auxid >=
m_data.m_vecs.size()) || (!
m_data.m_vecs[auxid])) {
83 if ((!this_nc->setupInputData(auxid).isSuccess()) ||
84 (!this_nc->setupOutputData(auxid).isSuccess())) {
90 if (this_nc->getEntryFor(auxid).isSuccess() ==
false) {
91 ::Error(
"xAOD::AuxStoreBase::getVector",
100 vec->resize (
vec->size());
117 std::size_t capacity) {
129 if ((auxid <
m_data.m_vecs.size()) &&
m_data.m_vecs[auxid] &&
130 (auxid <
m_data.m_isDecoration.size() &&
131 m_data.m_isDecoration[auxid])) {
133 m_data.m_vecs[auxid]->reserve(capacity);
135 return m_data.m_vecs[auxid]->toPtr();
140 if (
m_data.m_transientStore &&
141 m_data.m_transientStore->getAuxIDs().test(auxid)) {
142 return m_data.m_transientStore->getDecoration(auxid,
size, capacity);
146 if (
m_data.m_auxIDs.test(auxid)) {
155 if (!
m_data.m_transientStore) {
156 m_data.m_transientStore = std::make_unique<SG::AuxStoreInternal>(
159 m_data.m_transientStore->lock();
163 const std::size_t nids =
m_data.m_transientStore->getAuxIDs().size();
165 m_data.m_transientStore->getDecoration(auxid,
size, capacity);
166 if (result && (nids !=
m_data.m_transientStore->getAuxIDs().size())) {
167 if (
m_data.m_transientStore->isDecoration(auxid)) {
168 m_data.m_decorIDs.insert(auxid);
170 std::atomic_thread_fence( std::memory_order_seq_cst );
171 m_data.m_auxIDs.insert(auxid);
180 if (
m_data.m_isDecoration.size() <= auxid) {
181 m_data.m_isDecoration.resize(auxid + 1);
183 m_data.m_isDecoration[auxid] =
true;
184 m_data.m_decorIDs.insert(auxid);
185 std::atomic_thread_fence( std::memory_order_seq_cst );
201 if (auxid <
m_data.m_isDecoration.size() &&
m_data.m_isDecoration[auxid]) {
204 if (
m_data.m_transientStore) {
205 return m_data.m_transientStore->isDecoration(auxid);
217 if (
m_data.m_transientStore) {
218 m_data.m_transientStore->lock();
228 bool anycleared =
false;
229 if (
m_data.m_transientStore) {
233 anycleared =
m_data.m_transientStore->clearDecorations();
237 old_id_set -=
m_data.m_transientStore->getAuxIDs();
239 m_data.m_auxIDs -= old_id_set;
240 m_data.m_decorIDs.clear();
253 if (
m_data.m_transientStore) {
254 m_data.m_transientStore->lockDecoration(auxid);
256 m_data.m_decorIDs.erase(auxid);
264 if (
id >=
m_data.m_vecs.size())
267 if (!
m_data.m_vecs[
id] ||
m_data.m_vecs[
id]->isLinked()) {
271 const std::size_t
size =
m_data.m_vecs[id]->size();
279 if (
m_data.m_transientStore) {
280 return m_data.m_transientStore->size();
291 if (linked_id <
m_data.m_vecs.size()) {
292 return m_data.m_vecs[linked_id].get();
294 if (
m_data.m_transientStore) {
296 ->linkedVector(auxid);
305 if (linked_id <
m_data.m_vecs.size()) {
306 return m_data.m_vecs[linked_id].get();
308 if (
m_data.m_transientStore) {
309 return m_data.m_transientStore->linkedVector(auxid);
318 for (
auto& v :
m_data.m_vecs) {
320 v->toTransient( ctx );
323 if (
m_data.m_transientStore) {
324 m_data.m_transientStore->toTransient(ctx);
329 std::size_t capacity) {
340 if (!
m_data.m_transientStore) {
341 m_data.m_transientStore = std::make_unique<SG::AuxStoreInternal>(
344 m_data.m_transientStore->lock();
348 std::size_t nids =
m_data.m_transientStore->getAuxIDs().size();
349 void* result =
m_data.m_transientStore->getData(auxid,
size, capacity);
350 if (result && (nids !=
m_data.m_transientStore->getAuxIDs().size())) {
351 m_data.m_auxIDs.insert(auxid);
360 if (!((auxid <
m_data.m_isDecoration.size()) &&
361 m_data.m_isDecoration[auxid])) {
368 ::Error(
"xAOD::AuxStoreBase::getData",
376 ::Error(
"xAOD::AuxStoreBase::getData",
378 ::Error(
"xAOD::AuxStoreBase::getData",
XAOD_MESSAGE(
" name = %s"),
380 ::Error(
"xAOD::AuxStoreBase::getData",
XAOD_MESSAGE(
" size = %i"),
381 static_cast<int>(
size));
382 ::Error(
"xAOD::AuxStoreBase::getData",
383 XAOD_MESSAGE(
" m_structMode = EStructMode::kObjectStore"));
388 m_data.m_vecs[auxid]->reserve(capacity);
392 return m_data.m_vecs[auxid]->toPtr();
407 ::Error(
"xAOD::AuxStoreBase::resize",
409 static_cast<int>(
size));
417 for (
auto& v :
m_data.m_vecs) {
418 if (v && !v->isLinked()) {
419 if (!v->resize(
size)) {
424 if (
m_data.m_transientStore) {
440 ::Error(
"xAOD::AuxStoreBase::reserve",
442 static_cast<int>(
size));
446 for (
auto& v :
m_data.m_vecs) {
447 if (v && !v->isLinked()) {
452 if (
m_data.m_transientStore) {
464 ::Error(
"xAOD::AuxStoreBase::shift",
465 XAOD_MESSAGE(
"Should not have been called for single-object "
471 if ((
static_cast<std::size_t
>(std::abs(offs)) >
m_data.m_size) &&
478 for (
auto& v :
m_data.m_vecs) {
479 if (v && !v->isLinked()) {
484 if (
m_data.m_transientStore) {
485 m_data.m_transientStore->shift(pos, offs);
496 ::Error(
"xAOD::AuxStoreBase::insertMove",
497 XAOD_MESSAGE(
"Should not have been called for single-object "
503 std::size_t other_size =
other.size();
509 if (
id <
m_data.m_vecs.size()) {
510 v_dst =
m_data.m_vecs[id].get();
514 if (
other.getData(
id)) {
515 void* src_ptr =
other.getData(
id, other_size, other_size);
522 const void* orig = v_dst->
toPtr();
523 v_dst->
shift(pos, other_size);
524 if (orig != v_dst->
toPtr()) {
531 if (
m_data.m_transientStore) {
532 if (!
m_data.m_transientStore->insertMove(pos,
other, ignore))
549 if (!this_nc->getEntryFor(auxid).isSuccess()) {
550 ::Error(
"xAOD::AuxStoreBase::getIOData",
559 if (
m_data.m_transientStore &&
560 m_data.m_transientStore->getAuxIDs().test(auxid)) {
561 return m_data.m_transientStore->getIOData(auxid);
565 if (!this_nc->setupInputData(auxid).isSuccess()) {
580 ::Fatal(
"xAOD::AuxStoreBase::getIOData",
586 if (!this_nc->getEntryFor(auxid).isSuccess()) {
587 ::Error(
"xAOD::AuxStoreBase::getIOData",
609 if (
m_data.m_transientStore &&
610 m_data.m_transientStore->getAuxIDs().test(auxid)) {
611 return m_data.m_transientStore->getIOType(auxid);
617 if (!this_nc->setupInputData(auxid).isSuccess()) {
618 ::Error(
"xAOD::AuxStoreBase::getIOType",
621 static_cast<int>(auxid),
628 ::Fatal(
"xAOD::AuxStoreBase::getIOType",
672 auxids.insert(auxid);
675 return m_selection.getSelectedAuxIDs(auxids).size();
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.
Abstract interface for manipulating vectors of arbitrary types.
Helper for getting a const version of a pointer.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Exception — Attempted to modify auxiliary data in a locked store.
Interface for non-const operations on an auxiliary 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.
virtual ~AuxStoreBase()
Destructor.
virtual const SG::auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.
virtual SG::auxid_set_t getCopyIDs(bool warnUnlocked=false) const override
Get the set of variables that we should deep copy.
virtual void reset()=0
Reset all (transient) information in the object.
virtual void shift(std::size_t pos, std::ptrdiff_t offs) override
Shift the contents of the stored arrays.
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.
mutex_t m_mutex1
Mutex objects used for multithreaded synchronisation.
virtual void lockDecoration(SG::auxid_t auxid) override
Lock a decoration.
virtual const void * getIOData(SG::auxid_t auxid) const override
Get a pointer to the data being stored for one aux data item.
virtual StatusCode setupOutputData(SG::auxid_t auxid)=0
Connect a variable to the output.
virtual void toTransient(const EventContext &ctx) override
Call toTransient on contained variables.
virtual const void * getData(SG::auxid_t auxid) const override
Get a pointer to a given array.
AuxSelection m_selection
Object helping to select which auxiliary variables to write.
const std::string & prefix() const
Get the currently configured object name prefix.
void setTopStore(bool value=true)
Set whether the object should behave as a "top store" or not.
virtual bool hasOutput() const =0
Check if an output is being written by the object.
bool isAuxIDSelected(SG::auxid_t auxid) const
Check if an auxiliary variable is selected for ouput writing.
void setStructMode(EStructMode mode)
Set the structure mode of the object to a new value.
virtual const SG::auxid_set_t & getDecorIDs() const override
Get the types(names) of decorations handled by this container.
bool isTopStore() const
Check if the object is a "top store", or not.
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 bool insertMove(std::size_t pos, SG::IAuxStore &other, const SG::auxid_set_t &ignore) override
Insert contents of another store via move.
virtual SG::auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected aux variables.
virtual const std::type_info * getInputType(SG::auxid_t auxid) const =0
Get the type of an input object, for getIOType().
virtual bool clearDecorations() override
Remove the decorations added so far.
EStructMode
"Structural" modes of the object
@ kObjectStore
The object describes a single object.
virtual bool hasEntryFor(SG::auxid_t auxid) const =0
Check if a given variable is available from the input.
bool m_locked
Is this container locked?
virtual void reserve(std::size_t size) override
Reserve a given size for the arrays.
virtual bool isDecoration(SG::auxid_t auxid) const override
Test if a variable is a decoration.
virtual const SG::auxid_set_t & getDynamicAuxIDs() const override
Get the types(names) of variables created dynamically.
virtual const SG::auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
AuxStoreBase(bool topStore=true, EStructMode mode=EStructMode::kUndefinedStore)
Constructor.
virtual const SG::IAuxTypeVector * linkedVector(SG::auxid_t auxid) const override
Return (const) interface for a linked variable.
virtual void * getDecoration(SG::auxid_t auxid, std::size_t size, std::size_t capacity) override
Get a pointer to a given array, creating the array if necessary.
EStructMode structMode() const
Get what structure mode the object was constructed with.
Members m_data
Member variables of the base class.
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
virtual bool resize(std::size_t size) override
Resize the arrays to a given size.
virtual std::size_t size() const override
Return the number of elements in the store.
virtual const void * getInputObject(SG::auxid_t auxid) const =0
Get a pointer to an input object, as it is in memory, for getIOData().
virtual void selectAux(const std::set< std::string > &attributes)
Select dynamic auxiliary attributes for writing.
virtual void lock() override
Lock the object, and don't let decorations be added.
const T * as_const_ptr(const T *p)
Helper for getting a const version of a pointer.
virtual SG::auxid_set_t getCopyIDs(bool warnUnlocked=false) const override
Return the set of variables to copy in a deep copy.
size_t auxid_t
Identifier for a particular aux data item.