| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

GaudiHistoID.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_GAUDIHISTOID_H
2 #define GAUDIALG_GAUDIHISTOID_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD&STL
7 // ============================================================================
8 #include <string>
9 // ============================================================================
10 // GaudiKernel
11 // ============================================================================
12 #include "GaudiKernel/Kernel.h"
13 #include "GaudiKernel/Hash.h"
14 // ============================================================================
15 /* @file
16 *
17 * Header file for class GaudiAlg::ID
18 *
19 * @author Chris Jones Christopher.Rob.Jones@cern.ch
20 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru
21 * @date 2004-01-23
22 */
23 // ============================================================================
32 // ============================================================================
33 namespace GaudiAlg
34 {
35 // ==========================================================================
44 class GAUDI_API ID
45 {
46 public:
47 // ========================================================================
49 typedef int NumericID;
51 typedef std::string LiteralID;
52 // ========================================================================
53 public:
54 // ========================================================================
56 ID ( const NumericID id = -1 )
57 : m_nID ( id )
58 , m_hash ( boost::hash_value ( id ) ) { }
60 ID ( LiteralID&& id )
61 : m_aID ( std::move(id) )
62 , m_hash ( boost::hash_value ( m_aID ) ) { }
64 ID ( const LiteralID& id )
65 : m_aID ( id )
66 , m_hash ( boost::hash_value ( m_aID ) ) { }
68 ID ( const char* id )
69 : m_aID ( id )
70 , m_hash ( boost::hash_value ( m_aID ) ) { }
72 ~ID ( ) = default;
74 inline bool numeric () const noexcept { return -1 != m_nID ; }
76 inline bool literal () const noexcept { return !m_aID.empty() ; }
78 inline bool undefined () const noexcept { return !numeric() && !literal(); }
80 inline const LiteralID& literalID() const noexcept { return m_aID; }
82 inline NumericID numericID() const noexcept { return m_nID; }
84 GAUDI_API LiteralID idAsString() const ;
86 operator std::string () const { return idAsString () ; }
91 inline bool operator==( const ID& id ) const noexcept
92 {
93 return
94 hash () != id.hash () ? false :
95 numeric () && id.numeric () ? id.numericID () == numericID () :
96 literal () && id.literal () ? id.literalID () == literalID () :
97 idAsString () == id.idAsString() ;
98 }
100 inline bool operator!=( const ID& id ) const { return ! ( *this == id ) ; }
105 inline bool operator<( const ID& id ) const noexcept
106 {
107 return
108 //hash () < id.hash () ? true :
109 //hash () > id.hash () ? false :
110 numeric () && id.numeric() ? numericID() < id.numericID() :
111 literal () && id.literal() ? literalID() < id.literalID() :
112 idAsString () < id.idAsString() ;
113 }
114 // ========================================================================
115 GAUDI_API std::ostream& fillStream ( std::ostream& s ) const ;
116 // ========================================================================
117 public:
118 // ========================================================================
120 bool operator!() const noexcept { return undefined() ; }
121 // ========================================================================
122 public:
123 // ========================================================================
125 inline size_t hash () const noexcept { return m_hash ; }
127 inline size_t __hash__ () const noexcept { return hash () ; }
128 // ========================================================================
129 private:
130 // ========================================================================
132 NumericID m_nID{-1} ; // Internal numeric ID
134 LiteralID m_aID ; // Internal alpha-numeric ID
135 // ========================================================================
136 private:
137 // ========================================================================
139 size_t m_hash{0} ; // the hash value of ID
140 // ========================================================================
141 };
142 // ==========================================================================
144 inline std::ostream& operator << ( std::ostream& str , const GaudiAlg::ID& id )
145 { return id.fillStream ( str ) ; }
146 // ==========================================================================
147 } // end of namespace GaudiAlg
148 // ============================================================================
149 namespace GaudiUtils
150 {
151 // ==========================================================================
153 template <>
154 inline size_t Hash<GaudiAlg::ID>::operator()
155 ( const GaudiAlg::ID& key ) const { return key.hash () ; }
156 // ==========================================================================
157 } // end of namespace GaudiUtils
158 // ============================================================================
159 // The END
160 // ============================================================================
161 #endif // GAUDIALG_GAUDIHISTOID_H
162 // ============================================================================
GaudiAlg::ID::ID
ID(const LiteralID &id)
Implicit &#39;copy&#39; constructor from a literal ID.
Definition: GaudiHistoID.h:64
GaudiAlg::ID::operator!
bool operator!() const noexcept
good ID?
Definition: GaudiHistoID.h:120
GaudiAlg::ID::operator==
bool operator==(const ID &id) const noexcept
Implement the operator == Implementation depends on type of ID.
Definition: GaudiHistoID.h:91
Kernel.h
GaudiAlg::ID::ID
ID(LiteralID &&id)
Implicit &#39;move&#39; constructor from a literal ID.
Definition: GaudiHistoID.h:60
boost
The namespace threadpool contains a thread pool and related utility classes.
Definition: iter_pos.hpp:13
GaudiAlg::ID::numericID
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:82
GaudiAlg::ID::NumericID
int NumericID
type for internal numeric ID
Definition: GaudiHistoID.h:49
std
STL namespace.
GaudiAlg::ID::operator!=
bool operator!=(const ID &id) const
Implement the != operator, using the == operator.
Definition: GaudiHistoID.h:100
GaudiAlg::ID::operator<
bool operator<(const ID &id) const noexcept
Implement the operator < Implementation depends on type of ID.
Definition: GaudiHistoID.h:105
std::string
STL class.
Gaudi::hash_value
std::size_t hash_value(const Gaudi::StringKey &key)
hash-function: heeded for boost::hash
Definition: StringKey.h:216
GaudiAlg::ID::__hash__
size_t __hash__() const noexcept
return hash value (for python)
Definition: GaudiHistoID.h:127
GaudiAlg::ID::ID
ID(const NumericID id=-1)
Implicit constructor from a numeric ID.
Definition: GaudiHistoID.h:56
GaudiUtils::Hash
Simple hash function.
Definition: Hash.h:96
GaudiAlg::ID::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:76
GaudiAlg::ID::LiteralID
std::string LiteralID
type for internal literal ID
Definition: GaudiHistoID.h:51
GaudiUtils
Forward declarations for the functions in SerializeSTL.h.
Definition: GaudiHistoID.h:149
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:80
gaudirun.s
string s
Definition: gaudirun.py:245
GaudiAlg::ID::m_aID
LiteralID m_aID
Internal alpha-numeric ID.
Definition: GaudiHistoID.h:134
GaudiAlg::ID::numeric
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:74
GaudiAlg::ID::hash
size_t hash() const noexcept
return hash value (for python)
Definition: GaudiHistoID.h:125
GaudiAlg::ID::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:78
Hash.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
GaudiAlg
GaudiAlg.h GaudiAlg/GaudiAlg.h Namespace with definition of useful constants, types and function...
std::ostream
STL class.
GaudiAlg::ID
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:44
GaudiAlg::operator<<
std::ostream & operator<<(std::ostream &str, const GaudiAlg::ID &id)
Operator overloading for ostream.
Definition: GaudiHistoID.h:144
GaudiAlg::ID::ID
ID(const char *id)
Implicit constructor from a literal ID.
Definition: GaudiHistoID.h:68