ATLAS Offline Software
Loading...
Searching...
No Matches
SlotSpecificObj.icc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3 */
4
5/**
6 * @file AthenaKernel/SlotSpecificObj.icc
7 * @author scott snyder <snyder@bnl.gov>
8 * @date Jul, 2017
9 * @brief Maintain a set of objects, one per slot.
10 */
11
12
13namespace SG {
14
15
16/**
17 * @brief Constructor.
18 *
19 * The number of slots will be found by calling @c getNSlots().
20 */
21template <class T, InvalidSlot S>
22inline
23SlotSpecificObj<T, S>::SlotSpecificObj()
24 : SlotSpecificObj (getNSlots())
25{
26}
27
28
29/**
30 * @brief Constructor, with number of slots specified explicitly.
31 * @param nslots The number of event slots.
32 */
33template <class T, InvalidSlot S>
34inline
35SlotSpecificObj<T, S>::SlotSpecificObj (size_t nslots)
36 : m_slots (S==InvalidSlot::Disabled ? nslots : nslots+1)
37{
38}
39
40
41/**
42 * @brief Return pointer to the object for slot given by @c ctx.
43 * @param ctx Event context giving the desired slot.
44 */
45template <class T, InvalidSlot S>
46inline
47T* SlotSpecificObj<T, S>::get (const EventContext& ctx)
48{
49 if constexpr (S==InvalidSlot::Disabled) {
50 return &m_slots.at(ctx.slot());
51 }
52 else {
53 return ctx.valid() ? &m_slots.at(ctx.slot()) : &m_slots.back();
54 }
55}
56
57
58/**
59 * @brief Return pointer to the object for the current slot.
60 *
61 * The slot number is found by retrieving the global current context.
62 */
63template <class T, InvalidSlot S>
64inline
65T* SlotSpecificObj<T, S>::get()
66{
67 return get (Gaudi::Hive::currentContext());
68}
69
70
71/**
72 * @brief Return pointer to the object for slot given by @c ctx.
73 * @param ctx Event context giving the desired slot.
74 */
75template <class T, InvalidSlot S>
76inline
77const T* SlotSpecificObj<T, S>::get (const EventContext& ctx) const
78{
79 if constexpr (S==InvalidSlot::Disabled) {
80 return &m_slots.at(ctx.slot());
81 }
82 else {
83 return ctx.valid() ? &m_slots.at(ctx.slot()) : &m_slots.back();
84 }
85}
86
87
88/**
89 * @brief Return pointer to the object for the current slot.
90 *
91 * The slot number is found by retrieving the global current context.
92 */
93template <class T, InvalidSlot S>
94inline
95const T* SlotSpecificObj<T, S>::get() const
96{
97 return get (Gaudi::Hive::currentContext());
98}
99
100
101/**
102 * @brief Dereference the pointer.
103 *
104 * The slot number is found by retrieving the global current context.
105 */
106template <class T, InvalidSlot S>
107inline
108T& SlotSpecificObj<T, S>::operator* ()
109{
110 return *get();
111}
112
113
114/**
115 * @brief Dereference the pointer.
116 *
117 * The slot number is found by retrieving the global current context.
118 */
119template <class T, InvalidSlot S>
120inline
121const T& SlotSpecificObj<T, S>::operator* () const
122{
123 return *get();
124}
125
126
127/**
128 * @brief Dereference the pointer.
129 *
130 * The slot number is found by retrieving the global current context.
131 */
132template <class T, InvalidSlot S>
133inline
134T* SlotSpecificObj<T, S>::operator-> ()
135{
136 return get();
137}
138
139
140/**
141 * @brief Dereference the pointer.
142 *
143 * The slot number is found by retrieving the global current context.
144 */
145template <class T, InvalidSlot S>
146inline
147const T* SlotSpecificObj<T, S>::operator-> () const
148{
149 return get();
150}
151
152
153/**
154 * @brief Begin iterator.
155 */
156template <class T, InvalidSlot S>
157inline
158typename SlotSpecificObj<T, S>::iterator SlotSpecificObj<T, S>::begin()
159{
160 return m_slots.begin();
161}
162
163
164/**
165 * @brief Const begin iterator.
166 */
167template <class T, InvalidSlot S>
168inline
169typename SlotSpecificObj<T, S>::const_iterator SlotSpecificObj<T, S>::begin() const
170{
171 return m_slots.begin();
172}
173
174
175/**
176 * @brief End iterator.
177 */
178template <class T, InvalidSlot S>
179inline
180typename SlotSpecificObj<T, S>::iterator SlotSpecificObj<T, S>::end()
181{
182 return m_slots.end();
183}
184
185
186/**
187 * @brief Const end iterator.
188 */
189template <class T, InvalidSlot S>
190inline
191typename SlotSpecificObj<T, S>::const_iterator SlotSpecificObj<T, S>::end() const
192{
193 return m_slots.end();
194}
195
196
197} // namespace SG