The Gaudi Framework  v31r0 (aeb156f0)
GaudiAlg::ID Class Reference

ID class for Histogram and Ntuples. More...

#include <GaudiAlg/GaudiHistoID.h>

Collaboration diagram for GaudiAlg::ID:

Public Types

typedef int NumericID
 type for internal numeric ID More...
 
typedef std::string LiteralID
 type for internal literal ID More...
 

Public Member Functions

 ID (const NumericID id=-1)
 Implicit constructor from a numeric ID. More...
 
 ID (LiteralID &&id)
 Implicit 'move' constructor from a literal ID. More...
 
 ID (const LiteralID &id)
 Implicit 'copy' constructor from a literal ID. More...
 
 ID (const char *id)
 Implicit constructor from a literal ID. More...
 
 ~ID ()=default
 Destructor. More...
 
bool numeric () const noexcept
 Is this ID numeric. More...
 
bool literal () const noexcept
 Is this ID numeric. More...
 
bool undefined () const noexcept
 Is this ID undefined. More...
 
const LiteralIDliteralID () const noexcept
 Returns the ID as a LiteralID. More...
 
NumericID numericID () const noexcept
 Returns the numerical ID. More...
 
GAUDI_API LiteralID idAsString () const
 Return ID as string, for both numeric and literal IDs. More...
 
 operator std::string () const
 cast operator to std::string More...
 
bool operator== (const ID &id) const noexcept
 Implement the operator == Implementation depends on type of ID. More...
 
bool operator!= (const ID &id) const
 Implement the != operator, using the == operator. More...
 
bool operator< (const ID &id) const noexcept
 Implement the operator < Implementation depends on type of ID. More...
 
GAUDI_API std::ostreamfillStream (std::ostream &s) const
 
bool operator! () const noexcept
 good ID? More...
 
size_t hash () const noexcept
 return hash value (for python) More...
 
size_t __hash__ () const noexcept
 return hash value (for python) More...
 

Private Attributes

NumericID m_nID {-1}
 Internal numeric ID. More...
 
LiteralID m_aID
 Internal alpha-numeric ID. More...
 
size_t m_hash {0}
 the hash value of ID More...
 

Detailed Description

ID class for Histogram and Ntuples.

Internally handles both numeric and string like IDs

Author
Chris Jones Chris.nosp@m.toph.nosp@m.er.Ro.nosp@m.b.Jo.nosp@m.nes@c.nosp@m.ern..nosp@m.ch
Date
2005-08-12

Definition at line 43 of file GaudiHistoID.h.

Member Typedef Documentation

type for internal literal ID

Definition at line 49 of file GaudiHistoID.h.

type for internal numeric ID

Definition at line 47 of file GaudiHistoID.h.

Constructor & Destructor Documentation

GaudiAlg::ID::ID ( const NumericID  id = -1)
inline

Implicit constructor from a numeric ID.

Definition at line 54 of file GaudiHistoID.h.

54 : m_nID( id ), m_hash( boost::hash_value( id ) ) {}
size_t m_hash
the hash value of ID
Definition: GaudiHistoID.h:127
NumericID m_nID
Internal numeric ID.
Definition: GaudiHistoID.h:120
std::size_t hash_value(TupleID const &b)
Definition: TupleID.h:23
GaudiAlg::ID::ID ( LiteralID &&  id)
inline

Implicit 'move' constructor from a literal ID.

Definition at line 56 of file GaudiHistoID.h.

56 : m_aID( std::move( id ) ), m_hash( boost::hash_value( m_aID ) ) {}
size_t m_hash
the hash value of ID
Definition: GaudiHistoID.h:127
std::size_t hash_value(TupleID const &b)
Definition: TupleID.h:23
T move(T...args)
LiteralID m_aID
Internal alpha-numeric ID.
Definition: GaudiHistoID.h:122
GaudiAlg::ID::ID ( const LiteralID id)
inline

Implicit 'copy' constructor from a literal ID.

Definition at line 58 of file GaudiHistoID.h.

58 : m_aID( id ), m_hash( boost::hash_value( m_aID ) ) {}
size_t m_hash
the hash value of ID
Definition: GaudiHistoID.h:127
std::size_t hash_value(TupleID const &b)
Definition: TupleID.h:23
LiteralID m_aID
Internal alpha-numeric ID.
Definition: GaudiHistoID.h:122
GaudiAlg::ID::ID ( const char *  id)
inline

Implicit constructor from a literal ID.

Definition at line 60 of file GaudiHistoID.h.

60 : m_aID( id ), m_hash( boost::hash_value( m_aID ) ) {}
size_t m_hash
the hash value of ID
Definition: GaudiHistoID.h:127
std::size_t hash_value(TupleID const &b)
Definition: TupleID.h:23
LiteralID m_aID
Internal alpha-numeric ID.
Definition: GaudiHistoID.h:122
GaudiAlg::ID::~ID ( )
default

Destructor.

Member Function Documentation

size_t GaudiAlg::ID::__hash__ ( ) const
inlinenoexcept

return hash value (for python)

Definition at line 115 of file GaudiHistoID.h.

115 { return hash(); }
size_t hash() const noexcept
return hash value (for python)
Definition: GaudiHistoID.h:113
std::ostream & GaudiAlg::ID::fillStream ( std::ostream s) const

Definition at line 28 of file GaudiHistoID.cpp.

28  {
29  if ( numeric() ) {
30  s << numericID();
31  } else if ( literal() ) {
32  s << literalID();
33  } else {
34  s << "UNDEFINED";
35  }
36  return s;
37 }
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:72
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:70
string s
Definition: gaudirun.py:312
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:64
size_t GaudiAlg::ID::hash ( ) const
inlinenoexcept

return hash value (for python)

Definition at line 113 of file GaudiHistoID.h.

113 { return m_hash; }
size_t m_hash
the hash value of ID
Definition: GaudiHistoID.h:127
GaudiAlg::ID::LiteralID GaudiAlg::ID::idAsString ( ) const

Return ID as string, for both numeric and literal IDs.

Definition at line 20 of file GaudiHistoID.cpp.

20  {
22  fillStream( s );
23  return s.str();
24 }
GAUDI_API std::ostream & fillStream(std::ostream &s) const
string s
Definition: gaudirun.py:312
bool GaudiAlg::ID::literal ( ) const
inlinenoexcept

Is this ID numeric.

Definition at line 66 of file GaudiHistoID.h.

66 { return !m_aID.empty(); }
T empty(T...args)
LiteralID m_aID
Internal alpha-numeric ID.
Definition: GaudiHistoID.h:122
const LiteralID& GaudiAlg::ID::literalID ( ) const
inlinenoexcept

Returns the ID as a LiteralID.

Definition at line 70 of file GaudiHistoID.h.

70 { return m_aID; }
LiteralID m_aID
Internal alpha-numeric ID.
Definition: GaudiHistoID.h:122
bool GaudiAlg::ID::numeric ( ) const
inlinenoexcept

Is this ID numeric.

Definition at line 64 of file GaudiHistoID.h.

64 { return -1 != m_nID; }
NumericID m_nID
Internal numeric ID.
Definition: GaudiHistoID.h:120
NumericID GaudiAlg::ID::numericID ( ) const
inlinenoexcept

Returns the numerical ID.

Definition at line 72 of file GaudiHistoID.h.

72 { return m_nID; }
NumericID m_nID
Internal numeric ID.
Definition: GaudiHistoID.h:120
GaudiAlg::ID::operator std::string ( ) const
inline

cast operator to std::string

Definition at line 76 of file GaudiHistoID.h.

76 { return idAsString(); }
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
bool GaudiAlg::ID::operator! ( ) const
inlinenoexcept

good ID?

Definition at line 108 of file GaudiHistoID.h.

108 { return undefined(); }
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:68
bool GaudiAlg::ID::operator!= ( const ID id) const
inline

Implement the != operator, using the == operator.

Definition at line 89 of file GaudiHistoID.h.

89 { return !( *this == id ); }
bool GaudiAlg::ID::operator< ( const ID id) const
inlinenoexcept

Implement the operator < Implementation depends on type of ID.

Returns
boolean indicating the order of the IDs

Definition at line 94 of file GaudiHistoID.h.

94  {
95  return
96  // hash () < id.hash () ? true :
97  // hash () > id.hash () ? false :
98  numeric() && id.numeric()
99  ? numericID() < id.numericID()
100  : literal() && id.literal() ? literalID() < id.literalID() : idAsString() < id.idAsString();
101  }
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:72
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:70
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:64
bool GaudiAlg::ID::operator== ( const ID id) const
inlinenoexcept

Implement the operator == Implementation depends on type of ID.

Returns
boolean indicating if the IDs are equal

Definition at line 81 of file GaudiHistoID.h.

81  {
82  return hash() != id.hash()
83  ? false
84  : numeric() && id.numeric()
85  ? id.numericID() == numericID()
86  : literal() && id.literal() ? id.literalID() == literalID() : idAsString() == id.idAsString();
87  }
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:72
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:70
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:64
size_t hash() const noexcept
return hash value (for python)
Definition: GaudiHistoID.h:113
bool GaudiAlg::ID::undefined ( ) const
inlinenoexcept

Is this ID undefined.

Definition at line 68 of file GaudiHistoID.h.

68 { return !numeric() && !literal(); }
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:64

Member Data Documentation

LiteralID GaudiAlg::ID::m_aID
private

Internal alpha-numeric ID.

Definition at line 122 of file GaudiHistoID.h.

size_t GaudiAlg::ID::m_hash {0}
private

the hash value of ID

Definition at line 127 of file GaudiHistoID.h.

NumericID GaudiAlg::ID::m_nID {-1}
private

Internal numeric ID.

Definition at line 120 of file GaudiHistoID.h.


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