Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 public:
40 
41  DataObjID() = default;
42  DataObjID( const DataObjID& ) = default;
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 
47  // only return the last part of the key
48  const std::string& key() const { return m_key; }
49 
50  // combination of the key and the ClassName, mostly for debugging
51  std::string fullKey() const;
52 
53  CLID clid() const { return m_clid; }
54 
55  void updateKey( const std::string& key );
56 
57  friend bool operator<( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash < rhs.m_hash; }
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 == rhs ); }
60 
61  friend StatusCode parse( DataObjID& dest, const std::string& src );
62  friend std::ostream& toStream( const DataObjID& v, std::ostream& o );
63  friend std::ostream& operator<<( std::ostream& os, const DataObjID& d ) { return toStream( d, os ); }
64 
65 private:
66  void hashGen();
67  void setClid();
68  void setClassName();
69 
72 
73  std::string m_key{"INVALID"};
75 
78 };
79 
80 inline DataObjID::DataObjID( const std::string& key ) : m_key( key ) { hashGen(); }
81 
82 inline DataObjID::DataObjID( const CLID& clid, const std::string& key ) : m_clid( clid ), m_key( key ) {
83  setClassName();
84  hashGen();
85 }
86 
87 inline DataObjID::DataObjID( const std::string& className, const std::string& key )
88  : m_key( key ), m_className( className ) {
89  setClid();
90  hashGen();
91 }
92 
93 inline void DataObjID::updateKey( const std::string& key ) {
94  m_key = key;
95  hashGen();
96 }
97 
99  std::size_t operator()( const DataObjID& k ) const { return k.m_hash; }
100 };
101 
103 
104 namespace Gaudi {
105  namespace Details {
106  namespace Property {
107  template <typename T>
109 
110  template <>
112  std::string toString( const DataObjIDColl& v );
113  DataObjIDColl fromString( const DataObjIDColl&, const std::string& );
114  };
115  } // namespace Property
116  } // namespace Details
117 } // namespace Gaudi
118 
119 #endif
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition: DataObjID.cpp:82
Implementation of property with value of concrete type.
Definition: Property.h:352
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:59
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:76
void updateKey(const std::string &key)
Definition: DataObjID.h:93
std::string m_key
Definition: DataObjID.h:73
friend DataObjID_Hasher
Definition: DataObjID.h:39
STL class.
static std::once_flag m_ip
Definition: DataObjID.h:77
interface to the CLID database
Definition: IClassIDSvc.h:22
friend StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:46
CLID clid() const
Definition: DataObjID.h:53
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
const std::string & key() const
Definition: DataObjID.h:48
CLID m_clid
Definition: DataObjID.h:70
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
std::size_t m_hash
Definition: DataObjID.h:71
DataObjID()=default
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:99
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:58
void setClid()
Definition: DataObjID.cpp:56
void setClassName()
Definition: DataObjID.cpp:65
std::string fullKey() const
Definition: DataObjID.cpp:88
std::string m_className
Definition: DataObjID.h:74
STL class.
void hashGen()
Definition: DataObjID.cpp:73
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:57
friend std::ostream & operator<<(std::ostream &os, const DataObjID &d)
Definition: DataObjID.h:63