ATLAS Offline Software
IAuxTypeVector.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef ATHCONTAINERSINTERFACES_IAUXTYPEVECTOR_H
14 #define ATHCONTAINERSINTERFACES_IAUXTYPEVECTOR_H
15 
16 
20 #include "CxxUtils/CachedValue.h"
21 #include <cstddef>
22 #include <memory>
23 #include <typeinfo>
24 
25 
26 namespace SG {
27 
28 
29 class AuxDataOption;
30 
31 
42 {
43 public:
50  : m_auxid (auxid),
52  {
53  }
54 
55 
57  virtual ~IAuxTypeVector() = default;
58 
59 
63  virtual std::unique_ptr<IAuxTypeVector> clone() const = 0;
64 
65 
69  virtual void* toPtr() = 0;
70 
71 
75  virtual const void* toPtr() const = 0;
76 
77 
81  virtual void* toVector() = 0;
82 
83 
87  virtual size_t size() const = 0;
88 
89 
97  virtual bool resize (size_t sz) = 0;
98 
99 
104  virtual void reserve (size_t sz) = 0;
105 
106 
133  virtual bool shift (size_t pos, ptrdiff_t offs) = 0;
134 
135 
158  virtual bool insertMove (size_t pos,
159  void* src, size_t src_pos, size_t src_n,
160  IAuxStore& srcStore) = 0;
161 
162 
172  virtual bool setOption (const AuxDataOption& /*option*/)
173  { return false; }
174 
175 
188  virtual std::unique_ptr<IAuxTypeVector> toPacked() { return 0; }
189 
190 
202  virtual const std::type_info* objType() const { return 0; }
203 
204 
217  virtual std::unique_ptr<IAuxTypeVector> linkedVector() { return nullptr; }
218 
219 
226  bool isLinked() const { return m_isLinked; }
227 
228 
232  auxid_t auxid() const
233  {
234  return m_auxid;
235  }
236 
237 
262  {
263  if (!m_span.isValid()) {
264  m_span.set (this->getDataSpanImpl());
265  }
266  return *m_span.ptr();
267  }
268 
269 
270 protected:
276  virtual AuxDataSpanBase getDataSpanImpl() const = 0;
277 
278 
284  void storeDataSpan (void* beg, size_t size)
285  {
286  // Only do this if the span is already valid, so that it doesn't
287  // get marked valid before ROOT I/O.
288  if (m_span.isValid()) {
289  m_span.store (AuxDataSpanBase (beg, size));
290  }
291  }
292 
293 
298  {
299  m_span.reset();
300  }
301 
302 
303 private:
306 
309 
312 };
313 
314 
315 } // namespace SG
316 
317 
318 #endif // not ATHCONTAINERSINTERFACES_IAUXTYPEVECTOR_H
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
SG::IAuxTypeVector::getDataSpan
const AuxDataSpanBase & getDataSpan() const
Return a reference to a description of this vector's start+size.
Definition: IAuxTypeVector.h:261
SG::IAuxTypeVector::m_span
CxxUtils::CachedValue< AuxDataSpanBase > m_span
Description of the vector start+size.
Definition: IAuxTypeVector.h:311
fitman.sz
sz
Definition: fitman.py:527
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
SG::IAuxTypeVector::resetDataSpan
void resetDataSpan()
Invalidate the stored span.
Definition: IAuxTypeVector.h:297
AuxDataSpan.h
Describe a range over an auxiliary variable, for low-overhead access.
SG::IAuxTypeVector::toPtr
virtual const void * toPtr() const =0
Return a pointer to the start of the vector's data.
SG::IAuxTypeVector::getDataSpanImpl
virtual AuxDataSpanBase getDataSpanImpl() const =0
Return a span object describing the current vector.
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.
SG::IAuxTypeVector::~IAuxTypeVector
virtual ~IAuxTypeVector()=default
Destructor.
SG::IAuxTypeVector::objType
virtual const std::type_info * objType() const
Return the type of the complete object to be saved.
Definition: IAuxTypeVector.h:202
SG::IAuxTypeVector::clone
virtual std::unique_ptr< IAuxTypeVector > clone() const =0
Make a copy of this vector.
SG::IAuxTypeVector::toPacked
virtual std::unique_ptr< IAuxTypeVector > toPacked()
Make a packed version of the variable.
Definition: IAuxTypeVector.h:188
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::IAuxTypeVector::storeDataSpan
void storeDataSpan(void *beg, size_t size)
Update the stored span.
Definition: IAuxTypeVector.h:284
CxxUtils::CachedValue
Cached value with atomic update.
Definition: CachedValue.h:55
SG::IAuxTypeVector::toVector
virtual void * toVector()=0
Return a pointer to the STL vector itself.
SG::IAuxTypeVector::IAuxTypeVector
IAuxTypeVector(auxid_t auxid, bool isLinked)
Constructor.
Definition: IAuxTypeVector.h:49
SG::IAuxTypeVector::linkedVector
virtual std::unique_ptr< IAuxTypeVector > linkedVector()
Return IAuxTypeVector of a linked variable, if there is one.
Definition: IAuxTypeVector.h:217
SG::AuxDataOption
Hold information about an option setting request.
Definition: AuxDataOption.h:37
SG::AuxDataSpanBase
Minimal span-like object describing the range of an auxiliary variable.
Definition: AuxDataSpan.h:39
CachedValue.h
Cached value with atomic update.
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
SG::IAuxTypeVector::auxid
auxid_t auxid() const
Return the auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:232
SG::IAuxTypeVector::m_auxid
auxid_t m_auxid
The auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:305
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
AuxTypes.h
Basic definitions for auxiliary types.
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
SG::IAuxTypeVector::m_isLinked
bool m_isLinked
True if this variable is linked from another one.
Definition: IAuxTypeVector.h:308
SG::IAuxTypeVector::resize
virtual bool resize(size_t sz)=0
Change the size of the vector.
SG::IAuxTypeVector::reserve
virtual void reserve(size_t sz)=0
Change the capacity of the vector.
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
IAuxStore.h
Interface for non-const operations on an auxiliary store.
SG::IAuxTypeVector::setOption
virtual bool setOption(const AuxDataOption &)
Set an option for this variable.
Definition: IAuxTypeVector.h:172
SG::IAuxTypeVector::size
virtual size_t size() const =0
Return the size of the vector.
SG::IAuxTypeVector::toPtr
virtual void * toPtr()=0
Return a pointer to the start of the vector's data.