ATLAS Offline Software
Public Member Functions | Private Types | Private Attributes | List of all members
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. More...
 
const std::string * keyToString (StringPool::sgkey_t key, StringPool::sgaux_t &aux) const
 Find the string corresponding to a given key. More...
 
size_t size () const
 Number of registered mappings. More...
 
void clear ()
 Clear data. More...
 
void dump () const
 Debugging dump. Write to stdout. More...
 
bool merge (const StringPoolImpl &other)
 Merge other pool into this one. More...
 

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 }

◆ 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  std::cout << std::hex << std::setw(18) << k << " "
142  << std::dec << std::setw(9) << it->second.first << " "
143  << it->second.second << "\n";
144  }
145 }

◆ 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 155 of file StringPool.cxx.

156 {
157  bool allgood = true;
158  for (const keymap_t::value_type& p : other.m_keymap) {
159  if (!registerKey (p.first, p.second.second, p.second.first)) {
160  allgood = false;
161  }
162  }
163  return allgood;
164 }

◆ 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 {
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 }

◆ 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:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
skel.it
it
Definition: skel.GENtoEVGEN.py:423
SG::StringPoolImpl::pair_t
std::pair< StringPool::sgaux_t, std::string > pair_t
Definition: StringPool.cxx:59
lumiFormat.i
int i
Definition: lumiFormat.py:92
SG::StringPool::sgkey_t
uint32_t sgkey_t
Type of the integer keys.
Definition: StringPool.h:38
SG::StringPoolImpl::registerKey
bool registerKey(StringPool::sgkey_t key, const std::string &str, StringPool::sgaux_t aux)
Remember an additional mapping from key to string.
Definition: StringPool.cxx:73
SG::StringPoolImpl::keymap_t
SG::SGKeyMap< pair_t > keymap_t
Definition: StringPool.cxx:60
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::StringPoolImpl::m_keymap
keymap_t m_keymap
Definition: StringPool.cxx:61
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37