|
Gaudi Framework, version v21r8 |
| Home | Generated: 17 Mar 2010 |
00001 // $Id: 00002 // ============================================================================ 00003 #ifndef GAUDIALG_GAUDIHISTOID_H 00004 #define GAUDIALG_GAUDIHISTOID_H 1 00005 // ============================================================================ 00006 // Include files 00007 // ============================================================================ 00008 // STD&STL 00009 // ============================================================================ 00010 #include <string> 00011 // ============================================================================ 00012 // GaudiKernel 00013 // ============================================================================ 00014 #include "GaudiKernel/Kernel.h" 00015 #include "GaudiKernel/Hash.h" 00016 // ============================================================================ 00017 /* @file 00018 * 00019 * Header file for class GaudiAlg::ID 00020 * 00021 * @author Chris Jones Christopher.Rob.Jones@cern.ch 00022 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 00023 * @date 2004-01-23 00024 */ 00025 // ============================================================================ 00034 // ============================================================================ 00035 namespace GaudiAlg 00036 { 00037 // ========================================================================== 00046 class GAUDI_API ID 00047 { 00048 public: 00049 // ======================================================================== 00051 typedef int NumericID; 00053 typedef std::string LiteralID; 00054 // ======================================================================== 00055 public: 00056 // ======================================================================== 00058 ID ( const NumericID id = -1 ) ; 00060 ID ( const LiteralID& id ) ; 00062 ID ( const char* id ) ; 00064 ~ID ( ) {} ; 00066 inline bool numeric () const { return -1 != m_nID ; } 00068 inline bool literal () const { return !m_aID.empty() ; } 00070 inline bool undefined () const { return !numeric() && !literal(); } 00072 inline const LiteralID& literalID() const { return m_aID; } 00074 inline NumericID numericID() const { return m_nID; } 00076 GAUDI_API LiteralID idAsString() const ; 00078 operator std::string () const { return idAsString () ; } 00083 inline bool operator==( const ID& id ) const 00084 { 00085 return 00086 hash () != id.hash () ? false : 00087 numeric () && id.numeric () ? id.numericID () == numericID () : 00088 literal () && id.literal () ? id.literalID () == literalID () : 00089 idAsString () == id.idAsString() ; 00090 } 00092 inline bool operator!=( const ID& id ) const { return ! ( *this == id ) ; } 00097 inline bool operator<( const ID& id ) const 00098 { 00099 return 00100 //hash () < id.hash () ? true : 00101 //hash () > id.hash () ? false : 00102 numeric () && id.numeric() ? numericID() < id.numericID() : 00103 literal () && id.literal() ? literalID() < id.literalID() : 00104 idAsString () < id.idAsString() ; 00105 } 00106 // ======================================================================== 00107 GAUDI_API std::ostream& fillStream ( std::ostream& s ) const ; 00108 // ======================================================================== 00109 public: 00110 // ======================================================================== 00112 bool operator!() const { return undefined() ; } 00113 // ======================================================================== 00114 public: 00115 // ======================================================================== 00117 inline size_t hash () const { return m_hash ; } 00119 inline size_t __hash__ () const { return hash () ; } 00120 // ======================================================================== 00121 private: 00122 // ======================================================================== 00124 NumericID m_nID ; // Internal numeric ID 00126 LiteralID m_aID ; // Internal alpha-numeric ID 00127 // ======================================================================== 00128 private: 00129 // ======================================================================== 00131 size_t m_hash ; // the hash value of ID 00132 // ======================================================================== 00133 }; 00134 // ========================================================================== 00136 inline std::ostream& operator << ( std::ostream& str , const GaudiAlg::ID& id ) 00137 { return id.fillStream ( str ) ; } 00138 // ========================================================================== 00139 } // end of namespace GaudiAlg 00140 // ============================================================================ 00141 namespace GaudiUtils 00142 { 00143 // ========================================================================== 00145 template <> 00146 inline size_t Hash<GaudiAlg::ID>::operator() 00147 ( const GaudiAlg::ID& key ) const { return key.hash () ; } 00148 // ========================================================================== 00149 } // end of namespace GaudiUtils 00150 // ============================================================================ 00151 // The END 00152 // ============================================================================ 00153 #endif // GAUDIALG_GAUDIHISTOID_H 00154 // ============================================================================