ATLAS Offline Software
Loading...
Searching...
No Matches
IndexMap.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3/*
4 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5*/
6
7// $Id$
21
22
23#ifndef D3PDMAKERUTILS_INDEXMAP_HPP
24#define D3PDMAKERUTILS_INDEXMAP_HPP
25
26
29#include "GaudiKernel/IIncidentListener.h"
30#include "GaudiKernel/ToolHandle.h"
31#include <string>
32#include <vector>
33#include <unordered_map>
34
35
36namespace D3PD {
37
38
40
41
43 : public implements<IIncidentListener>
44{
45public:
54 IndexMap (INamedInterface* parent,
55 const std::string& targetLabel,
56 ToolHandle<ICollectionGetterRegistryTool>& registry,
57 const bool& allowMissing);
58
59
72 IndexMap (INamedInterface* parent,
73 const std::string& targetLabel,
74 const std::vector<std::string>& targetLabels,
75 ToolHandle<ICollectionGetterRegistryTool>& registry,
76 const bool& allowMissing);
77
78
85 IndexMap (INamedInterface* parent,
86 ToolHandleArray<ICollectionGetterTool>& getters,
87 const bool& allowMissing);
88
89
93 StatusCode configureD3PD ();
94
95
100 StatusCode configureD3PD (const std::type_info& ti);
101
102
105
106
108 ICollectionGetterTool* target (unsigned int i);
109
110
112 int ntargets();
113
114
116 virtual void handle (const Incident &inc);
117
118
120 StatusCode reset();
121
122
129 int findIndex (const void* p);
130
131
140 int findIndex (const void* p, unsigned int i);
141
142
149 std::pair<int, int> findIndexPair (const void* p);
150
151
153 bool valid() const;
154
155
159 std::string formatLabels() const;
160
161
162private:
164 StatusCode configureCommon ();
165
166
168 INamedInterface* m_parent;
169
171 const std::string* m_targetLabel;
172
175 const std::vector<std::string>* m_targetLabels;
176
178 ToolHandle<ICollectionGetterRegistryTool>* m_registry;
179
181 ToolHandleArray<ICollectionGetterTool>* m_getters;
182
184 const bool& m_allowMissing;
185
187 std::vector<ICollectionGetterTool*> m_targets;
188
190 typedef std::unordered_multimap<const void*, std::pair<int, int> > map_t;
192
195
197 std::vector<TypeConverter> m_converters;
198};
199
200
201} // namespace D3PD
202
203
204
205#endif // not D3PDMAKERUTILS_INDEXMAP_HPP
Abstract interface to keep a registry of collection getter tools.
Helper to convert pointers.
Abstract interface to get a collection of objects and iterate over it.
ToolHandleArray< ICollectionGetterTool > * m_getters
Property for a direct list of getters.
Definition IndexMap.h:181
std::vector< ICollectionGetterTool * > m_targets
Getters defining the collections within which to index.
Definition IndexMap.h:187
const bool & m_allowMissing
Property for the allowMissing flag.
Definition IndexMap.h:184
std::vector< TypeConverter > m_converters
Converter for each target.
Definition IndexMap.h:197
ICollectionGetterTool * target()
Return the getter defining the first collection within which to index.
Definition IndexMap.cxx:175
std::unordered_multimap< const void *, std::pair< int, int > > map_t
The pointer -> (index,target) map.
Definition IndexMap.h:190
int ntargets()
Return the number of valid targets.
Definition IndexMap.cxx:199
const std::string * m_targetLabel
Property for the label of the getter defining the target collection.
Definition IndexMap.h:171
std::string formatLabels() const
Return list of all configured targets as a comma-separated string.
Definition IndexMap.cxx:325
bool m_valid
Flag if the map is valid.
Definition IndexMap.h:194
std::pair< int, int > findIndexPair(const void *p)
Find the (index,container) pair corresponding to an element.
Definition IndexMap.cxx:293
virtual void handle(const Incident &inc)
Incident handler.
Definition IndexMap.cxx:214
StatusCode configureD3PD()
Configure during initialization: type-check.
Definition IndexMap.cxx:137
StatusCode reset()
Call before asking for an index. Rebuilds cache if needed.
Definition IndexMap.cxx:227
INamedInterface * m_parent
The parent tool.
Definition IndexMap.h:168
IndexMap(INamedInterface *parent, const std::string &targetLabel, ToolHandle< ICollectionGetterRegistryTool > &registry, const bool &allowMissing)
Constructor: for a single target.
Definition IndexMap.cxx:31
int findIndex(const void *p)
Find the index corresponding to an element.
Definition IndexMap.cxx:255
ToolHandle< ICollectionGetterRegistryTool > * m_registry
Property for the ICollectionGetterRegistryTool instance.
Definition IndexMap.h:178
bool valid() const
Return the valid flag.
Definition IndexMap.cxx:316
StatusCode configureCommon()
Common part of configuration.
Definition IndexMap.cxx:97
const std::vector< std::string > * m_targetLabels
Property for the label of the getter defining the list of target collections.
Definition IndexMap.h:175
Block filler tool for noisy FEB information.