The Gaudi Framework  v29r0 (ff2e7097)
DataObjID.cpp
Go to the documentation of this file.
5 #include <functional>
6 
9 
11 {
12 
13  if ( m_clid == 0 ) {
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 
24 {
25 
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 
35 {
36 
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 
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 
55 {
56  if ( m_clid == 0 && m_className == "" ) {
57  return m_key;
58  } else {
59  return ( m_className + "/" + m_key );
60  }
61 }
virtual StatusCode getIDOfTypeName(const std::string &typeName, CLID &id) const =0
get id associated with type name (if any)
virtual StatusCode getTypeNameOfID(const CLID &id, std::string &typeName) const =0
get user assigned type name associated with clID
T to_string(T...args)
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:79
std::string m_key
Definition: DataObjID.h:76
T call_once(T...args)
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
STL class.
static std::once_flag m_ip
Definition: DataObjID.h:80
interface to the CLID database
Definition: IClassIDSvc.h:24
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
GAUDI_API ISvcLocator * svcLocator()
CLID m_clid
Definition: DataObjID.h:72
std::size_t m_hash
Definition: DataObjID.h:73
static void getClidSvc()
Definition: DataObjID.cpp:21
void setClid()
Definition: DataObjID.cpp:23
void setClassName()
Definition: DataObjID.cpp:34
std::string fullKey() const
Definition: DataObjID.cpp:54
std::string m_className
Definition: DataObjID.h:75
STL class.
void hashGen()
Definition: DataObjID.cpp:10
friend std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:44