ATLAS Offline Software
Loading...
Searching...
No Matches
SG::StringPoolImpl Class Reference
Collaboration diagram for SG::StringPoolImpl:

Public Member Functions

bool registerKey (StringPool::sgkey_t key, const std::string &str, StringPool::sgaux_t aux)
 Remember an additional mapping from key to string.
const std::string * keyToString (StringPool::sgkey_t key, StringPool::sgaux_t &aux) const
 Find the string corresponding to a given key.
size_t size () const
 Number of registered mappings.
void clear ()
 Clear data.
void dump () const
 Debugging dump. Write to stdout.
bool merge (const StringPoolImpl &other)
 Merge other pool into this one.

Private Types

typedef std::pair< StringPool::sgaux_t, std::string > pair_t
typedef SG::SGKeyMap< pair_tkeymap_t

Private Attributes

keymap_t m_keymap

Detailed Description

Definition at line 33 of file StringPool.cxx.

Member Typedef Documentation

◆ keymap_t

Definition at line 60 of file StringPool.cxx.

◆ pair_t

typedef std::pair<StringPool::sgaux_t, std::string> SG::StringPoolImpl::pair_t
private

Definition at line 59 of file StringPool.cxx.

Member Function Documentation

◆ clear()

void SG::StringPoolImpl::clear ( )

Clear data.

Definition at line 123 of file StringPool.cxx.

124{
125 keymap_t().swap (m_keymap);
126}
SG::SGKeyMap< pair_t > keymap_t

◆ dump()

void SG::StringPoolImpl::dump ( ) const

Debugging dump. Write to stdout.

Debugging dump.

Write to cout.

Definition at line 132 of file StringPool.cxx.

133{
134 std::vector<StringPool::sgkey_t> keys;
135 keys.reserve (m_keymap.size());
136 for (const keymap_t::value_type& p : m_keymap)
137 keys.push_back (p.first);
138 std::sort (keys.begin(), keys.end());
139 for (StringPool::sgkey_t k : keys) {
140 keymap_t::const_iterator it = m_keymap.find (k);
141 if (it != m_keymap.end()) {
142 std::cout << std::hex << std::setw(18) << k << " "
143 << std::dec << std::setw(9) << it->second.first << " "
144 << it->second.second << "\n";
145 }
146 }
147}
uint32_t sgkey_t
Type of the integer keys.
Definition StringPool.h:38
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ keyToString()

const std::string * SG::StringPoolImpl::keyToString ( StringPool::sgkey_t key,
StringPool::sgaux_t & aux ) const

Find the string corresponding to a given key.

Parameters
keyThe key to look up.
aux[out]Auxiliary data associated with the key.
Returns
Pointer to the string found, or null. We can find keys as long as the corresponding string was given to either stringToKey() or registerKey().

Definition at line 99 of file StringPool.cxx.

101{
102 StringPoolImpl::keymap_t::const_iterator i = m_keymap.find (key);
103 if (i != m_keymap.end()) {
104 aux = i->second.first;
105 return &i->second.second;
106 }
107 return 0;
108}

◆ merge()

bool SG::StringPoolImpl::merge ( const StringPoolImpl & other)

Merge other pool into this one.

Merge another pool into this one.

Parameters
otherThe other pool to merge into this one.

In case of collisions, the colliding entries are skipped, and false is returned. If no collisions, then true is returned.

Definition at line 157 of file StringPool.cxx.

158{
159 bool allgood = true;
160 for (const keymap_t::value_type& p : other.m_keymap) {
161 if (!registerKey (p.first, p.second.second, p.second.first)) {
162 allgood = false;
163 }
164 }
165 return allgood;
166}
bool registerKey(StringPool::sgkey_t key, const std::string &str, StringPool::sgaux_t aux)
Remember an additional mapping from key to string.

◆ registerKey()

bool SG::StringPoolImpl::registerKey ( StringPool::sgkey_t key,
const std::string & str,
StringPool::sgaux_t aux )

Remember an additional mapping from key to string.

Parameters
keyThe key to enter.
strThe string to enter.
auxAuxiliary data to include along with the string.
Returns
True if successful; false if the key already corresponds to a different string.

Definition at line 73 of file StringPool.cxx.

76{
77 StringPoolImpl::keymap_t::iterator i = m_keymap.find (key);
78 if (i == m_keymap.end()) {
79 pair_t& p = m_keymap[key];
80 p.first = aux;
81 p.second = str;
82 }
83 else if (i->second.first != aux || i->second.second != str) {
84 return false;
85 }
86 return true;
87}
std::pair< StringPool::sgaux_t, std::string > pair_t

◆ size()

size_t SG::StringPoolImpl::size ( ) const

Number of registered mappings.

Definition at line 114 of file StringPool.cxx.

115{
116 return m_keymap.size();
117}

Member Data Documentation

◆ m_keymap

keymap_t SG::StringPoolImpl::m_keymap
private

Definition at line 61 of file StringPool.cxx.


The documentation for this class was generated from the following file: