All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gaudi::StringKey Class Reference

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

#include </scratch/z5/marcocle/lhcb-release/419/GAUDI/GAUDI_v26r1/InstallArea/x86_64-slc6-gcc48-opt/include/GaudiKernel/StringKey.h>

Collaboration diagram for Gaudi::StringKey:

Public Member Functions

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

Private Attributes

std::string m_str
 the actual string:
 
std::size_t m_hash
 the hash:
 

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 32 of file StringKey.cpp.

: m_str ( key )
, m_hash ( boost::hash_value( m_str ) ) // NB! hashing here!!!
{}
Gaudi::StringKey::StringKey ( const std::string &  key)

constructor from std::string, perform hashing

Definition at line 25 of file StringKey.cpp.

: m_str ( key )
, m_hash ( boost::hash_value( m_str ) ) // NB! hashing here!!!
{}
Gaudi::StringKey::StringKey ( const char *  key = "")

constructor from plain C-string, perform hashing

Gaudi::StringKey::StringKey ( const std::string &  key)

constructor from std::string, perform hashing

Member Function Documentation

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

equality operator for python

Definition at line 51 of file StringKey.cpp.

{ return this == &right || *this == right ; }
bool Gaudi::StringKey::__eq__ ( const StringKey right) const

equality operator for python

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

equality operators for python

Definition at line 56 of file StringKey.cpp.

{ return *this == right ; }
bool Gaudi::StringKey::__eq__ ( const std::string &  right) const

equality operators for python

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.

{ return m_hash ; }
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.

{ return m_hash ; }
bool Gaudi::StringKey::__neq__ ( const StringKey right) const

non-equality operator for python

Definition at line 61 of file StringKey.cpp.

{ return this != &right && *this != right ; }
bool Gaudi::StringKey::__neq__ ( const StringKey right) const

non-equality operator for python

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

non-equality operator for python

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

non-equality operator for python

Definition at line 66 of file StringKey.cpp.

{ return *this != right ; }
std::string Gaudi::StringKey::__repr__ ( ) const

the representation of the object

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

the representation of the object

Definition at line 48 of file StringKey.cpp.

{ return toString() ; }
std::string Gaudi::StringKey::__str__ ( ) const

the representation of the object

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

the representation of the object

Definition at line 44 of file StringKey.cpp.

{ return toString() ; }
bool Gaudi::StringKey::empty ( ) const
inline

empty key?

Definition at line 51 of file StringKey.h.

{ return m_str.empty() ; }
bool Gaudi::StringKey::empty ( ) const
inline

empty key?

Definition at line 51 of file StringKey.h.

{ return m_str.empty() ; }
Gaudi::StringKey::operator const std::string & ( ) const
inline

implicit cast to std::string

Definition at line 49 of file StringKey.h.

{ return str() ; }
Gaudi::StringKey::operator const std::string & ( ) const
inline

implicit cast to std::string

Definition at line 49 of file StringKey.h.

{ return str() ; }
bool Gaudi::StringKey::operator! ( ) const
inline

empty key?

Definition at line 53 of file StringKey.h.

{ return empty() ; }
bool Gaudi::StringKey::operator! ( ) const
inline

empty key?

Definition at line 53 of file StringKey.h.

{ return empty() ; }
bool Gaudi::StringKey::operator!= ( const StringKey o) const
inline

non equality Key

Definition at line 70 of file StringKey.h.

{ return !(*this==o) ; }
bool Gaudi::StringKey::operator!= ( const StringKey o) const
inline

non equality Key

Definition at line 70 of file StringKey.h.

{ return !(*this==o) ; }
bool Gaudi::StringKey::operator!= ( const std::string &  o) const
inline

non-equality string

Definition at line 72 of file StringKey.h.

{ return !(*this==o) ; }
bool Gaudi::StringKey::operator!= ( const std::string &  o) const
inline

non-equality string

Definition at line 72 of file StringKey.h.

{ 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.

{ return m_hash == o.m_hash ? m_str < o.m_str : m_hash < o.m_hash ; }
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.

{ return m_hash == o.m_hash ? m_str < o.m_str : m_hash < o.m_hash ; }
bool Gaudi::StringKey::operator<= ( const StringKey o) const
inline

less or equal key

Definition at line 101 of file StringKey.h.

{ return !(*this > o ) ; }
bool Gaudi::StringKey::operator<= ( const StringKey o) const
inline

less or equal key

Definition at line 101 of file StringKey.h.

{ 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.

{ return m_hash == o.m_hash && m_str == o.m_str ; }
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.

{ return m_hash == o.m_hash && m_str == o.m_str ; }
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.

{ return m_str == o ; }
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.

{ return m_str == o ; }
bool Gaudi::StringKey::operator> ( const StringKey o) const
inline

greater key

Definition at line 99 of file StringKey.h.

{ return o < *this ; }
bool Gaudi::StringKey::operator> ( const StringKey o) const
inline

greater key

Definition at line 99 of file StringKey.h.

{ return o < *this ; }
bool Gaudi::StringKey::operator>= ( const StringKey o) const
inline

greater or equal key

Definition at line 103 of file StringKey.h.

{ return !(*this < o ) ; }
bool Gaudi::StringKey::operator>= ( const StringKey o) const
inline

greater or equal key

Definition at line 103 of file StringKey.h.

{ return !(*this < o ) ; }
const std::string& Gaudi::StringKey::str ( ) const
inline

the actual string

Definition at line 47 of file StringKey.h.

{ return m_str ; }
const std::string& Gaudi::StringKey::str ( ) const
inline

the actual string

Definition at line 47 of file StringKey.h.

{ return m_str ; }
std::string Gaudi::StringKey::toString ( ) const

string representation (for properties)

Definition at line 39 of file StringKey.cpp.

{ return Gaudi::Utils::toString ( m_str ) ; }
std::string Gaudi::StringKey::toString ( ) const

string representation (for properties)

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: