The Gaudi Framework  v30r3 (a5ef0a68)
DataObjID.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATAOBJID
2 #define GAUDIKERNEL_DATAOBJID 1
3 
4 #include "GaudiKernel/ClassID.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:
41 
42  DataObjID() = default;
43  DataObjID( const DataObjID& ) = default;
44  DataObjID( const std::string& key );
45  DataObjID( const CLID& clid, const std::string& key );
46  DataObjID( const std::string& className, const std::string& key );
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 bool operator<( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash < rhs.m_hash; }
59  friend bool operator==( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash == rhs.m_hash; }
60  friend bool operator!=( const DataObjID& lhs, const DataObjID& rhs ) { return !( lhs == rhs ); }
61 
62  friend StatusCode parse( DataObjID& dest, const std::string& src );
63  friend std::ostream& toStream( const DataObjID& v, std::ostream& o );
64  friend std::ostream& operator<<( std::ostream& os, const DataObjID& d ) { return toStream( d, os ); }
65 
66 private:
67  void hashGen();
68  void setClid();
69  void setClassName();
70 
73 
74  std::string m_key{"INVALID"};
76 
79 };
80 
81 inline DataObjID::DataObjID( const std::string& key ) : m_key( key ) { hashGen(); }
82 
83 inline DataObjID::DataObjID( const CLID& clid, const std::string& key ) : m_clid( clid ), m_key( key )
84 {
85  setClassName();
86  hashGen();
87 }
88 
89 inline DataObjID::DataObjID( const std::string& className, const std::string& key )
90  : m_key( key ), m_className( className )
91 {
92  setClid();
93  hashGen();
94 }
95 
96 inline void DataObjID::updateKey( const std::string& key )
97 {
98  m_key = key;
99  hashGen();
100 }
101 
103  std::size_t operator()( const DataObjID& k ) const { return k.m_hash; }
104 };
105 
107 
108 namespace Gaudi
109 {
110  namespace Details
111  {
112  namespace Property
113  {
114  template <typename T>
116 
117  template <>
119  std::string toString( const DataObjIDColl& v );
120  DataObjIDColl fromString( const DataObjIDColl&, const std::string& );
121  };
122  }
123  }
124 }
125 
126 #endif
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition: DataObjID.cpp:92
Implementation of property with value of concrete type.
Definition: Property.h:381
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:60
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:77
void updateKey(const std::string &key)
Definition: DataObjID.h:96
std::string m_key
Definition: DataObjID.h:74
friend DataObjID_Hasher
Definition: DataObjID.h:40
STL class.
static std::once_flag m_ip
Definition: DataObjID.h:78
interface to the CLID database
Definition: IClassIDSvc.h:24
friend StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:52
CLID clid() const
Definition: DataObjID.h:54
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
const std::string & key() const
Definition: DataObjID.h:49
CLID m_clid
Definition: DataObjID.h:71
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
std::size_t m_hash
Definition: DataObjID.h:72
DataObjID()=default
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:103
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:59
void setClid()
Definition: DataObjID.cpp:63
void setClassName()
Definition: DataObjID.cpp:73
std::string fullKey() const
Definition: DataObjID.cpp:99
std::string m_className
Definition: DataObjID.h:75
STL class.
void hashGen()
Definition: DataObjID.cpp:82
Helper functions to set/get the application return code.
Definition: __init__.py:1
std::string toString(const Type &)
friend bool operator<(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:58
friend std::ostream & operator<<(std::ostream &os, const DataObjID &d)
Definition: DataObjID.h:64