| The Gaudi Framework v29r1 (5cd95fa2)

- 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 DataObjID::hashGen()
11 {
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 void DataObjID::getClidSvc() { p_clidSvc = Gaudi::svcLocator()->service<IClassIDSvc>( "ClassIDSvc" ).get(); }
22
23 void DataObjID::setClid()
24 {
25
26 std::call_once( m_ip, &DataObjID::getClidSvc );
27
28 if ( p_clidSvc == nullptr || p_clidSvc->getIDOfTypeName( m_className, m_clid ).isFailure() ) {
29 m_clid = 0;
30 m_className = "UNKNOWN_CLASS:" + m_className;
31 }
32 }
33
34 void DataObjID::setClassName()
35 {
36
37 std::call_once( m_ip, &DataObjID::getClidSvc );
38
39 if ( p_clidSvc == nullptr || p_clidSvc->getTypeNameOfID( m_clid, m_className ).isFailure() ) {
40 m_className = "UNKNOW_CLID:" + std::to_string( m_clid );
41 }
42 }
43
44 std::ostream& operator<<( std::ostream& str, const DataObjID& d )
45 {
46 if ( d.m_clid == 0 && d.m_className == "" ) {
47 str << "('" << d.m_key << "')";
48 } else {
49 str << "('" << d.m_className << "','" << d.m_key << "')";
50 }
51 return str;
52 }
53
54 std::string DataObjID::fullKey() const
55 {
56 if ( m_clid == 0 && m_className == "" ) {
57 return m_key;
58 } else {
59 return ( m_className + "/" + m_key );
60 }
61 }
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:37
std::to_string
T to_string(T...args)
DataObjID::p_clidSvc
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:79
Bootstrap.h
DataObjID::m_key
std::string m_key
Definition: DataObjID.h:76
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:86
std::string
STL class.
DataObjID::m_ip
static std::once_flag m_ip
Definition: DataObjID.h:80
IClassIDSvc
interface to the CLID database
Definition: IClassIDSvc.h:24
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:79
IClassIDSvc.h
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
std::hash
DataObjID::m_clid
CLID m_clid
Definition: DataObjID.h:72
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:73
DataObjID.h
DataObjID::getClidSvc
static void getClidSvc()
Definition: DataObjID.cpp:21
DataObjID::setClid
void setClid()
Definition: DataObjID.cpp:23
DataObjID::setClassName
void setClassName()
Definition: DataObjID.cpp:34
DataObjID::fullKey
std::string fullKey() const
Definition: DataObjID.cpp:54
DataObjID::m_className
std::string m_className
Definition: DataObjID.h:75
std::ostream
STL class.
ISvcLocator.h
DataObjID::hashGen
void hashGen()
Definition: DataObjID.cpp:10
DataObjID::operator<<
friend std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:44