The Gaudi Framework  v30r1 (5d4f4ae2)
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 parse( const std::string& key );
69  void setClid();
70  void setClassName();
71 
74 
75  std::string m_key{"INVALID"};
77 
80 };
81 
82 inline DataObjID::DataObjID( const std::string& key ) : m_key( key ) { hashGen(); }
83 
84 inline DataObjID::DataObjID( const CLID& clid, const std::string& key ) : m_clid( clid ), m_key( key )
85 {
86  setClassName();
87  hashGen();
88 }
89 
90 inline DataObjID::DataObjID( const std::string& className, const std::string& key )
91  : m_key( key ), m_className( className )
92 {
93  setClid();
94  hashGen();
95 }
96 
97 inline void DataObjID::updateKey( const std::string& key )
98 {
99  m_key = key;
100  hashGen();
101 }
102 
104  std::size_t operator()( const DataObjID& k ) const { return k.m_hash; }
105 };
106 
108 
109 namespace Gaudi
110 {
111  namespace Details
112  {
113  namespace Property
114  {
115  template <typename T>
117 
118  template <>
120  std::string toString( const DataObjIDColl& v );
121  DataObjIDColl fromString( const std::string& s );
122  };
123  }
124  }
125 }
126 
127 #endif
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition: DataObjID.cpp:77
Implementation of property with value of concrete type.
Definition: Property.h:319
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:60
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:78
void updateKey(const std::string &key)
Definition: DataObjID.h:97
std::string m_key
Definition: DataObjID.h:75
friend DataObjID_Hasher
Definition: DataObjID.h:40
STL class.
static std::once_flag m_ip
Definition: DataObjID.h:79
interface to the CLID database
Definition: IClassIDSvc.h:24
friend StatusCode parse(DataObjID &dest, const std::string &src)
CLID clid() const
Definition: DataObjID.h:54
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
const std::string & key() const
Definition: DataObjID.h:49
CLID m_clid
Definition: DataObjID.h:72
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
std::size_t m_hash
Definition: DataObjID.h:73
DataObjID()=default
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:104
string s
Definition: gaudirun.py:253
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:59
void setClid()
Definition: DataObjID.cpp:48
void setClassName()
Definition: DataObjID.cpp:58
std::string fullKey() const
Definition: DataObjID.cpp:84
std::string m_className
Definition: DataObjID.h:76
STL class.
void hashGen()
Definition: DataObjID.cpp:67
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