| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes | List of all members
Gaudi::StringKey Class Reference

The helper class to represent the efficient "key" for access. More...

`#include <GaudiKernel/StringKey.h>`

Collaboration diagram for Gaudi::StringKey:
[legend]

## Public Member Functions
| StringKey (const char *key="")
| constructor from plain C-string, perform hashing More...
| StringKey (std::string key)
| constructor from std::string, perform hashing More...
const std::string & | str () const
| the actual string More...
| operator const std::string & () const
| implicit cast to std::string More...
bool | empty () const
| empty key? More...
bool | operator! () const
| empty key? More...
bool | operator== (const StringKey &o) const
| equality Key for efficiency reason compare the hash-values first More...
bool | operator== (const std::string &o) const
| equality, without hashing string rely on the native string equality More...
bool | operator!= (const StringKey &o) const
| non equality Key More...
bool | operator!= (const std::string &o) const
| non-equality string More...
bool | operator< (const StringKey &o) const
| less key It can be used as a key for std::map, e.g. More...
bool | operator> (const StringKey &o) const
| greater key More...
bool | operator<= (const StringKey &o) const
| less or equal key More...
bool | operator>= (const StringKey &o) const
| greater or equal key More...
std::size_t | __hash__ () const
| the actual access to the hash More...
std::string | __str__ () const
| the representation of the object More...
std::string | __repr__ () const
| the representation of the object More...
bool | __eq__ (const StringKey &right) const
| equality operator for python More...
bool | __eq__ (const std::string &right) const
| equality operators for python More...
bool | __neq__ (const StringKey &right) const
| non-equality operator for python More...
bool | __neq__ (const std::string &right) const
| non-equality operator for python More...
std::string | toString () const
| string representation (for properties) More...

## Private Attributes
std::string | m_str
| the actual string: More...
std::size_t | m_hash
| the hash: More...

## Detailed Description

The helper class to represent the efficient "key" for access.

Essentially it is a bit modified version ("boost-free") of the original class stringKey by Gerhard Raven, which is heavily used now in HLT

Attention
  NEVER use the actual hash value for anything stored in files, as it is not guaranteed that the hashing scheme will remain the same.

Author
  Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@n.nosp@m.ikhe.nosp@m.f.nl

Date
  2009-04-08

Definition at line 35 of file StringKey.h.

## Constructor & Destructor Documentation

Gaudi::StringKey::StringKey | ( | const char * | key = `""` | ) |

constructor from plain C-string, perform hashing

Definition at line 26 of file StringKey.cpp.

27 : m_str ( key )
28 , m_hash ( std::hash<std::string>()(m_str) ) // NB! hashing here!!!
29 {}
Gaudi::StringKey::m_hash
std::size_t m_hash
the hash:
Definition: StringKey.h:141
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139
std::hash

Gaudi::StringKey::StringKey | ( | std::string | key | ) |

constructor from std::string, perform hashing

Definition at line 19 of file StringKey.cpp.

20 : m_str ( std::move(key) )
21 , m_hash ( std::hash<std::string>()(m_str) ) // NB! hashing here!!!
22 {}
Gaudi::StringKey::m_hash
std::size_t m_hash
the hash:
Definition: StringKey.h:141
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139
std::hash
std::move
T move(T...args)

## Member Function Documentation

bool Gaudi::StringKey::__eq__ | ( | const StringKey & | right | ) | const

equality operator for python

Definition at line 45 of file StringKey.cpp.

46 { return this == &right || *this == right ; }
std::right
T right(T...args)

bool Gaudi::StringKey::__eq__ | ( | const std::string & | right | ) | const

equality operators for python

Definition at line 50 of file StringKey.cpp.

51 { return *this == right ; }

std::size_t Gaudi::StringKey::__hash__ | ( |  | ) | const
| inline

the actual access to the hash

Attention
  NEVER use the actual hash value for anything stored in files, as it is not guaranteed that the hashing scheme will remain the same. The two reason for this function are:
  - transparent usage of this object for hashmap-like containers
  - Python the actual hash value

Definition at line 116 of file StringKey.h.

116 { return m_hash ; }
Gaudi::StringKey::m_hash
std::size_t m_hash
the hash:
Definition: StringKey.h:141

bool Gaudi::StringKey::__neq__ | ( | const StringKey & | right | ) | const

non-equality operator for python

Definition at line 55 of file StringKey.cpp.

56 { return this != &right && *this != right ; }
std::right
T right(T...args)

bool Gaudi::StringKey::__neq__ | ( | const std::string & | right | ) | const

non-equality operator for python

Definition at line 60 of file StringKey.cpp.

61 { return *this != right ; }

std::string Gaudi::StringKey::__repr__ | ( |  | ) | const

the representation of the object

Definition at line 42 of file StringKey.cpp.

42 { return toString() ; }
Gaudi::StringKey::toString
std::string toString() const
string representation (for properties)
Definition: StringKey.cpp:33

std::string Gaudi::StringKey::__str__ | ( |  | ) | const

the representation of the object

Definition at line 38 of file StringKey.cpp.

38 { return toString() ; }
Gaudi::StringKey::toString
std::string toString() const
string representation (for properties)
Definition: StringKey.cpp:33

bool Gaudi::StringKey::empty | ( |  | ) | const
| inline

empty key?

Definition at line 51 of file StringKey.h.

51 { return m_str.empty() ; }
std::string::empty
T empty(T...args)
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139

Gaudi::StringKey::operator const std::string & | ( |  | ) | const
| inline

implicit cast to std::string

Definition at line 49 of file StringKey.h.

49 { return str() ; }
Gaudi::StringKey::str
const std::string & str() const
the actual string
Definition: StringKey.h:47

bool Gaudi::StringKey::operator! | ( |  | ) | const
| inline

empty key?

Definition at line 53 of file StringKey.h.

53 { return empty() ; }
Gaudi::StringKey::empty
bool empty() const
empty key?
Definition: StringKey.h:51

bool Gaudi::StringKey::operator!= | ( | const StringKey & | o | ) | const
| inline

non equality Key

Definition at line 70 of file StringKey.h.

70 { return !(*this==o) ; }

bool Gaudi::StringKey::operator!= | ( | const std::string & | o | ) | const
| inline

non-equality string

Definition at line 72 of file StringKey.h.

72 { return !(*this==o) ; }

bool Gaudi::StringKey::operator< | ( | const StringKey & | o | ) | const
| inline

less key It can be used as a key for std::map, e.g.

`std::map<StringKey,double>` Note that with such maps one can gain if using prehashed key:

typedef std::map<StringKey,double> MAP ;
const StringKey& key = ... ;
const MAP& m = ... ;
// EFFICIENT:
MAP::const_iterator i1 = m.find ( key ) ;
// CAN BE VERY INEFICIENT:
MAP::const_iterator i2 = m_find( "SomeLongKey,_e.g._TES_Locaiton" );

Definition at line 96 of file StringKey.h.

97 { return m_hash == o.m_hash ? m_str < o.m_str : m_hash < o.m_hash ; }
Gaudi::StringKey::m_hash
std::size_t m_hash
the hash:
Definition: StringKey.h:141
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139

bool Gaudi::StringKey::operator<= | ( | const StringKey & | o | ) | const
| inline

less or equal key

Definition at line 101 of file StringKey.h.

101 { return !(*this > o ) ; }

bool Gaudi::StringKey::operator== | ( | const StringKey & | o | ) | const
| inline

equality Key for efficiency reason compare the hash-values first

Definition at line 60 of file StringKey.h.

61 { return m_hash == o.m_hash && m_str == o.m_str ; }
Gaudi::StringKey::m_hash
std::size_t m_hash
the hash:
Definition: StringKey.h:141
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139

bool Gaudi::StringKey::operator== | ( | const std::string & | o | ) | const
| inline

equality, without hashing string rely on the native string equality

Definition at line 65 of file StringKey.h.

65 { return m_str == o ; }
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139

bool Gaudi::StringKey::operator> | ( | const StringKey & | o | ) | const
| inline

greater key

Definition at line 99 of file StringKey.h.

99 { return o < *this ; }

bool Gaudi::StringKey::operator>= | ( | const StringKey & | o | ) | const
| inline

greater or equal key

Definition at line 103 of file StringKey.h.

103 { return !(*this < o ) ; }

const std::string& Gaudi::StringKey::str | ( |  | ) | const
| inline

the actual string

Definition at line 47 of file StringKey.h.

47 { return m_str ; }
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139

std::string Gaudi::StringKey::toString | ( |  | ) | const

string representation (for properties)

Definition at line 33 of file StringKey.cpp.

34 { return Gaudi::Utils::toString ( m_str ) ; }
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:371
Gaudi::StringKey::m_str
std::string m_str
the actual string:
Definition: StringKey.h:139

## Member Data Documentation

std::size_t Gaudi::StringKey::m_hash
| private

the hash:

Definition at line 141 of file StringKey.h.

std::string Gaudi::StringKey::m_str
| private

the actual string:

Definition at line 139 of file StringKey.h.

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

- GaudiKernel/GaudiKernel/StringKey.h
- GaudiKernel/src/Lib/StringKey.cpp