ATLAS Offline Software
Loading...
Searching...
No Matches
SlotSpecificObj.icc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration.
3 */
4// $Id$
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
13#include <cassert>
14
15
16namespace SG {
17
18
19/**
20 * @brief Constructor.
21 *
22 * The number of slots will be found by calling @c getNSlots().
23 */
24template <class T>
25inline
26SlotSpecificObj<T>::SlotSpecificObj()
27 : SlotSpecificObj (getNSlots())
28{
29}
30
31
32/**
33 * @brief Constructor, with number of slots specified explicitly.
34 * @param nslots The number of event slots.
35 */
36template <class T>
37inline
38SlotSpecificObj<T>::SlotSpecificObj (size_t nslots)
39 : m_slots (nslots)
40{
41}
42
43
44/**
45 * @brief Return pointer to the object for slot given by @c ctx.
46 * @param ctx Event context giving the desired slot.
47 */
48template <class T>
49inline
50T* SlotSpecificObj<T>::get (const EventContext& ctx)
51{
52 size_t slot = ctx.slot();
53 assert (slot < m_slots.size());
54 return &m_slots[slot];
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>
64inline
65T* SlotSpecificObj<T>::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>
76inline
77const T* SlotSpecificObj<T>::get (const EventContext& ctx) const
78{
79 size_t slot = ctx.slot();
80 assert (slot < m_slots.size());
81 return &m_slots[slot];
82}
83
84
85/**
86 * @brief Return pointer to the object for the current slot.
87 *
88 * The slot number is found by retrieving the global current context.
89 */
90template <class T>
91inline
92const T* SlotSpecificObj<T>::get() const
93{
94 return get (Gaudi::Hive::currentContext());
95}
96
97
98/**
99 * @brief Dereference the pointer.
100 *
101 * The slot number is found by retrieving the global current context.
102 */
103template <class T>
104inline
105T& SlotSpecificObj<T>::operator* ()
106{
107 return *get();
108}
109
110
111/**
112 * @brief Dereference the pointer.
113 *
114 * The slot number is found by retrieving the global current context.
115 */
116template <class T>
117inline
118const T& SlotSpecificObj<T>::operator* () const
119{
120 return *get();
121}
122
123
124/**
125 * @brief Dereference the pointer.
126 *
127 * The slot number is found by retrieving the global current context.
128 */
129template <class T>
130inline
131T* SlotSpecificObj<T>::operator-> ()
132{
133 return get();
134}
135
136
137/**
138 * @brief Dereference the pointer.
139 *
140 * The slot number is found by retrieving the global current context.
141 */
142template <class T>
143inline
144const T* SlotSpecificObj<T>::operator-> () const
145{
146 return get();
147}
148
149
150/**
151 * @brief Begin iterator.
152 */
153template <class T>
154inline
155typename SlotSpecificObj<T>::iterator SlotSpecificObj<T>::begin()
156{
157 return m_slots.begin();
158}
159
160
161/**
162 * @brief Const begin iterator.
163 */
164template <class T>
165inline
166typename SlotSpecificObj<T>::const_iterator SlotSpecificObj<T>::begin() const
167{
168 return m_slots.begin();
169}
170
171
172/**
173 * @brief End iterator.
174 */
175template <class T>
176inline
177typename SlotSpecificObj<T>::iterator SlotSpecificObj<T>::end()
178{
179 return m_slots.end();
180}
181
182
183/**
184 * @brief Const end iterator.
185 */
186template <class T>
187inline
188typename SlotSpecificObj<T>::const_iterator SlotSpecificObj<T>::end() const
189{
190 return m_slots.end();
191}
192
193
194} // namespace SG