The Gaudi Framework  v29r0 (ff2e7097)
DataObjID Class Reference

#include <GaudiKernel/DataObjID.h>

Collaboration diagram for DataObjID:

Public Member Functions

 DataObjID ()
 
 DataObjID (const std::string &key)
 
 DataObjID (const CLID &clid, const std::string &key)
 
 DataObjID (const std::string &className, const std::string &key)
 
 DataObjID (const DataObjID &)=default
 
const std::stringkey () const
 
std::string fullKey () const
 
CLID clid () const
 
void updateKey (const std::string &key)
 

Public Attributes

friend DataObjID_Hasher
 

Private Member Functions

void hashGen ()
 
void parse (const std::string &key)
 
void setClid ()
 
void setClassName ()
 

Static Private Member Functions

static void getClidSvc ()
 

Private Attributes

CLID m_clid {0}
 
std::size_t m_hash {0}
 
std::string m_className {""}
 
std::string m_key {"INVALID"}
 

Static Private Attributes

static IClassIDSvcp_clidSvc
 
static std::once_flag m_ip
 

Friends

std::ostreamoperator<< (std::ostream &str, const DataObjID &d)
 
bool operator< (const DataObjID &lhs, const DataObjID &rhs)
 
bool operator== (const DataObjID &lhs, const DataObjID &rhs)
 
bool operator!= (const DataObjID &lhs, const DataObjID &rhs)
 

Detailed Description

Definition at line 37 of file DataObjID.h.

Constructor & Destructor Documentation

DataObjID::DataObjID ( )
inline

Definition at line 42 of file DataObjID.h.

42 {};
DataObjID::DataObjID ( const std::string key)
inline

Definition at line 83 of file DataObjID.h.

83 : m_key( key ) { hashGen(); }
std::string m_key
Definition: DataObjID.h:76
void hashGen()
Definition: DataObjID.cpp:10
DataObjID::DataObjID ( const CLID clid,
const std::string key 
)
inline

Definition at line 85 of file DataObjID.h.

85  : m_clid( clid ), m_key( key )
86 {
87  setClassName();
88  hashGen();
89 }
std::string m_key
Definition: DataObjID.h:76
CLID clid() const
Definition: DataObjID.h:54
CLID m_clid
Definition: DataObjID.h:72
void setClassName()
Definition: DataObjID.cpp:34
void hashGen()
Definition: DataObjID.cpp:10
DataObjID::DataObjID ( const std::string className,
const std::string key 
)
inline

Definition at line 91 of file DataObjID.h.

92  : m_className( className ), m_key( key )
93 {
94  setClid();
95  hashGen();
96 }
std::string m_key
Definition: DataObjID.h:76
void setClid()
Definition: DataObjID.cpp:23
std::string m_className
Definition: DataObjID.h:75
void hashGen()
Definition: DataObjID.cpp:10
DataObjID::DataObjID ( const DataObjID )
default

Member Function Documentation

CLID DataObjID::clid ( ) const
inline

Definition at line 54 of file DataObjID.h.

54 { return m_clid; }
CLID m_clid
Definition: DataObjID.h:72
std::string DataObjID::fullKey ( ) const

Definition at line 54 of file DataObjID.cpp.

55 {
56  if ( m_clid == 0 && m_className == "" ) {
57  return m_key;
58  } else {
59  return ( m_className + "/" + m_key );
60  }
61 }
std::string m_key
Definition: DataObjID.h:76
CLID m_clid
Definition: DataObjID.h:72
std::string m_className
Definition: DataObjID.h:75
void DataObjID::getClidSvc ( )
staticprivate

Definition at line 21 of file DataObjID.cpp.

21 { p_clidSvc = Gaudi::svcLocator()->service<IClassIDSvc>( "ClassIDSvc" ).get(); }
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:79
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()
void DataObjID::hashGen ( )
private

Definition at line 10 of file DataObjID.cpp.

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 }
std::string m_key
Definition: DataObjID.h:76
CLID m_clid
Definition: DataObjID.h:72
std::size_t m_hash
Definition: DataObjID.h:73
const std::string& DataObjID::key ( ) const
inline

Definition at line 49 of file DataObjID.h.

49 { return m_key; }
std::string m_key
Definition: DataObjID.h:76
void DataObjID::parse ( const std::string key)
private
void DataObjID::setClassName ( )
private

Definition at line 34 of file DataObjID.cpp.

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 }
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
T call_once(T...args)
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
static std::once_flag m_ip
Definition: DataObjID.h:80
CLID m_clid
Definition: DataObjID.h:72
static void getClidSvc()
Definition: DataObjID.cpp:21
std::string m_className
Definition: DataObjID.h:75
void DataObjID::setClid ( )
private

Definition at line 23 of file DataObjID.cpp.

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 }
virtual StatusCode getIDOfTypeName(const std::string &typeName, CLID &id) const =0
get id associated with type name (if any)
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:79
T call_once(T...args)
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
static std::once_flag m_ip
Definition: DataObjID.h:80
CLID m_clid
Definition: DataObjID.h:72
static void getClidSvc()
Definition: DataObjID.cpp:21
std::string m_className
Definition: DataObjID.h:75
void DataObjID::updateKey ( const std::string key)
inline

Definition at line 98 of file DataObjID.h.

99 {
100  m_key = key;
101  hashGen();
102 }
std::string m_key
Definition: DataObjID.h:76
const std::string & key() const
Definition: DataObjID.h:49
void hashGen()
Definition: DataObjID.cpp:10

Friends And Related Function Documentation

bool operator!= ( const DataObjID lhs,
const DataObjID rhs 
)
friend

Definition at line 64 of file DataObjID.h.

64 { return !( lhs == rhs ); }
bool operator< ( const DataObjID lhs,
const DataObjID rhs 
)
friend

Definition at line 60 of file DataObjID.h.

60 { return lhs.m_hash < rhs.m_hash; }
std::size_t m_hash
Definition: DataObjID.h:73
std::ostream& operator<< ( std::ostream str,
const DataObjID d 
)
friend

Definition at line 44 of file DataObjID.cpp.

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 }
std::string m_key
Definition: DataObjID.h:76
CLID m_clid
Definition: DataObjID.h:72
std::string m_className
Definition: DataObjID.h:75
bool operator== ( const DataObjID lhs,
const DataObjID rhs 
)
friend

Definition at line 62 of file DataObjID.h.

62 { return lhs.m_hash == rhs.m_hash; }
std::size_t m_hash
Definition: DataObjID.h:73

Member Data Documentation

friend DataObjID::DataObjID_Hasher

Definition at line 40 of file DataObjID.h.

std::string DataObjID::m_className {""}
private

Definition at line 75 of file DataObjID.h.

CLID DataObjID::m_clid {0}
private

Definition at line 72 of file DataObjID.h.

std::size_t DataObjID::m_hash {0}
private

Definition at line 73 of file DataObjID.h.

std::once_flag DataObjID::m_ip
staticprivate

Definition at line 80 of file DataObjID.h.

std::string DataObjID::m_key {"INVALID"}
private

Definition at line 76 of file DataObjID.h.

IClassIDSvc * DataObjID::p_clidSvc
staticprivate

Definition at line 79 of file DataObjID.h.


The documentation for this class was generated from the following files: