ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictGroup.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef IDDICT_IdDictGroup_H
6#define IDDICT_IdDictGroup_H
7
8#include <string>
9#include <string_view>
10#include <vector>
11#include <variant>
12#include <utility>
13#include <memory>
14
15class IdDictDictEntry;
16class IdDictRegion;
17class IdDictMgr;
20class Identifier;
22class MultiRange;
23
24
25
27public:
28 // ==================================
29 //** @name Constructor/destructor
30 // @{
31
32 IdDictGroup ();
33 IdDictGroup (const std::string& name);
34 ~IdDictGroup ();
35
36 IdDictGroup (const IdDictGroup&) = delete;
38
39
41 // ==================================
42 //** @name Simple accessors.
43 // @{
44
45 const std::string& name() const;
46 size_t n_regions() const;
47 const IdDictRegion& region(size_t index) const;
48
49
51 // ==================================
52 //** @name Methods used to initialize the object.
53 // @{
54
56 const std::vector<IdDictRegion*>& regions();
57
60
61 void add_dictentry (std::unique_ptr<IdDictDictEntry> entry);
62
64 IdDictDictionary& dictionary,
65 size_t& index);
66 void generate_implementation (const IdDictMgr& idd,
67 IdDictDictionary& dictionary,
68 std::string_view tag = "");
69 void reset_implementation ();
70 bool verify () const;
71 void sort ();
72 void clear ();
73
74
84 int unpack (const Identifier& id,
85 const ExpandedIdentifier& prefix,
86 size_t index2,
87 ExpandedIdentifier& unpackedId,
88 std::vector<const IdDictFieldImplementation*>* impls = nullptr) const;
89
93 void build_region_tree();
94
95
99 void dump() const;
100
101
105 void dump_regions() const;
106
107
111 void dump_tree() const;
112
113
114private:
121 void add_tree_field (const IdDictRegion& re, unsigned ifield, unsigned inode);
122
123 std::string m_name;
124 std::vector<std::unique_ptr<IdDictDictEntry> > m_entries; // just the RegionEntries
125 std::vector<IdDictRegion*> m_regions; // regions derived from entries
127
128
194 void optimize();
195
198
203 std::unique_ptr<std::vector<const IdDictFieldImplementation*> > m_other_impls;
204
213 using ChildPair = std::pair<size_t, unsigned>;
214 std::variant<std::vector<unsigned>, ChildPair> m_children;
215
217 // of an identifier.
218 static constexpr unsigned END = static_cast<unsigned> (-1);
219 };
220
221 std::vector<IdDictRegionTreeNode> m_region_tree;
222};
223
224
225inline
226const std::string& IdDictGroup::name() const {
227 return m_name;
228}
229
230
231inline
233{
234 return m_regions.size();
235}
236
237
238inline
240{
241 return *m_regions.at(index);
242}
243
244
245#endif
const boost::regex re(r_e)
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
const std::vector< IdDictRegion * > & regions()
Non-const access to regions.
bool m_generated_implementation
IdDictGroup(const IdDictGroup &)=delete
std::vector< IdDictRegionTreeNode > m_region_tree
The list of region nodes.
void add_dictentry(std::unique_ptr< IdDictDictEntry > entry)
std::vector< std::unique_ptr< IdDictDictEntry > > m_entries
void build_region_tree()
Take the list of regions and build a tree structure for fast unpacking.
std::string m_name
int unpack(const Identifier &id, const ExpandedIdentifier &prefix, size_t index2, ExpandedIdentifier &unpackedId, std::vector< const IdDictFieldImplementation * > *impls=nullptr) const
Unpack the value_type id to an expanded Identifier, considering the provided prefix (result will incl...
size_t n_regions() const
void sort()
Sort:
void dump_tree() const
Dump the tree structure built from the regions for fast unpacking.
std::vector< IdDictRegion * > m_regions
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, std::string_view tag="")
void dump_regions() const
Dump the list of regions for this group.
void reset_implementation()
const IdDictRegion & region(size_t index) const
void add_tree_field(const IdDictRegion &re, unsigned ifield, unsigned inode)
Recursively add new nodes to the tree structure.
IdDictGroup & operator=(const IdDictGroup &)=delete
MultiRange build_multirange() const
Get MultiRange for this group.
const std::string & name() const
void dump() const
Dump regions and tree for this group.
void resolve_references(IdDictMgr &idd, IdDictDictionary &dictionary, size_t &index)
bool verify() const
A MultiRange combines several Ranges.
Definition MultiRange.h:17
Definition index.py:1
std::pair< size_t, unsigned > ChildPair
References to child nodes.
const IdDictFieldImplementation & m_impl
Reference to the the implementation field.
std::variant< std::vector< unsigned >, ChildPair > m_children
std::unique_ptr< std::vector< const IdDictFieldImplementation * > > m_other_impls
Implementations for other field descriptions that this ored field of the identifier may contain.
void optimize()
Compress the vector of node indices, if they are all the same.
static constexpr unsigned END
Special value used to indicate that we've reached the end.
IdDictRegionTreeNode(const IdDictFieldImplementation &impl)
Constructor, taking a reference to the implementation.