The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
DataObjID Class Reference

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/DataObjID.h>

Collaboration diagram for DataObjID:

Public Member Functions

 DataObjID ()=default
 
 DataObjID (const DataObjID &other)
 
 DataObjID (std::string key)
 
 DataObjID (const CLID &clid, std::string key)
 
 DataObjID (std::string className, std::string key)
 
DataObjIDoperator= (const DataObjID &other)
 
const std::string & key () const
 only return the last part of the key
 
const std::string & className () const
 return the ClassName (if available)
 
std::string fullKey () const
 combination of the key and the ClassName, mostly for debugging
 
CLID clid () const
 
std::size_t hash () const
 
void updateKey (std::string key)
 

Public Attributes

friend DataObjID_Hasher
 

Private Member Functions

void hashGen ()
 
void setClid ()
 

Private Attributes

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

Friends

bool operator< (const DataObjID &lhs, const DataObjID &rhs)
 
bool operator== (const DataObjID &lhs, const DataObjID &rhs)
 
StatusCode parse (DataObjID &dest, std::string_view src)
 
std::ostream & toStream (const DataObjID &v, std::ostream &o)
 
std::ostream & operator<< (std::ostream &os, const DataObjID &d)
 

Detailed Description

Definition at line 47 of file DataObjID.h.

Constructor & Destructor Documentation

◆ DataObjID() [1/5]

DataObjID::DataObjID ( )
default

◆ DataObjID() [2/5]

DataObjID::DataObjID ( const DataObjID & other)
inline

Definition at line 52 of file DataObjID.h.

53 : m_clid( other.m_clid ), m_hash( other.m_hash ), m_key( other.m_key ), m_className( other.m_className ) {}
std::size_t m_hash
Definition DataObjID.h:93
std::string m_key
Definition DataObjID.h:95
CLID m_clid
Definition DataObjID.h:92
std::string m_className
Definition DataObjID.h:96

◆ DataObjID() [3/5]

DataObjID::DataObjID ( std::string key)
inline

Definition at line 100 of file DataObjID.h.

100: m_key( std::move( key ) ) { hashGen(); }
const std::string & key() const
only return the last part of the key
Definition DataObjID.h:68
void hashGen()
Definition DataObjID.cpp:76

◆ DataObjID() [4/5]

DataObjID::DataObjID ( const CLID & clid,
std::string key )
inline

Definition at line 102 of file DataObjID.h.

102 : m_clid( clid ), m_key( std::move( key ) ) {
103 hashGen();
104}
CLID clid() const
Definition DataObjID.h:76

◆ DataObjID() [5/5]

DataObjID::DataObjID ( std::string className,
std::string key )
inline

Definition at line 106 of file DataObjID.h.

107 : m_key( std::move( key ) ), m_className( std::move( className ) ) {
108 setClid();
109 hashGen();
110}
void setClid()
Definition DataObjID.cpp:68
const std::string & className() const
return the ClassName (if available)
Definition DataObjID.cpp:90

Member Function Documentation

◆ className()

const std::string & DataObjID::className ( ) const

return the ClassName (if available)

Definition at line 90 of file DataObjID.cpp.

90 {
91
92 // Set class name once if not done already
93 if ( m_clid != 0 && m_className.empty() ) {
94 std::call_once( m_setClassName, [&]() {
95 if ( !getClidSvc() || getClidSvc()->getTypeNameOfID( m_clid, m_className ).isFailure() ) {
96 m_className = "UNKNOWN_CLID:" + std::to_string( m_clid );
97 }
98 } );
99 }
100 return m_className;
101}
std::once_flag m_setClassName
Definition DataObjID.h:97

◆ clid()

CLID DataObjID::clid ( ) const
inline

Definition at line 76 of file DataObjID.h.

76{ return m_clid; }

◆ fullKey()

std::string DataObjID::fullKey ( ) const

combination of the key and the ClassName, mostly for debugging

Definition at line 103 of file DataObjID.cpp.

103 {
104 return ( m_clid == 0 && m_className.empty() ) ? m_key : ( className() + '/' + m_key );
105}

◆ hash()

std::size_t DataObjID::hash ( ) const
inline

Definition at line 77 of file DataObjID.h.

77{ return m_hash; }

◆ hashGen()

void DataObjID::hashGen ( )
private

Definition at line 76 of file DataObjID.cpp.

76 {
77 m_hash = ( std::hash<std::string>()( m_key ) );
78 if ( m_clid != 0 ) {
79 // this is a bit redundant since hash<int> is a pass-through
80 m_hash ^= ( std::hash<CLID>()( m_clid ) << 1 );
81 }
82}

◆ key()

const std::string & DataObjID::key ( ) const
inline

only return the last part of the key

Definition at line 68 of file DataObjID.h.

68{ return m_key; }

◆ operator=()

DataObjID & DataObjID::operator= ( const DataObjID & other)
inline

Definition at line 59 of file DataObjID.h.

59 {
60 m_clid = other.m_clid;
61 m_hash = other.m_hash;
62 m_key = other.m_key;
64 return *this;
65 }

◆ setClid()

void DataObjID::setClid ( )
private

Definition at line 68 of file DataObjID.cpp.

68 {
69
70 if ( !getClidSvc() || getClidSvc()->getIDOfTypeName( m_className, m_clid ).isFailure() ) {
71 m_clid = 0;
72 m_className = "UNKNOWN_CLASS:" + m_className;
73 }
74}

◆ updateKey()

void DataObjID::updateKey ( std::string key)
inline

Definition at line 112 of file DataObjID.h.

112 {
113 m_key = std::move( key );
114 hashGen();
115}

Friends And Related Symbol Documentation

◆ operator<

bool operator< ( const DataObjID & lhs,
const DataObjID & rhs )
friend

Definition at line 81 of file DataObjID.h.

81{ return lhs.m_hash < rhs.m_hash; }

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const DataObjID & d )
friend

Definition at line 86 of file DataObjID.h.

86{ return toStream( d, os ); }
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition DataObjID.cpp:84

◆ operator==

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

Definition at line 82 of file DataObjID.h.

82{ return lhs.m_hash == rhs.m_hash; }

◆ parse

StatusCode parse ( DataObjID & dest,
std::string_view src )
friend

Definition at line 58 of file DataObjID.cpp.

58{ return Gaudi::Parsers::parse_( dest, quote( src ) ); }
StatusCode parse_(ResultT &result, std::string_view input)
Definition Factory.h:26

◆ toStream

std::ostream & toStream ( const DataObjID & v,
std::ostream & o )
friend

Definition at line 84 of file DataObjID.cpp.

84 {
86 return ( d.m_clid != 0 || !d.className().empty() ) ? toStream( std::tie( d.className(), d.m_key ), os )
87 : toStream( d.m_key, os );
88}
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition ToStream.h:304

Member Data Documentation

◆ DataObjID_Hasher

friend DataObjID::DataObjID_Hasher

Definition at line 49 of file DataObjID.h.

◆ m_className

std::string DataObjID::m_className
mutableprivate

Definition at line 96 of file DataObjID.h.

◆ m_clid

CLID DataObjID::m_clid { 0 }
private

Definition at line 92 of file DataObjID.h.

92{ 0 };

◆ m_hash

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

Definition at line 93 of file DataObjID.h.

93{ 0 };

◆ m_key

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

Definition at line 95 of file DataObjID.h.

95{ "INVALID" };

◆ m_setClassName

std::once_flag DataObjID::m_setClassName
mutableprivate

Definition at line 97 of file DataObjID.h.


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