The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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::stringkey () const
 only return the last part of the key More...
 
const std::stringclassName () const
 return the ClassName (if available) More...
 
std::string fullKey () const
 combination of the key and the ClassName, mostly for debugging More...
 
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)
 
bool operator!= (const DataObjID &lhs, const DataObjID &rhs)
 
StatusCode parse (DataObjID &dest, std::string_view src)
 
std::ostreamtoStream (const DataObjID &v, std::ostream &o)
 
std::ostreamoperator<< (std::ostream &os, const DataObjID &d)
 

Detailed Description

Definition at line 48 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 53 of file DataObjID.h.

54  : m_clid( other.m_clid ), m_hash( other.m_hash ), m_key( other.m_key ), m_className( other.m_className ) {}

◆ DataObjID() [3/5]

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

Definition at line 102 of file DataObjID.h.

102 : m_key( std::move( key ) ) { hashGen(); }

◆ DataObjID() [4/5]

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

Definition at line 104 of file DataObjID.h.

104  : m_clid( clid ), m_key( std::move( key ) ) {
105  hashGen();
106 }

◆ DataObjID() [5/5]

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

Definition at line 108 of file DataObjID.h.

110  setClid();
111  hashGen();
112 }

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() ) {
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 }

◆ clid()

CLID DataObjID::clid ( ) const
inline

Definition at line 77 of file DataObjID.h.

77 { 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 78 of file DataObjID.h.

78 { return m_hash; }

◆ hashGen()

void DataObjID::hashGen ( )
private

Definition at line 76 of file DataObjID.cpp.

76  {
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 69 of file DataObjID.h.

69 { return m_key; }

◆ operator=()

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

Definition at line 60 of file DataObjID.h.

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

◆ 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 114 of file DataObjID.h.

114  {
115  m_key = std::move( key );
116  hashGen();
117 }

Friends And Related Function Documentation

◆ operator!=

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

Definition at line 84 of file DataObjID.h.

84 { return !( lhs == rhs ); }

◆ 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; }

◆ operator<<

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

Definition at line 88 of file DataObjID.h.

88 { return toStream( d, os ); }

◆ operator==

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

Definition at line 83 of file DataObjID.h.

83 { 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 ) ); }

◆ 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 }

Member Data Documentation

◆ DataObjID_Hasher

friend DataObjID::DataObjID_Hasher

Definition at line 50 of file DataObjID.h.

◆ m_className

std::string DataObjID::m_className
mutableprivate

Definition at line 98 of file DataObjID.h.

◆ m_clid

CLID DataObjID::m_clid { 0 }
private

Definition at line 94 of file DataObjID.h.

◆ m_hash

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

Definition at line 95 of file DataObjID.h.

◆ m_key

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

Definition at line 97 of file DataObjID.h.

◆ m_setClassName

std::once_flag DataObjID::m_setClassName
mutableprivate

Definition at line 99 of file DataObjID.h.


The documentation for this class was generated from the following files:
std::call_once
T call_once(T... args)
std::move
T move(T... args)
Gaudi::Parsers::parse_
StatusCode parse_(ResultT &result, std::string_view input)
Definition: Factory.h:39
DataObjID::clid
CLID clid() const
Definition: DataObjID.h:77
std::tie
T tie(T... args)
DataObjID::m_className
std::string m_className
Definition: DataObjID.h:98
std::to_string
T to_string(T... args)
gaudirun.dest
dest
Definition: gaudirun.py:224
DataObjID::m_clid
CLID m_clid
Definition: DataObjID.h:94
DataObjID::className
const std::string & className() const
return the ClassName (if available)
Definition: DataObjID.cpp:90
DataObjID::hashGen
void hashGen()
Definition: DataObjID.cpp:76
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:95
Gaudi::Utils::toStream
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:334
DataObjID::m_key
std::string m_key
Definition: DataObjID.h:97
std::string::empty
T empty(T... args)
DataObjID::setClid
void setClid()
Definition: DataObjID.cpp:68
DataObjID::key
const std::string & key() const
only return the last part of the key
Definition: DataObjID.h:69
DataObjID::toStream
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition: DataObjID.cpp:84
DataObjID::m_setClassName
std::once_flag m_setClassName
Definition: DataObjID.h:99
std::hash< std::string >