ATLAS Offline Software
SysHandleArray.icc
Go to the documentation of this file.
1 namespace CP {
2  template <typename HANDLE> template <typename OWNER>
3  SysHandleArray<HANDLE>::SysHandleArray(
4  OWNER *owner, const std::vector<std::string> &values)
5  : asg::AsgMessagingForward(owner), m_decorNames(values)
6  {
7  }
8 
9  template <typename HANDLE> template <typename OWNER>
10  SysHandleArray<HANDLE>::SysHandleArray(
11  OWNER *owner,
12  const std::string &propertyName,
13  const std::vector<std::string> &propertyValue,
14  const std::string &propertyDescription)
15  : asg::AsgMessagingForward(owner), m_decorNames(propertyValue)
16  {
17  owner->declareProperty(propertyName, m_decorNames, propertyDescription);
18  }
19 
20  template <typename HANDLE> template <typename... Args>
21  StatusCode SysHandleArray<HANDLE>::initialize(Args &&...args)
22  {
23  // Build the list of handles separate to the data member so that it isn't
24  // partially initialized if there's a failure
25  std::vector<HANDLE> handles;
26  handles.reserve(m_decorNames.size());
27  for (const std::string &decor : m_decorNames)
28  {
29  // NB: This will fail if the templated class doesn't have the right
30  // constructor
31  handles.emplace_back(decor, this);
32  ATH_CHECK(handles.back().initialize(std::forward<Args>(args)...));
33  }
34  // If we get here then it all worked OK
35  m_handles = std::move(handles);
36  return StatusCode::SUCCESS;
37  }
38 
39  template <typename HANDLE>
40  std::size_t SysHandleArray<HANDLE>::size() const noexcept { return m_decorNames.size(); }
41 
42  template <typename HANDLE>
43  bool SysHandleArray<HANDLE>::empty() const noexcept { return size() == 0; }
44 
45  template <typename HANDLE>
46  HANDLE &SysHandleArray<HANDLE>::at(std::size_t idx)
47  {
48  requireInitialized();
49  return m_handles.at(idx);
50  }
51 
52  template <typename HANDLE>
53  const HANDLE &SysHandleArray<HANDLE>::at(std::size_t idx) const
54  {
55  requireInitialized();
56  return m_handles.at(idx);
57  }
58 
59  template <typename HANDLE>
60  typename SysHandleArray<HANDLE>::iterator SysHandleArray<HANDLE>::begin()
61  {
62  requireInitialized();
63  return m_handles.begin();
64  }
65 
66  template <typename HANDLE>
67  typename SysHandleArray<HANDLE>::iterator SysHandleArray<HANDLE>::end()
68  {
69  requireInitialized();
70  return m_handles.end();
71  }
72 
73  template <typename HANDLE>
74  typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::begin() const
75  {
76  requireInitialized();
77  return m_handles.begin();
78  }
79 
80  template <typename HANDLE>
81  typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::end() const
82  {
83  requireInitialized();
84  return m_handles.end();
85  }
86 
87  template <typename HANDLE>
88  typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::cbegin() const
89  {
90  requireInitialized();
91  return m_handles.cbegin();
92  }
93 
94  template <typename HANDLE>
95  typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::cend() const
96  {
97  requireInitialized();
98  return m_handles.cend();
99  }
100 
101  template <typename HANDLE>
102  typename SysHandleArray<HANDLE>::reverse_iterator SysHandleArray<HANDLE>::rbegin()
103  {
104  requireInitialized();
105  return m_handles.rbegin();
106  }
107 
108  template <typename HANDLE>
109  typename SysHandleArray<HANDLE>::reverse_iterator SysHandleArray<HANDLE>::rend()
110  {
111  requireInitialized();
112  return m_handles.rend();
113  }
114 
115  template <typename HANDLE>
116  typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::rbegin() const
117  {
118  requireInitialized();
119  return m_handles.rbegin();
120  }
121 
122  template <typename HANDLE>
123  typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::rend() const
124  {
125  requireInitialized();
126  return m_handles.rend();
127  }
128 
129  template <typename HANDLE>
130  typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::crbegin() const
131  {
132  requireInitialized();
133  return m_handles.crbegin();
134  }
135 
136  template <typename HANDLE>
137  typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::crend() const
138  {
139  requireInitialized();
140  return m_handles.crend();
141  }
142 
143  template <typename HANDLE>
144  void SysHandleArray<HANDLE>::requireInitialized() const
145  {
146  if (m_handles.size() != m_decorNames.size())
147  throw std::logic_error("SysHandleArray not initialized!");
148  }
149 
150 } //> end namespace CP