| The Gaudi Framework v27r1

- 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 class 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 bool operator< ( const DataObjID& other ) const {
61 return (m_hash < other.m_hash);
62 }
63
64 bool operator==( const DataObjID& other ) const {
65 return (m_hash == other.m_hash);
66 }
67
68 bool operator!=( const DataObjID& other ) const {
69 return (m_hash != other.m_hash);
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 class DataObjID_Hasher {
115 public:
116 std::size_t operator()(const DataObjID& k) const {
117 return (k.m_hash);
118 }
119 };
120
121 typedef std::unordered_set<DataObjID, DataObjID_Hasher> DataObjIDColl;
122
123 namespace Gaudi {
124 namespace Parsers {
125 StatusCode parse(DataObjID&, const std::string&);
126 StatusCode parse(DataObjIDColl&, const std::string&);
127 }
128 namespace Utils {
129 GAUDI_API std::ostream& toStream(const DataObjID& v, std::ostream& o);
130 GAUDI_API std::ostream& toStream(const DataObjIDColl& v, std::ostream& o);
131 }
132 }
133
134
135 #endif
ClassID.h
DataObjID
Definition: DataObjID.h:38
DataObjIDColl
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
Definition: DataObjID.h:121
DataObjID::p_clidSvc
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:86
DataObjID::updateKey
void updateKey(const std::string &key)
Definition: DataObjID.h:109
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:11
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
Gaudi::Utils::toStream
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition: ToStream.h:319
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 >
DataObjID::operator!=
bool operator!=(const DataObjID &other) const
Definition: DataObjID.h:68
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:80
DataObjID::getClidSvc
static void getClidSvc()
Definition: DataObjID.cpp:23
DataObjID::parse
void parse(const std::string &key)
DataObjID::operator==
bool operator==(const DataObjID &other) const
Definition: DataObjID.h:64
StatusCode.h
DataObjID::setClid
void setClid()
Definition: DataObjID.cpp:29
DataObjID::setClassName
void setClassName()
Definition: DataObjID.cpp:42
DataObjID::operator<
bool operator<(const DataObjID &other) const
Definition: DataObjID.h:60
DataObjID::fullKey
std::string fullKey() const
Definition: DataObjID.cpp:64
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
DataObjID_Hasher::operator()
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:116
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 std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:54
DataObjID_Hasher
Definition: DataObjID.h:114