The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 <string>
8 #include <unordered_set>
9 #include <iostream>
10 #include <mutex>
11 
12 //---------------------------------------------------------------------------
13 
32 //---------------------------------------------------------------------------
33 
34 
35 struct DataObjID_Hasher;
36 class IClassIDSvc;
37 
38 class DataObjID {
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 ) {
61  return lhs.m_hash < rhs.m_hash;
62  }
63 
64  friend bool operator==(const DataObjID& lhs, const DataObjID& rhs ) {
65  return lhs.m_hash == rhs.m_hash;
66  }
67 
68  friend bool operator!=(const DataObjID& lhs, const DataObjID& rhs ) {
69  return !( lhs == rhs );
70  }
71 
72 private:
73 
74  void hashGen();
75  void parse(const std::string& key);
76  void setClid();
77  void setClassName();
78 
79  CLID m_clid {0};
81 
83  std::string m_key {"INVALID"};
84 
85  static void getClidSvc();
88 
89 };
90 
92  m_key(key) {
93  hashGen();
94 
95 }
96 
97 inline DataObjID::DataObjID(const CLID& clid, const std::string& key):
98  m_clid(clid), m_key(key) {
99  setClassName();
100  hashGen();
101 }
102 
103 inline DataObjID::DataObjID(const std::string& className, const std::string& key):
104  m_className(className), m_key(key) {
105  setClid();
106  hashGen();
107 }
108 
109 inline void DataObjID::updateKey(const std::string& key) {
110  m_key = key;
111  hashGen();
112 }
113 
115  std::size_t operator()(const DataObjID& k) const {
116  return k.m_hash;
117  }
118 };
119 
121 
122 namespace Gaudi {
123  namespace Parsers {
126  }
127  namespace Utils {
130  }
131 }
132 
133 
134 #endif
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
Definition: DataObjID.h:120
GAUDI_API std::ostream & toStream(const DataObjIDColl &v, std::ostream &o)
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:68
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:86
void updateKey(const std::string &key)
Definition: DataObjID.h:109
std::string m_key
Definition: DataObjID.h:83
DataObjID()
Definition: DataObjID.h:42
friend DataObjID_Hasher
Definition: DataObjID.h:40
STL class.
static std::once_flag m_ip
Definition: DataObjID.h:87
interface to the CLID database
Definition: IClassIDSvc.h:23
CLID clid() const
Definition: DataObjID.h:54
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
const std::string & key() const
Definition: DataObjID.h:49
CLID m_clid
Definition: DataObjID.h:79
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
std::size_t m_hash
Definition: DataObjID.h:80
static void getClidSvc()
Definition: DataObjID.cpp:23
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:115
void parse(const std::string &key)
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:64
void setClid()
Definition: DataObjID.cpp:29
void setClassName()
Definition: DataObjID.cpp:42
std::string fullKey() const
Definition: DataObjID.cpp:64
#define GAUDI_API
Definition: Kernel.h:107
std::string m_className
Definition: DataObjID.h:82
STL class.
void hashGen()
Definition: DataObjID.cpp:11
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:54