| The Gaudi Framework v29r1 (5cd95fa2)

- 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/Hash.h"
13 #include "GaudiKernel/Kernel.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 ) : m_nID( id ), m_hash( boost::hash_value( id ) ) {}
58 ID( LiteralID&& id ) : m_aID( std::move( id ) ), m_hash( boost::hash_value( m_aID ) ) {}
60 ID( const LiteralID& id ) : m_aID( id ), m_hash( boost::hash_value( m_aID ) ) {}
62 ID( const char* id ) : m_aID( id ), m_hash( boost::hash_value( m_aID ) ) {}
64 ~ID() = default;
66 inline bool numeric() const noexcept { return -1 != m_nID; }
68 inline bool literal() const noexcept { return !m_aID.empty(); }
70 inline bool undefined() const noexcept { return !numeric() && !literal(); }
72 inline const LiteralID& literalID() const noexcept { return m_aID; }
74 inline NumericID numericID() const noexcept { return m_nID; }
76 GAUDI_API LiteralID idAsString() const;
78 operator std::string() const { return idAsString(); }
83 inline bool operator==( const ID& id ) const noexcept
84 {
85 return hash() != id.hash()
86 ? false
87 : numeric() && id.numeric()
88 ? id.numericID() == numericID()
89 : literal() && id.literal() ? id.literalID() == literalID() : idAsString() == id.idAsString();
90 }
92 inline bool operator!=( const ID& id ) const { return !( *this == id ); }
97 inline bool operator<( const ID& id ) const noexcept
98 {
99 return
100 // hash () < id.hash () ? true :
101 // hash () > id.hash () ? false :
102 numeric() && id.numeric()
103 ? numericID() < id.numericID()
104 : literal() && id.literal() ? literalID() < id.literalID() : idAsString() < id.idAsString();
105 }
106 // ========================================================================
107 GAUDI_API std::ostream& fillStream( std::ostream& s ) const;
108 // ========================================================================
109 public:
110 // ========================================================================
112 bool operator!() const noexcept { return undefined(); }
113 // ========================================================================
114 public:
115 // ========================================================================
117 inline size_t hash() const noexcept { return m_hash; }
119 inline size_t __hash__() const noexcept { return hash(); }
120 // ========================================================================
121 private:
122 // ========================================================================
124 NumericID m_nID{-1}; // Internal numeric ID
126 LiteralID m_aID; // Internal alpha-numeric ID
127 // ========================================================================
128 private:
129 // ========================================================================
131 size_t m_hash{0}; // the hash value of ID
132 // ========================================================================
133 };
134 // ==========================================================================
136 inline std::ostream& operator<<( std::ostream& str, const GaudiAlg::ID& id ) { return id.fillStream( str ); }
137 // ==========================================================================
138 } // end of namespace GaudiAlg
139 // ============================================================================
140 namespace GaudiUtils
141 {
142 // ==========================================================================
144 template <>
145 inline size_t Hash<GaudiAlg::ID>::operator()( const GaudiAlg::ID& key ) const
146 {
147 return key.hash();
148 }
149 // ==========================================================================
150 } // end of namespace GaudiUtils
151 // ============================================================================
152 // The END
153 // ============================================================================
154 #endif // GAUDIALG_GAUDIHISTOID_H
155 // ============================================================================
GaudiAlg::ID::ID
ID(const LiteralID &id)
Implicit &#39;copy&#39; constructor from a literal ID.
Definition: GaudiHistoID.h:60
GaudiAlg::ID::operator!
bool operator!() const noexcept
good ID?
Definition: GaudiHistoID.h:112
GaudiAlg::ID::operator==
bool operator==(const ID &id) const noexcept
Implement the operator == Implementation depends on type of ID.
Definition: GaudiHistoID.h:83
Kernel.h
GaudiAlg::ID::ID
ID(LiteralID &&id)
Implicit &#39;move&#39; constructor from a literal ID.
Definition: GaudiHistoID.h:58
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:74
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:92
GaudiAlg::ID::operator<
bool operator<(const ID &id) const noexcept
Implement the operator < Implementation depends on type of ID.
Definition: GaudiHistoID.h:97
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:207
GaudiAlg::ID::__hash__
size_t __hash__() const noexcept
return hash value (for python)
Definition: GaudiHistoID.h:119
GaudiAlg::ID::ID
ID(const NumericID id=-1)
Implicit constructor from a numeric ID.
Definition: GaudiHistoID.h:56
GaudiAlg::ID::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:68
GaudiAlg::ID::LiteralID
std::string LiteralID
type for internal literal ID
Definition: GaudiHistoID.h:51
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
GaudiUtils
Forward declarations for the functions in SerializeSTL.h.
Definition: GaudiHistoID.h:140
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:72
gaudirun.s
string s
Definition: gaudirun.py:253
GaudiAlg::ID::m_aID
LiteralID m_aID
Internal alpha-numeric ID.
Definition: GaudiHistoID.h:126
GaudiAlg::ID::numeric
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
GaudiAlg::ID::hash
size_t hash() const noexcept
return hash value (for python)
Definition: GaudiHistoID.h:117
GaudiAlg::ID::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:70
Hash.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
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:136
GaudiAlg::ID::ID
ID(const char *id)
Implicit constructor from a literal ID.
Definition: GaudiHistoID.h:62