ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictGroup.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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 <vector>
10#include <variant>
11#include <utility>
12#include <memory>
13
14class IdDictDictEntry;
15class IdDictRegion;
16class IdDictMgr;
19class Identifier;
21class MultiRange;
22
23
24
26public:
27 // ==================================
28 //** @name Constructor/destructor
29 // @{
30
31 IdDictGroup ();
32 IdDictGroup (const std::string& name);
33 ~IdDictGroup ();
34
35 IdDictGroup (const IdDictGroup&) = delete;
37
38
40 // ==================================
41 //** @name Simple accessors.
42 // @{
43
44 const std::string& name() const;
45 size_t n_regions() const;
46 const IdDictRegion& region(size_t index) const;
47
48
50 // ==================================
51 //** @name Methods used to initialize the object.
52 // @{
53
55 const std::vector<IdDictRegion*>& regions();
56
59
60 void add_dictentry (std::unique_ptr<IdDictDictEntry> entry);
61
63 IdDictDictionary& dictionary,
64 size_t& index);
65 void generate_implementation (const IdDictMgr& idd,
66 IdDictDictionary& dictionary,
67 const std::string& tag = "");
68 void reset_implementation ();
69 bool verify () const;
70 void sort ();
71 void clear ();
72
73
83 int unpack (const Identifier& id,
84 const ExpandedIdentifier& prefix,
85 size_t index2,
86 ExpandedIdentifier& unpackedId,
87 std::vector<const IdDictFieldImplementation*>* impls = nullptr) const;
88
92 void build_region_tree();
93
94
98 void dump() const;
99
100
104 void dump_regions() const;
105
106
110 void dump_tree() const;
111
112
113private:
120 void add_tree_field (const IdDictRegion& re, unsigned ifield, unsigned inode);
121
122 std::string m_name;
123 std::vector<std::unique_ptr<IdDictDictEntry> > m_entries; // just the RegionEntries
124 std::vector<IdDictRegion*> m_regions; // regions derived from entries
126
127
193 void optimize();
194
197
202 std::unique_ptr<std::vector<const IdDictFieldImplementation*> > m_other_impls;
203
212 using ChildPair = std::pair<size_t, unsigned>;
213 std::variant<std::vector<unsigned>, ChildPair> m_children;
214
216 // of an identifier.
217 static constexpr unsigned END = static_cast<unsigned> (-1);
218 };
219
220 std::vector<IdDictRegionTreeNode> m_region_tree;
221};
222
223
224inline
225const std::string& IdDictGroup::name() const {
226 return m_name;
227}
228
229
230inline
232{
233 return m_regions.size();
234}
235
236
237inline
239{
240 return *m_regions.at(index);
241}
242
243
244#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 dump_regions() const
Dump the list of regions for this group.
void reset_implementation()
const IdDictRegion & region(size_t index) const
void generate_implementation(const IdDictMgr &idd, IdDictDictionary &dictionary, const std::string &tag="")
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.