| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

DataObjID.cpp
Go to the documentation of this file.
1 #include "GaudiKernel/DataObjID.h"
2 #include "GaudiKernel/Bootstrap.h"
3 #include "GaudiKernel/IClassIDSvc.h"
4 #include "GaudiKernel/ISvcLocator.h"
5 #include <functional>
6
7 IClassIDSvc* DataObjID::p_clidSvc(nullptr);
8 std::once_flag DataObjID::m_ip;
9
10 void
11 DataObjID::hashGen() {
12
13 if (m_clid == 0) {
14 m_hash = (std::hash<std::string>()(m_key));
15 } else {
16 // this is a bit redundant since hash<int> is a pass-through
17 m_hash = (std::hash<std::string>()(m_key)) ^ (std::hash<CLID>()(m_clid) << 1);
18 }
19
20 }
21
22 void
23 DataObjID::getClidSvc() {
24 p_clidSvc = Gaudi::svcLocator()->service<IClassIDSvc>("ClassIDSvc").get();
25 }
26
27
28 void
29 DataObjID::setClid() {
30
31 std::call_once( m_ip, &DataObjID::getClidSvc );
32
33 if (p_clidSvc == nullptr || p_clidSvc->getIDOfTypeName(m_className, m_clid).isFailure()) {
34 m_clid = 0;
35 m_className = "UNKNOWN_CLASS:" + m_className;
36 }
37
38 }
39
40
41 void
42 DataObjID::setClassName() {
43
44 std::call_once( m_ip, &DataObjID::getClidSvc );
45
46 if (p_clidSvc == nullptr || p_clidSvc->getTypeNameOfID(m_clid, m_className).isFailure()) {
47 m_className = "UNKNOW_CLID:" + std::to_string(m_clid);
48 }
49
50 }
51
52
53 std::ostream&
54 operator<< (std::ostream& str, const DataObjID& d) {
55 if (d.m_clid == 0 && d.m_className == "") {
56 str << "('" << d.m_key << "')";
57 } else {
58 str << "('" << d.m_className << "','" << d.m_key << "')";
59 }
60 return str;
61 }
62
63 std::string
64 DataObjID::fullKey() const {
65 if (m_clid == 0 && m_className == "") {
66 return m_key;
67 } else {
68 return ( m_className + "/" + m_key );
69 }
70 }
IClassIDSvc::getIDOfTypeName
virtual StatusCode getIDOfTypeName(const std::string &typeName, CLID &id) const =0
get id associated with type name (if any)
IClassIDSvc::getTypeNameOfID
virtual StatusCode getTypeNameOfID(const CLID &id, std::string &typeName) const =0
get user assigned type name associated with clID
DataObjID
Definition: DataObjID.h:38
std::to_string
T to_string(T...args)
DataObjID::p_clidSvc
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:86
Bootstrap.h
DataObjID::m_key
std::string m_key
Definition: DataObjID.h:83
std::once_flag
std::call_once
T call_once(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
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
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
IClassIDSvc.h
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
std::hash
DataObjID::m_clid
CLID m_clid
Definition: DataObjID.h:79
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:80
DataObjID.h
DataObjID::getClidSvc
static void getClidSvc()
Definition: DataObjID.cpp:23
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
DataObjID::m_className
std::string m_className
Definition: DataObjID.h:82
std::ostream
STL class.
ISvcLocator.h
DataObjID::hashGen
void hashGen()
Definition: DataObjID.cpp:11
DataObjID::operator<<
friend std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:54