ATLAS Offline Software
Loading...
Searching...
No Matches
RDOCollectionAdapter.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4#ifndef ACTSTRK_RDOCOLLECTIONADAPTER_H
5#define ACTSTRK_RDOCOLLECTIONADAPTER_H
6
7namespace ActsTrk {
8 // helper class to adapt different RDO collections to have the same interface
9 // forward declaration needs dedicated implementation
10 template <typename T_RDOContainer>
12 const T_RDOContainer::base_value_type *m_RDOs;
13 public:
14 RDOCollectionAdapter(const typename T_RDOContainer::base_value_type *RDOs)
15 : m_RDOs(RDOs)
16 {}
17 RDOCollectionAdapter(const typename T_RDOContainer::base_value_type &RDOs)
18 : m_RDOs(&RDOs)
19 {}
20 // test whether this object can be dereferenced to return the representation of a single module.
21 bool isValid() const {
22 return m_RDOs!=nullptr;
23 }
24 operator bool() const { return isValid();}
25 // dereferencing will return a representation of one module.
26 const typename T_RDOContainer::base_value_type &operator*() const {
27 assert(m_RDOs);
28 return *m_RDOs;
29 }
30 // return a pointer to the representation of one module.
31 const typename T_RDOContainer::base_value_type *operator->() const {
32 assert(m_RDOs);
33 return m_RDOs;
34 }
35 // check whether the RDO collection represented by this object is empty.
36 // @TODO or rather implement operator-> ? That would give this adapter a more consistent interface
37 // since it rather represents a pointer to an object than an object.
38 bool empty() const {
39 assert(m_RDOs);
40 return m_RDOs->empty();
41 }
42 // result represents the module of the given id_hash when dereferenced.
43 // @note must only be dereferenced if isValid is true.
44 static std::optional<RDOCollectionAdapter> make(const T_RDOContainer &rdo_container,const IdentifierHash &id_hash) {
45 const typename T_RDOContainer::base_value_type *RDOs = rdo_container.indexFindPtr(id_hash);
46 if (RDOs) { return RDOCollectionAdapter(*RDOs); }
47 else { return std::optional<RDOCollectionAdapter>{}; }
48 }
49 // result represents an iterable range where each element represents one module
50 static const T_RDOContainer &range(const T_RDOContainer &rdo_container) {
51 return rdo_container;
52 }
53 };
54
55}
56#endif
RDOCollectionAdapter(const typename T_RDOContainer::base_value_type *RDOs)
const T_RDOContainer::base_value_type * m_RDOs
const T_RDOContainer::base_value_type * operator->() const
static const T_RDOContainer & range(const T_RDOContainer &rdo_container)
const T_RDOContainer::base_value_type & operator*() const
RDOCollectionAdapter(const typename T_RDOContainer::base_value_type &RDOs)
static std::optional< RDOCollectionAdapter > make(const T_RDOContainer &rdo_container, const IdentifierHash &id_hash)
This is a "hash" representation of an Identifier.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...