| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

DataObjID.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATAOBJID
2 #define GAUDIKERNEL_DATAOBJID 1
3
4 #include "GaudiKernel/ClassID.h"
5 #include "GaudiKernel/StatusCode.h"
6
7 #include <iostream>
8 #include <mutex>
9 #include <string>
10 #include <unordered_set>
11
12 //---------------------------------------------------------------------------
13
32 //---------------------------------------------------------------------------
33
34 struct DataObjID_Hasher;
35 class IClassIDSvc;
36
37 class DataObjID
38 {
39 public:
40 friend DataObjID_Hasher;
41
42 DataObjID(){};
43 DataObjID( const std::string& key );
44 DataObjID( const CLID& clid, const std::string& key );
45 DataObjID( const std::string& className, const std::string& key );
46 DataObjID( const DataObjID& ) = default;
47
48 // only return the last part of the key
49 const std::string& key() const { return m_key; }
50
51 // combination of the key and the ClassName, mostly for debugging
52 std::string fullKey() const;
53
54 CLID clid() const { return m_clid; }
55
56 void updateKey( const std::string& key );
57
58 friend std::ostream& operator<<( std::ostream& str, const DataObjID& d );
59
60 friend bool operator<( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash < rhs.m_hash; }
61
62 friend bool operator==( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash == rhs.m_hash; }
63
64 friend bool operator!=( const DataObjID& lhs, const DataObjID& rhs ) { return !( lhs == rhs ); }
65
66 private:
67 void hashGen();
68 void parse( const std::string& key );
69 void setClid();
70 void setClassName();
71
72 CLID m_clid{0};
73 std::size_t m_hash{0};
74
75 std::string m_className{""};
76 std::string m_key{"INVALID"};
77
78 static void getClidSvc();
79 static IClassIDSvc* p_clidSvc;
80 static std::once_flag m_ip;
81 };
82
83 inline DataObjID::DataObjID( const std::string& key ) : m_key( key ) { hashGen(); }
84
85 inline DataObjID::DataObjID( const CLID& clid, const std::string& key ) : m_clid( clid ), m_key( key )
86 {
87 setClassName();
88 hashGen();
89 }
90
91 inline DataObjID::DataObjID( const std::string& className, const std::string& key )
92 : m_className( className ), m_key( key )
93 {
94 setClid();
95 hashGen();
96 }
97
98 inline void DataObjID::updateKey( const std::string& key )
99 {
100 m_key = key;
101 hashGen();
102 }
103
104 struct DataObjID_Hasher {
105 std::size_t operator()( const DataObjID& k ) const { return k.m_hash; }
106 };
107
108 typedef std::unordered_set<DataObjID, DataObjID_Hasher> DataObjIDColl;
109
110 namespace Gaudi
111 {
112 namespace Parsers
113 {
114 StatusCode parse( DataObjID&, const std::string& );
115 StatusCode parse( DataObjIDColl&, const std::string& );
116 }
117 namespace Utils
118 {
119 GAUDI_API std::ostream& toStream( const DataObjID& v, std::ostream& o );
120 GAUDI_API std::ostream& toStream( const DataObjIDColl& v, std::ostream& o );
121 }
122 }
123
124 #endif
ClassID.h
DataObjID
Definition: DataObjID.h:37
DataObjIDColl
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
Definition: DataObjID.h:108
Gaudi::Utils::toStream
GAUDI_API std::ostream & toStream(const DataObjIDColl &v, std::ostream &o)
Definition: DataObjIDProperty.cpp:156
DataObjID::operator!=
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:64
DataObjID::p_clidSvc
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:79
DataObjID::updateKey
void updateKey(const std::string &key)
Definition: DataObjID.h:98
DataObjID::m_key
std::string m_key
Definition: DataObjID.h:76
DataObjID::DataObjID
DataObjID()
Definition: DataObjID.h:42
std::size_t
std::once_flag
DataObjID::DataObjID_Hasher
friend DataObjID_Hasher
Definition: DataObjID.h:40
std::string
STL class.
DataObjID::m_ip
static std::once_flag m_ip
Definition: DataObjID.h:80
IClassIDSvc
interface to the CLID database
Definition: IClassIDSvc.h:24
DataObjID::clid
CLID clid() const
Definition: DataObjID.h:54
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
DataObjID::key
const std::string & key() const
Definition: DataObjID.h:49
DataObjID::m_clid
CLID m_clid
Definition: DataObjID.h:72
std::unordered_set< DataObjID, DataObjID_Hasher >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:73
DataObjID_Hasher
Definition: DataObjID.h:104
DataObjID::getClidSvc
static void getClidSvc()
Definition: DataObjID.cpp:21
DataObjID_Hasher::operator()
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:105
DataObjID::parse
void parse(const std::string &key)
DataObjID::operator==
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:62
StatusCode.h
DataObjID::setClid
void setClid()
Definition: DataObjID.cpp:23
DataObjID::setClassName
void setClassName()
Definition: DataObjID.cpp:34
DataObjID::fullKey
std::string fullKey() const
Definition: DataObjID.cpp:54
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
DataObjID::m_className
std::string m_className
Definition: DataObjID.h:75
std::ostream
STL class.
DataObjID::hashGen
void hashGen()
Definition: DataObjID.cpp:10
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
DataObjID::operator<
friend bool operator<(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:60
DataObjID::operator<<
friend std::ostream & operator<<(std::ostream &str, const DataObjID &d)
Definition: DataObjID.cpp:44