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-2026 CERN for the benefit of the ATLAS collaboration
5*/
12
13
14#ifndef ATHCONTAINERS_VIEWVECTORBASE_H
15#define ATHCONTAINERS_VIEWVECTORBASE_H
16
17
19#include "AthLinks/ElementLinkBase.h"
20#include "SGCore/sgkey_t.h"
21#include <vector>
22#include <cstdint>
23
24
25class ViewVectorBaseTest;
26
27
28namespace SG {
29
30
37{
38public:
40 virtual ~ViewVectorBase() = default;
41
42
46 virtual void toPersistent() = 0;
47
48
52 virtual void toTransient() = 0;
53
54
59
60
69
70
71protected:
78 template <class DV>
79 void doToPersistent1 (DV& v, const std::true_type&);
80
81
89 template <class DV>
90 void doToPersistent1 (DV&, const std::false_type&);
91
92
99 template <class DV>
100 void doToPersistent (DV& v);
101
102
109 template <class DV>
110 void doToTransient2 (DV& v, const std::true_type&);
111
112
119 template <class DV>
120 void doToTransient2 (DV&, const std::false_type&) {}
121
122
129 template <class DV>
130 void doToTransient1 (DV& v, const std::true_type&)
131 {
132 doToTransient2 (v, std::is_same<DV, typename DV::base_data_vector>());
133 }
134
135
145 template <class DV>
146 void doToTransient1 (DV&, const std::false_type&) {}
147
148
155 template <class DV>
156 void doToTransient (DV& v)
157 {
158#ifdef XAOD_STANDALONE
159 doToTransient1 (v, std::true_type());
160#else
162#endif
163 }
164
165
166private:
167 // For unit testing.
168 friend class ::ViewVectorBaseTest;
169
171 std::vector<sgkey_t> m_persKey;
172 std::vector<unsigned int> m_persIndex;
173
176};
177
178
179} // namespace SG
180
181
183
184
185#endif // not ATHCONTAINERS_VIEWVECTORBASE_H
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.