All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
8 std::once_flag DataObjID::m_ip;
9 
10 void
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
24  p_clidSvc = Gaudi::svcLocator()->service<IClassIDSvc>("ClassIDSvc").get();
25 }
26 
27 
28 void
30 
31  std::call_once( m_ip, &DataObjID::getClidSvc );
32 
34  m_clid = 0;
35  m_className = "UNKNOWN_CLASS:" + m_className;
36  }
37 
38 }
39 
40 
41 void
43 
44  std::call_once( m_ip, &DataObjID::getClidSvc );
45 
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
65  if (m_clid == 0 && m_className == "") {
66  return m_key;
67  } else {
68  return ( m_className + "/" + m_key );
69  }
70 }
string to_string(const T &value)
Definition: mergesort.cpp:40
std::string m_key
Definition: DataObjID.h:83
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
virtual StatusCode getIDOfTypeName(const std::string &typeName, CLID &id) const =0
get id associated with type name (if any)
interface to the CLID database
Definition: IClassIDSvc.h:23
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:86
GAUDI_API ISvcLocator * svcLocator()
virtual StatusCode getTypeNameOfID(const CLID &id, std::string &typeName) const =0
get user assigned type name associated with clID
CLID m_clid
Definition: DataObjID.h:79
std::size_t m_hash
Definition: DataObjID.h:80
static void getClidSvc()
Definition: DataObjID.cpp:23
void setClid()
Definition: DataObjID.cpp:29
std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:54
void setClassName()
Definition: DataObjID.cpp:42
std::string fullKey() const
Definition: DataObjID.cpp:64
std::string m_className
Definition: DataObjID.h:82
void hashGen()
Definition: DataObjID.cpp:11
static std::once_flag m_ip
Definition: DataObjID.h:87