| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

DataObjID.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATAOBJID
2 #define GAUDIKERNEL_DATAOBJID 1
3
4 #include "GaudiKernel/ClassID.h"
5 #include "GaudiKernel/StatusCode.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:
40 friend DataObjID_Hasher;
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};
80 std::size_t m_hash {0};
81
82 std::string m_className {""};
83 std::string m_key {"INVALID"};
84
85 static void getClidSvc();
86 static IClassIDSvc* p_clidSvc;
87 static std::once_flag m_ip;
88
89 };
90
91 inline DataObjID::DataObjID(const std::string& key):
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
114 struct DataObjID_Hasher {
115 std::size_t operator()(const DataObjID& k) const {
116 return k.m_hash;
117 }
118 };
119
120 typedef std::unordered_set<DataObjID, DataObjID_Hasher> DataObjIDColl;
121
122 namespace Gaudi {
123 namespace Parsers {
124 StatusCode parse(DataObjID&, const std::string&);
125 StatusCode parse(DataObjIDColl&, const std::string&);
126 }
127 namespace Utils {
128 GAUDI_API std::ostream& toStream(const DataObjID& v, std::ostream& o);
129 GAUDI_API std::ostream& toStream(const DataObjIDColl& v, std::ostream& o);
130 }
131 }
132
133
134 #endif
ClassID.h
DataObjID
Definition: DataObjID.h:38
DataObjIDColl
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
Definition: DataObjID.h:120
Gaudi::Utils::toStream
GAUDI_API std::ostream & toStream(const DataObjIDColl &v, std::ostream &o)
Definition: DataObjIDProperty.cpp:158
DataObjID::operator!=
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:68
DataObjID::p_clidSvc
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:86
DataObjID::updateKey
void updateKey(const std::string &key)
Definition: DataObjID.h:109
DataObjID::m_key
std::string m_key
Definition: DataObjID.h:83
DataObjID::DataObjID
DataObjID()
Definition: DataObjID.h:42
std::size_t
std::once_flag
DataObjID::DataObjID_Hasher
friend DataObjID_Hasher
Definition: DataObjID.h:40
std::string
STL class.
DataObjID::m_ip
static std::once_flag m_ip
Definition: DataObjID.h:87
IClassIDSvc
interface to the CLID database
Definition: IClassIDSvc.h:23
DataObjID::clid
CLID clid() const
Definition: DataObjID.h:54
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
DataObjID::key
const std::string & key() const
Definition: DataObjID.h:49
DataObjID::m_clid
CLID m_clid
Definition: DataObjID.h:79
std::unordered_set< DataObjID, DataObjID_Hasher >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:80
DataObjID_Hasher
Definition: DataObjID.h:114
DataObjID::getClidSvc
static void getClidSvc()
Definition: DataObjID.cpp:23
DataObjID_Hasher::operator()
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:115
DataObjID::parse
void parse(const std::string &key)
DataObjID::operator==
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:64
StatusCode.h
DataObjID::setClid
void setClid()
Definition: DataObjID.cpp:29
DataObjID::setClassName
void setClassName()
Definition: DataObjID.cpp:42
DataObjID::fullKey
std::string fullKey() const
Definition: DataObjID.cpp:64
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
DataObjID::m_className
std::string m_className
Definition: DataObjID.h:82
std::ostream
STL class.
DataObjID::hashGen
void hashGen()
Definition: DataObjID.cpp:11
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
DataObjID::operator<
friend bool operator<(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:60
DataObjID::operator<<
friend std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:54