The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
#pragma once
12
13
#include <
GaudiKernel/ClassID.h
>
14
#include <
GaudiKernel/StatusCode.h
>
15
16
#include <iostream>
17
#include <memory>
18
#include <mutex>
19
#include <string>
20
#include <unordered_set>
21
22
//---------------------------------------------------------------------------
23
41
42
//---------------------------------------------------------------------------
43
44
struct
DataObjID_Hasher
;
45
class
IClassIDSvc
;
46
47
class
DataObjID
{
48
public
:
49
friend
DataObjID_Hasher
;
50
51
DataObjID
() =
default
;
52
DataObjID
(
const
DataObjID
& other )
53
:
m_clid
( other.
m_clid
),
m_hash
( other.
m_hash
),
m_key
( other.
m_key
),
m_className
( other.
m_className
) {}
54
55
DataObjID
( std::string
key
);
56
DataObjID
(
const
CLID
&
clid
, std::string
key
);
57
DataObjID
( std::string
className
, std::string
key
);
58
59
DataObjID
&
operator=
(
const
DataObjID
& other ) {
60
m_clid
= other.
m_clid
;
61
m_hash
= other.
m_hash
;
62
m_key
= other.
m_key
;
63
m_className
= other.
m_className
;
64
return
*
this
;
65
}
66
68
const
std::string&
key
()
const
{
return
m_key
; }
69
71
const
std::string&
className
()
const
;
72
74
std::string
fullKey
()
const
;
75
76
CLID
clid
()
const
{
return
m_clid
; }
77
std::size_t
hash
()
const
{
return
m_hash
; }
78
79
void
updateKey
( std::string
key
);
80
81
friend
bool
operator<
(
const
DataObjID
& lhs,
const
DataObjID
& rhs ) {
return
lhs.
m_hash
< rhs.
m_hash
; }
82
friend
bool
operator==
(
const
DataObjID
& lhs,
const
DataObjID
& rhs ) {
return
lhs.
m_hash
== rhs.
m_hash
; }
83
84
friend
StatusCode
parse
(
DataObjID
& dest, std::string_view src );
85
friend
std::ostream&
toStream
(
const
DataObjID
& v, std::ostream& o );
86
friend
std::ostream&
operator<<
( std::ostream& os,
const
DataObjID
& d ) {
return
toStream
( d, os ); }
87
88
private
:
89
void
hashGen
();
90
void
setClid
();
91
92
CLID
m_clid
{ 0 };
93
std::size_t
m_hash
{ 0 };
94
95
std::string
m_key
{
"INVALID"
};
96
mutable
std::string
m_className
;
97
mutable
std::once_flag
m_setClassName
;
98
};
99
100
inline
DataObjID::DataObjID
( std::string
key
) :
m_key
(
std
::move(
key
) ) {
hashGen
(); }
101
102
inline
DataObjID::DataObjID
(
const
CLID
&
clid
, std::string
key
) :
m_clid
(
clid
),
m_key
(
std
::move(
key
) ) {
103
hashGen
();
104
}
105
106
inline
DataObjID::DataObjID
( std::string
className
, std::string
key
)
107
:
m_key
(
std
::move(
key
) ),
m_className
(
std
::move(
className
) ) {
108
setClid
();
109
hashGen
();
110
}
111
112
inline
void
DataObjID::updateKey
( std::string
key
) {
113
m_key
= std::move(
key
);
114
hashGen
();
115
}
116
117
struct
DataObjID_Hasher
{
118
std::size_t
operator()
(
const
DataObjID
& k )
const
{
return
k.
m_hash
; }
119
};
120
121
using
DataObjIDColl
= std::unordered_set<DataObjID, DataObjID_Hasher>;
122
using
DataObjIDVector
= std::vector<DataObjID>;
123
124
namespace
Gaudi
{
125
namespace
Details {
126
namespace
Property {
127
template
<
typename
T>
128
struct
StringConverter;
129
130
template
<>
131
struct
StringConverter
<
DataObjIDColl
> {
132
std::string
toString
(
const
DataObjIDColl
& v );
133
DataObjIDColl
fromString
(
const
DataObjIDColl
&,
const
std::string& );
134
};
135
136
template
<>
137
struct
StringConverter
<
DataObjIDVector
> {
138
std::string
toString
(
const
DataObjIDVector
& v );
139
DataObjIDVector
fromString
(
const
DataObjIDVector
&,
const
std::string& );
140
};
141
}
// namespace Property
142
}
// namespace Details
143
}
// namespace Gaudi
ClassID.h
CLID
unsigned int CLID
Class ID definition.
Definition
ClassID.h:16
DataObjIDColl
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
Definition
DataObjID.h:121
DataObjIDVector
std::vector< DataObjID > DataObjIDVector
Definition
DataObjID.h:122
StatusCode.h
DataObjID
Definition
DataObjID.h:47
DataObjID::setClid
void setClid()
Definition
DataObjID.cpp:68
DataObjID::m_hash
std::size_t m_hash
Definition
DataObjID.h:93
DataObjID::key
const std::string & key() const
only return the last part of the key
Definition
DataObjID.h:68
DataObjID::fullKey
std::string fullKey() const
combination of the key and the ClassName, mostly for debugging
Definition
DataObjID.cpp:103
DataObjID::clid
CLID clid() const
Definition
DataObjID.h:76
DataObjID::hashGen
void hashGen()
Definition
DataObjID.cpp:76
DataObjID::className
const std::string & className() const
return the ClassName (if available)
Definition
DataObjID.cpp:90
DataObjID::m_key
std::string m_key
Definition
DataObjID.h:95
DataObjID::m_setClassName
std::once_flag m_setClassName
Definition
DataObjID.h:97
DataObjID::operator==
friend bool operator==(const DataObjID &lhs, const DataObjID &rhs)
Definition
DataObjID.h:82
DataObjID::m_clid
CLID m_clid
Definition
DataObjID.h:92
DataObjID::DataObjID
DataObjID(const DataObjID &other)
Definition
DataObjID.h:52
DataObjID::operator<
friend bool operator<(const DataObjID &lhs, const DataObjID &rhs)
Definition
DataObjID.h:81
DataObjID::operator=
DataObjID & operator=(const DataObjID &other)
Definition
DataObjID.h:59
DataObjID::DataObjID_Hasher
friend DataObjID_Hasher
Definition
DataObjID.h:49
DataObjID::DataObjID
DataObjID()=default
DataObjID::m_className
std::string m_className
Definition
DataObjID.h:96
DataObjID::operator<<
friend std::ostream & operator<<(std::ostream &os, const DataObjID &d)
Definition
DataObjID.h:86
DataObjID::updateKey
void updateKey(std::string key)
Definition
DataObjID.h:112
DataObjID::parse
friend StatusCode parse(DataObjID &dest, std::string_view src)
Definition
DataObjID.cpp:58
DataObjID::hash
std::size_t hash() const
Definition
DataObjID.h:77
DataObjID::toStream
friend std::ostream & toStream(const DataObjID &v, std::ostream &o)
Definition
DataObjID.cpp:84
IClassIDSvc
interface to the CLID database
Definition
IClassIDSvc.h:24
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
std
STL namespace.
DataObjID_Hasher
Definition
DataObjID.h:117
DataObjID_Hasher::operator()
std::size_t operator()(const DataObjID &k) const
Definition
DataObjID.h:118
Gaudi::Details::Property::DefaultStringConverter< TYPE >::fromString
TYPE fromString(const TYPE &, const std::string &s) final override
Definition
Property.h:95
Gaudi::Details::Property::DefaultStringConverterImpl::toString
std::string toString(const TYPE &v)
Definition
Property.h:51
Gaudi::Details::Property::StringConverter
Definition
Property.h:104
GaudiKernel
include
GaudiKernel
DataObjID.h
Generated on
for The Gaudi Framework by
1.17.0