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)
9 template <typename HANDLE> template <typename OWNER>
10 SysHandleArray<HANDLE>::SysHandleArray(
12 const std::string &propertyName,
13 const std::vector<std::string> &propertyValue,
14 const std::string &propertyDescription)
15 : asg::AsgMessagingForward(owner), m_decorNames(propertyValue)
17 owner->declareProperty(propertyName, m_decorNames, propertyDescription);
20 template <typename HANDLE> template <typename... Args>
21 StatusCode SysHandleArray<HANDLE>::initialize(Args &&...args)
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)
29 // NB: This will fail if the templated class doesn't have the right
31 handles.emplace_back(decor, this);
32 ATH_CHECK(handles.back().initialize(std::forward<Args>(args)...));
34 // If we get here then it all worked OK
35 m_handles = std::move(handles);
36 return StatusCode::SUCCESS;
39 template <typename HANDLE>
40 std::size_t SysHandleArray<HANDLE>::size() const noexcept { return m_decorNames.size(); }
42 template <typename HANDLE>
43 bool SysHandleArray<HANDLE>::empty() const noexcept { return size() == 0; }
45 template <typename HANDLE>
46 HANDLE &SysHandleArray<HANDLE>::at(std::size_t idx)
49 return m_handles.at(idx);
52 template <typename HANDLE>
53 const HANDLE &SysHandleArray<HANDLE>::at(std::size_t idx) const
56 return m_handles.at(idx);
59 template <typename HANDLE>
60 typename SysHandleArray<HANDLE>::iterator SysHandleArray<HANDLE>::begin()
63 return m_handles.begin();
66 template <typename HANDLE>
67 typename SysHandleArray<HANDLE>::iterator SysHandleArray<HANDLE>::end()
70 return m_handles.end();
73 template <typename HANDLE>
74 typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::begin() const
77 return m_handles.begin();
80 template <typename HANDLE>
81 typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::end() const
84 return m_handles.end();
87 template <typename HANDLE>
88 typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::cbegin() const
91 return m_handles.cbegin();
94 template <typename HANDLE>
95 typename SysHandleArray<HANDLE>::const_iterator SysHandleArray<HANDLE>::cend() const
98 return m_handles.cend();
101 template <typename HANDLE>
102 typename SysHandleArray<HANDLE>::reverse_iterator SysHandleArray<HANDLE>::rbegin()
104 requireInitialized();
105 return m_handles.rbegin();
108 template <typename HANDLE>
109 typename SysHandleArray<HANDLE>::reverse_iterator SysHandleArray<HANDLE>::rend()
111 requireInitialized();
112 return m_handles.rend();
115 template <typename HANDLE>
116 typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::rbegin() const
118 requireInitialized();
119 return m_handles.rbegin();
122 template <typename HANDLE>
123 typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::rend() const
125 requireInitialized();
126 return m_handles.rend();
129 template <typename HANDLE>
130 typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::crbegin() const
132 requireInitialized();
133 return m_handles.crbegin();
136 template <typename HANDLE>
137 typename SysHandleArray<HANDLE>::const_reverse_iterator SysHandleArray<HANDLE>::crend() const
139 requireInitialized();
140 return m_handles.crend();
143 template <typename HANDLE>
144 void SysHandleArray<HANDLE>::requireInitialized() const
146 if (m_handles.size() != m_decorNames.size())
147 throw std::logic_error("SysHandleArray not initialized!");
150 } //> end namespace CP