ATLAS Offline Software
Loading...
Searching...
No Matches
AuxStoreBase.h
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2#ifndef XAODROOTACCESS_TOOLS_AUXSTOREBASE_H
3#define XAODROOTACCESS_TOOLS_AUXSTOREBASE_H
4
5// Framework include(s).
12
13// System include(s).
14#include <memory>
15#include <string>
16#include <string_view>
17
18namespace xAOD::details {
19
27
28 public:
35
37 AuxStoreBase(bool topStore = true,
40 virtual ~AuxStoreBase();
41
43 EStructMode structMode() const;
45 void setStructMode(EStructMode mode);
46
48 const std::string& prefix() const;
50 virtual void setPrefix(std::string_view prefix) = 0;
51
53 bool isTopStore() const;
55 void setTopStore(bool value = true);
56
59
61 virtual const void* getData(SG::auxid_t auxid) const override;
62
64 virtual const SG::IAuxTypeVector* getVector(SG::auxid_t auxid) const override;
65
67 virtual const SG::auxid_set_t& getAuxIDs() const override;
68
70 virtual const SG::auxid_set_t& getDecorIDs() const override;
71
73 virtual void* getDecoration(SG::auxid_t auxid, std::size_t size,
74 std::size_t capacity) override;
75
77 virtual bool isDecoration(SG::auxid_t auxid) const override;
78
80 virtual void lock() override;
83 virtual bool clearDecorations() override;
84
86 virtual void lockDecoration(SG::auxid_t auxid) override;
87
89 virtual std::size_t size() const override;
90
92 virtual const SG::IAuxTypeVector* linkedVector(
93 SG::auxid_t auxid) const override;
95 virtual SG::IAuxTypeVector* linkedVector(SG::auxid_t auxid) override;
96
98
101
103 virtual void* getData(SG::auxid_t auxid, std::size_t size,
104 std::size_t capacity) override;
105
107 virtual const SG::auxid_set_t& getWritableAuxIDs() const override;
108
110 virtual bool resize(std::size_t size) override;
112 virtual void reserve(std::size_t size) override;
114 virtual void shift(std::size_t pos, std::ptrdiff_t offs) override;
116 virtual bool insertMove(std::size_t pos, SG::IAuxStore& other,
117 const SG::auxid_set_t& ignore) override;
118
120
123
125 virtual const void* getIOData(SG::auxid_t auxid) const override;
126
128 virtual const std::type_info* getIOType(SG::auxid_t auxid) const override;
129
131 virtual const SG::auxid_set_t& getDynamicAuxIDs() const override;
132
134 virtual void selectAux(const std::set<std::string>& attributes);
135
137 virtual SG::auxid_set_t getSelectedAuxIDs() const override;
138
140
141 protected:
143 bool isAuxIDSelected(SG::auxid_t auxid) const;
144
147
149 virtual void reset() = 0;
150
152 virtual bool hasEntryFor(SG::auxid_t auxid) const = 0;
154 virtual StatusCode getEntryFor(SG::auxid_t auxid) = 0;
156 virtual bool hasOutput() const = 0;
157
159 virtual StatusCode setupInputData(SG::auxid_t auxid) = 0;
161 virtual StatusCode setupOutputData(SG::auxid_t auxid) = 0;
162
164 virtual const void* getInputObject(SG::auxid_t auxid) const = 0;
166 virtual const std::type_info* getInputType(SG::auxid_t auxid) const = 0;
167
169
171 struct Members {
172
176 bool m_topStore = true;
178 std::string m_prefix{};
180 std::string m_dynPrefix{};
181
183 std::unique_ptr<SG::AuxStoreInternal> m_transientStore{};
184
191 std::vector<std::unique_ptr<SG::IAuxTypeVector> > m_vecs{};
193 std::size_t m_size = 0u;
194
196 std::vector<bool> m_isDecoration{};
197
198 }; // struct BaseMembers
199
202
204 using mutex_t = AthContainers_detail::mutex;
206 using guard_t = AthContainers_detail::lock_guard<mutex_t>;
207
208 private:
212 bool m_locked = false;
215
216}; // class AuxStoreBase
217
218} // namespace xAOD::details
219
220#endif // XAODROOTACCESS_TOOLS_AUXSTOREBASE_H
An auxiliary data store that holds data internally.
Interface providing I/O for a generic auxiliary store.
Interface for non-const operations on an auxiliary store.
Interface providing I/O for a generic auxiliary store.
Definition IAuxStoreIO.h:44
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
Abstract interface for manipulating vectors of arbitrary types.
A set of aux data identifiers.
Definition AuxTypes.h:47
Class helping in dealing with dynamic branch selection.
virtual ~AuxStoreBase()
Destructor.
virtual const SG::auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.
virtual void setPrefix(std::string_view prefix)=0
Set the object name prefix.
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 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.
virtual StatusCode getEntryFor(SG::auxid_t auxid)=0
Load a single variable from the input.
AthContainers_detail::mutex mutex_t
Mutex type for multithread synchronization.
EStructMode
"Structural" modes of the object
@ kUndefinedStore
The structure mode is not defined.
@ kObjectStore
The object describes a single object.
@ kContainerStore
The object describes an entire container.
virtual StatusCode setupInputData(SG::auxid_t auxid)=0
Connect a variable to the input.
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.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Struct collecting all member variables of this base class.
SG::auxid_set_t m_auxIDs
Internal list of auxiliary variable IDs handled currently by the object.
EStructMode m_structMode
The "structural" mode of the object.
std::string m_prefix
Static prefix for the branch names.
std::string m_dynPrefix
Dynamic prefix for the branch names.
std::size_t m_size
The current size of the container being described.
std::unique_ptr< SG::AuxStoreInternal > m_transientStore
Store for the in-memory-only variables.
std::vector< bool > m_isDecoration
Per variable lock status (indexed by auxiliary ID)
SG::auxid_set_t m_decorIDs
Internal list of auxiliary decoration IDs handled currently by the object.
bool m_topStore
Flag stating whether this is a "top store".
std::vector< std::unique_ptr< SG::IAuxTypeVector > > m_vecs
Variables handled currently by the object (indexed by auxiliary ID)
Threading definitions.