The Gaudi Framework  v36r1 (3e2fb5a8)
DataObjID.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_DATAOBJID
12 #define GAUDIKERNEL_DATAOBJID 1
13 
14 #include "GaudiKernel/ClassID.h"
15 #include "GaudiKernel/StatusCode.h"
16 
17 #include <iostream>
18 #include <mutex>
19 #include <string>
20 #include <unordered_set>
21 
22 //---------------------------------------------------------------------------
23 
42 //---------------------------------------------------------------------------
43 
44 struct DataObjID_Hasher;
45 class IClassIDSvc;
46 
47 class DataObjID {
48 public:
50 
51  DataObjID() = default;
52  DataObjID( const DataObjID& ) = default;
54  DataObjID( const CLID& clid, std::string key );
56 
58  const std::string& key() const { return m_key; }
59 
61  const std::string& className() const { return m_className; }
62 
64  std::string fullKey() const;
65 
66  CLID clid() const { return m_clid; }
67 
68  void updateKey( std::string key );
69 
70  friend bool operator<( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash < rhs.m_hash; }
71  friend bool operator==( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash == rhs.m_hash; }
72  friend bool operator!=( const DataObjID& lhs, const DataObjID& rhs ) { return !( lhs == rhs ); }
73 
74  friend StatusCode parse( DataObjID& dest, const std::string& src );
75  friend std::ostream& toStream( const DataObjID& v, std::ostream& o );
76  friend std::ostream& operator<<( std::ostream& os, const DataObjID& d ) { return toStream( d, os ); }
77 
78 private:
79  void hashGen();
80  void setClid();
81  void setClassName();
82 
85 
86  std::string m_key{"INVALID"};
88 
91 };
92 
93 inline DataObjID::DataObjID( std::string key ) : m_key( std::move( key ) ) { hashGen(); }
94 
95 inline DataObjID::DataObjID( const CLID& clid, std::string key ) : m_clid( clid ), m_key( std::move( key ) ) {
96  setClassName();
97  hashGen();
98 }
99 
101  : m_key( std::move( key ) ), m_className( std::move( className ) ) {
102  setClid();
103  hashGen();
104 }
105 
107  m_key = std::move( key );
108  hashGen();
109 }
110 
112  std::size_t operator()( const DataObjID& k ) const { return k.m_hash; }
113 };
114 
116 
117 namespace Gaudi {
118  namespace Details {
119  namespace Property {
120  template <typename T>
121  struct StringConverter;
122 
123  template <>
127  };
128  } // namespace Property
129  } // namespace Details
130 } // namespace Gaudi
131 
132 #endif
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
DataObjID::operator<<
friend std::ostream & operator<<(std::ostream &os, const DataObjID &d)
Definition: DataObjID.h:76
DataObjID::m_ip
static std::once_flag m_ip
Definition: DataObjID.h:90
std::string
STL class.
DataObjID::setClassName
void setClassName()
Definition: DataObjID.cpp:76
std::move
T move(T... args)
DataObjID::updateKey
void updateKey(std::string key)
Definition: DataObjID.h:106
std::unordered_set
STL class.
DataObjID::operator<
friend bool operator<(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:70
DataObjID::DataObjID_Hasher
friend DataObjID_Hasher
Definition: DataObjID.h:49
ClassID.h
StatusCode.h
DataObjID::operator==
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:71
DataObjID::clid
CLID clid() const
Definition: DataObjID.h:66
DataObjID::fullKey
std::string fullKey() const
combination of the key and the ClassName, mostly for debugging
Definition: DataObjID.cpp:99
std::once_flag
DataObjID::m_className
std::string m_className
Definition: DataObjID.h:87
StatusCode
Definition: StatusCode.h:65
std::ostream
STL class.
Gaudi::Details::Property::DefaultStringConverter::fromString
TYPE fromString(const TYPE &ref_value, const std::string &s) final override
Definition: Property.h:85
Gaudi::Details::Property::StringConverter
Definition: Property.h:104
DataObjID_Hasher::operator()
std::size_t operator()(const DataObjID &k) const
Definition: DataObjID.h:112
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
DataObjID::operator!=
friend bool operator!=(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:72
DataObjID::className
const std::string & className() const
return the ClassName (if available)
Definition: DataObjID.h:61
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
DataObjID
Definition: DataObjID.h:47
gaudirun.dest
dest
Definition: gaudirun.py:213
HistoDumpEx.v
v
Definition: HistoDumpEx.py:27
DataObjID::m_clid
CLID m_clid
Definition: DataObjID.h:83
DataObjID::hashGen
void hashGen()
Definition: DataObjID.cpp:84
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:84
std
STL namespace.
DataObjID::m_key
std::string m_key
Definition: DataObjID.h:86
DataObjID::DataObjID
DataObjID()=default
DataObjID::p_clidSvc
static IClassIDSvc * p_clidSvc
Definition: DataObjID.h:89
DataObjID::setClid
void setClid()
Definition: DataObjID.cpp:67
DataObjID::DataObjID
DataObjID(const DataObjID &)=default
DataObjID::key
const std::string & key() const
only return the last part of the key
Definition: DataObjID.h:58
std::size_t
DataObjID::parse
friend StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:57
DataObjID::toStream
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition: DataObjID.cpp:93
IClassIDSvc
interface to the CLID database
Definition: IClassIDSvc.h:25
ProduceConsume.key
key
Definition: ProduceConsume.py:52
Gaudi::Details::Property::DefaultStringConverterImpl::toString
std::string toString(const TYPE &v)
Definition: Property.h:51
DataObjID_Hasher
Definition: DataObjID.h:111