The Gaudi Framework  v29r0 (ff2e7097)
DataObjID.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATAOBJID
2 #define GAUDIKERNEL_DATAOBJID 1
3 
4 #include "GaudiKernel/ClassID.h"
6 
7 #include <iostream>
8 #include <mutex>
9 #include <string>
10 #include <unordered_set>
11 
12 //---------------------------------------------------------------------------
13 
32 //---------------------------------------------------------------------------
33 
34 struct DataObjID_Hasher;
35 class IClassIDSvc;
36 
37 class DataObjID
38 {
39 public:
41 
42  DataObjID(){};
43  DataObjID( const std::string& key );
44  DataObjID( const CLID& clid, const std::string& key );
45  DataObjID( const std::string& className, const std::string& key );
46  DataObjID( const DataObjID& ) = default;
47 
48  // only return the last part of the key
49  const std::string& key() const { return m_key; }
50 
51  // combination of the key and the ClassName, mostly for debugging
52  std::string fullKey() const;
53 
54  CLID clid() const { return m_clid; }
55 
56  void updateKey( const std::string& key );
57 
58  friend std::ostream& operator<<( std::ostream& str, const DataObjID& d );
59 
60  friend bool operator<( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash < rhs.m_hash; }
61 
62  friend bool operator==( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash == rhs.m_hash; }
63 
64  friend bool operator!=( const DataObjID& lhs, const DataObjID& rhs ) { return !( lhs == rhs ); }
65 
66 private:
67  void hashGen();
68  void parse( const std::string& key );
69  void setClid();
70  void setClassName();
71 
74 
76  std::string m_key{"INVALID"};
77 
78  static void getClidSvc();
81 };
82 
83 inline DataObjID::DataObjID( const std::string& key ) : m_key( key ) { hashGen(); }
84 
85 inline DataObjID::DataObjID( const CLID& clid, const std::string& key ) : m_clid( clid ), m_key( key )
86 {
87  setClassName();
88  hashGen();
89 }
90 
91 inline DataObjID::DataObjID( const std::string& className, const std::string& key )
92  : m_className( className ), m_key( key )
93 {
94  setClid();
95  hashGen();
96 }
97 
98 inline void DataObjID::updateKey( const std::string& key )
99 {
100  m_key = key;
101  hashGen();
102 }
103 
105  std::size_t operator()( const DataObjID& k ) const { return k.m_hash; }
106 };
107 
109 
110 namespace Gaudi
111 {
112  namespace Parsers
113  {
116  }
117  namespace Utils
118  {
121  }
122 }
123 
124 #endif
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
Definition: DataObjID.h:108
GAUDI_API std::ostream & toStream(const DataObjIDColl &v, std::ostream &o)
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:64
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:79
void updateKey(const std::string &key)
Definition: DataObjID.h:98
std::string m_key
Definition: DataObjID.h:76
DataObjID()
Definition: DataObjID.h:42
friend DataObjID_Hasher
Definition: DataObjID.h:40
STL class.
static std::once_flag m_ip
Definition: DataObjID.h:80
interface to the CLID database
Definition: IClassIDSvc.h:24
CLID clid() const
Definition: DataObjID.h:54
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
const std::string & key() const
Definition: DataObjID.h:49
CLID m_clid
Definition: DataObjID.h:72
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
std::size_t m_hash
Definition: DataObjID.h:73
static void getClidSvc()
Definition: DataObjID.cpp:21
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:105
void parse(const std::string &key)
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:62
void setClid()
Definition: DataObjID.cpp:23
void setClassName()
Definition: DataObjID.cpp:34
std::string fullKey() const
Definition: DataObjID.cpp:54
#define GAUDI_API
Definition: Kernel.h:110
std::string m_className
Definition: DataObjID.h:75
STL class.
void hashGen()
Definition: DataObjID.cpp:10
Helper functions to set/get the application return code.
Definition: __init__.py:1
friend bool operator<(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:60
friend std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:44