Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataObjID.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 <memory>
19 #include <mutex>
20 #include <string>
21 #include <unordered_set>
22 
23 //---------------------------------------------------------------------------
24 
43 //---------------------------------------------------------------------------
44 
45 struct DataObjID_Hasher;
46 class IClassIDSvc;
47 
48 class DataObjID {
49 public:
51 
52  DataObjID() = default;
53  DataObjID( const DataObjID& other )
54  : m_clid( other.m_clid ), m_hash( other.m_hash ), m_key( other.m_key ), m_className( other.m_className ) {}
55 
57  DataObjID( const CLID& clid, std::string key );
59 
60  DataObjID& operator=( const DataObjID& other ) {
61  m_clid = other.m_clid;
62  m_hash = other.m_hash;
63  m_key = other.m_key;
64  m_className = other.m_className;
65  return *this;
66  }
67 
69  const std::string& key() const { return m_key; }
70 
72  const std::string& className() const;
73 
75  std::string fullKey() const;
76 
77  CLID clid() const { return m_clid; }
78  std::size_t hash() const { return m_hash; }
79 
80  void updateKey( std::string key );
81 
82  friend bool operator<( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash < rhs.m_hash; }
83  friend bool operator==( const DataObjID& lhs, const DataObjID& rhs ) { return lhs.m_hash == rhs.m_hash; }
84  friend bool operator!=( const DataObjID& lhs, const DataObjID& rhs ) { return !( lhs == rhs ); }
85 
86  friend StatusCode parse( DataObjID& dest, std::string_view src );
87  friend std::ostream& toStream( const DataObjID& v, std::ostream& o );
88  friend std::ostream& operator<<( std::ostream& os, const DataObjID& d ) { return toStream( d, os ); }
89 
90 private:
91  void hashGen();
92  void setClid();
93 
94  CLID m_clid{ 0 };
96 
97  std::string m_key{ "INVALID" };
100 };
101 
102 inline DataObjID::DataObjID( std::string key ) : m_key( std::move( key ) ) { hashGen(); }
103 
104 inline DataObjID::DataObjID( const CLID& clid, std::string key ) : m_clid( clid ), m_key( std::move( key ) ) {
105  hashGen();
106 }
107 
109  : m_key( std::move( key ) ), m_className( std::move( className ) ) {
110  setClid();
111  hashGen();
112 }
113 
115  m_key = std::move( key );
116  hashGen();
117 }
118 
120  std::size_t operator()( const DataObjID& k ) const { return k.m_hash; }
121 };
122 
125 
126 namespace Gaudi {
127  namespace Details {
128  namespace Property {
129  template <typename T>
130  struct StringConverter;
131 
132  template <>
136  };
137 
138  template <>
142  };
143  } // namespace Property
144  } // namespace Details
145 } // namespace Gaudi
146 
147 #endif
DataObjID::operator<<
friend std::ostream & operator<<(std::ostream &os, const DataObjID &d)
Definition: DataObjID.h:88
std::string
STL class.
std::move
T move(T... args)
DataObjID::updateKey
void updateKey(std::string key)
Definition: DataObjID.h:114
std::unordered_set< DataObjID, DataObjID_Hasher >
DataObjID::operator<
friend bool operator<(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:82
DataObjID::DataObjID_Hasher
friend DataObjID_Hasher
Definition: DataObjID.h:50
std::vector
STL class.
ClassID.h
StatusCode.h
DataObjID::DataObjID
DataObjID(const DataObjID &other)
Definition: DataObjID.h:53
DataObjID::operator==
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition: DataObjID.h:83
DataObjID::clid
CLID clid() const
Definition: DataObjID.h:77
DataObjID::fullKey
std::string fullKey() const
combination of the key and the ClassName, mostly for debugging
Definition: DataObjID.cpp:103
std::once_flag
DataObjID::m_className
std::string m_className
Definition: DataObjID.h:98
StatusCode
Definition: StatusCode.h:65
std::ostream
STL class.
Gaudi::Details::Property::DefaultStringConverter< TYPE >::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:120
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:84
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
DataObjID
Definition: DataObjID.h:48
gaudirun.dest
dest
Definition: gaudirun.py:224
DataObjID::operator=
DataObjID & operator=(const DataObjID &other)
Definition: DataObjID.h:60
DataObjID::m_clid
CLID m_clid
Definition: DataObjID.h:94
DataObjID::className
const std::string & className() const
return the ClassName (if available)
Definition: DataObjID.cpp:90
DataObjID::hashGen
void hashGen()
Definition: DataObjID.cpp:76
DataObjID::m_hash
std::size_t m_hash
Definition: DataObjID.h:95
std
STL namespace.
DataObjID::m_key
std::string m_key
Definition: DataObjID.h:97
DataObjID::DataObjID
DataObjID()=default
DataObjID::setClid
void setClid()
Definition: DataObjID.cpp:68
Properties.v
v
Definition: Properties.py:122
DataObjID::key
const std::string & key() const
only return the last part of the key
Definition: DataObjID.h:69
std::size_t
DataObjID::hash
std::size_t hash() const
Definition: DataObjID.h:78
DataObjID::toStream
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition: DataObjID.cpp:84
DataObjID::parse
friend StatusCode parse(DataObjID &dest, std::string_view src)
Definition: DataObjID.cpp:58
IClassIDSvc
interface to the CLID database
Definition: IClassIDSvc.h:25
ProduceConsume.key
key
Definition: ProduceConsume.py:84
Gaudi::Details::Property::DefaultStringConverterImpl::toString
std::string toString(const TYPE &v)
Definition: Property.h:51
DataObjID_Hasher
Definition: DataObjID.h:119
DataObjID::m_setClassName
std::once_flag m_setClassName
Definition: DataObjID.h:99