ATLAS Offline Software
Loading...
Searching...
No Matches
ViewVectorBase.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/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
12
13
14#ifndef ATHCONTAINERS_VIEWVECTORBASE_H
15#define ATHCONTAINERS_VIEWVECTORBASE_H
16
17
20#include "AthLinks/ElementLinkBase.h"
21#include "SGCore/sgkey_t.h"
22#include <vector>
23#include <cstdint>
24
25
26class ViewVectorBaseTest;
27
28
29namespace SG {
30
31
38{
39public:
41 virtual ~ViewVectorBase() = default;
42
43
47 virtual void toPersistent() = 0;
48
49
53 virtual void toTransient() = 0;
54
55
60
61
70
71
72protected:
79 template <class DV>
80 void doToPersistent1 (DV& v, const std::true_type&);
81
82
90 template <class DV>
91 void doToPersistent1 (DV&, const std::false_type&);
92
93
100 template <class DV>
101 void doToPersistent (DV& v);
102
103
110 template <class DV>
111 void doToTransient2 (DV& v, const std::true_type&);
112
113
120 template <class DV>
121 void doToTransient2 (DV&, const std::false_type&) {}
122
123
130 template <class DV>
131 void doToTransient1 (DV& v, const std::true_type&)
132 {
133 doToTransient2 (v, std::is_same<DV, typename DV::base_data_vector>());
134 }
135
136
146 template <class DV>
147 void doToTransient1 (DV&, const std::false_type&) {}
148
149
156 template <class DV>
157 void doToTransient (DV& v)
158 {
159#ifdef XAOD_STANDALONE
160 doToTransient1 (v, std::true_type());
161#else
163#endif
164 }
165
166
167private:
168 // For unit testing.
169 friend class ::ViewVectorBaseTest;
170
172 std::vector<sgkey_t> m_persKey;
173 std::vector<unsigned int> m_persIndex;
174
177};
178
179
180} // namespace SG
181
182
184
185
186#endif // not ATHCONTAINERS_VIEWVECTORBASE_H
Wrapper for CurrentEventStore, to do the correct thing for both Athena and standalone builds.
Hold the persistent representation for a ViewVector.
void doToPersistent(DV &v)
Convert to persistent form.
void doToTransient1(DV &, const std::false_type &)
Convert to transient form.
void doToPersistent1(DV &v, const std::true_type &)
Convert to persistent form.
void clearPersistent()
Clear the persistent data.
void doToTransient1(DV &v, const std::true_type &)
Convert to persistent form.
virtual void toPersistent()=0
Convert the vector to persistent form.
void doToTransient2(DV &v, const std::true_type &)
Convert to transient form.
std::vector< unsigned int > m_persIndex
void doToTransient2(DV &, const std::false_type &)
Convert to transient form.
virtual ~ViewVectorBase()=default
Destructor.
virtual void toTransient()=0
Convert the vector to transient form.
void setClearOnPersistent()
Set a flag to declare that the vector should be cleared on the next call to toPersistent().
void doToTransient(DV &v)
Convert to persistent form.
bool m_clearOnPersistent
If true, the vector should be cleared when doPersistent is called.
void doToPersistent1(DV &, const std::false_type &)
Convert to persistent form.
std::vector< sgkey_t > m_persKey
The persistent form. (sgkey, index)
Helper to make a vector<EL> from a DataVector.
Forward declaration.