ATLAS Offline Software
Loading...
Searching...
No Matches
StringPool.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 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4*/
22
23#ifndef SGTOOLS_STRINGPOOL_H
24#define SGTOOLS_STRINGPOOL_H
25
26#include <stdint.h>
27#include <string>
28#include <memory>
29
30namespace SG {
31
32class StringPoolImpl;
33
34class StringPool
35{
36public:
38 typedef uint32_t sgkey_t;
39
41 typedef unsigned int sgaux_t;
42
45 static const int sgkey_t_nbits = 30;
46 static const sgkey_t sgkey_t_max =
47 (static_cast<sgkey_t>(1) << sgkey_t_nbits) - 1;
48
50 StringPool();
51
53 ~StringPool();
54
56 StringPool (const StringPool& other);
57 StringPool (StringPool&& other);
58
60 StringPool& operator= (const StringPool& other);
61 StringPool& operator= (StringPool&& other);
62
72 sgkey_t stringToKey (const std::string& str, sgaux_t aux = 0);
73
81 const std::string* keyToString (sgkey_t key) const;
82
91 const std::string* keyToString (sgkey_t key, sgaux_t& aux) const;
92
104 bool registerKey (sgkey_t key,
105 const std::string& str,
106 sgaux_t aux = 0);
107
108
112 size_t size() const;
113
117 void dump() const;
118
119
123 void clear();
124
125
133 bool merge (const StringPool& other);
134
135
136private:
137 std::unique_ptr<StringPoolImpl> m_impl;
138};
139
140
141} // namespace SG
142
143
144#endif // not SGTOOLS_STRINGPOOL_H
size_t size() const
Number of registered mappings.
bool registerKey(sgkey_t key, const std::string &str, sgaux_t aux=0)
Remember an additional mapping from key to string.
std::unique_ptr< StringPoolImpl > m_impl
Definition StringPool.h:137
const std::string * keyToString(sgkey_t key) const
Find the string corresponding to a given key.
sgkey_t stringToKey(const std::string &str, sgaux_t aux=0)
void clear()
Empty the pool.
Forward declaration.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
-event-from-file
Definition merge.py:1
setEventNumber uint32_t