ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
SGTools
SGTools
SGVersionedKey.h
Go to the documentation of this file.
1
/* -*- C++ -*- */
2
3
/*
4
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5
*/
6
10
#ifndef SGTOOLS_VERSIONEDKEY_H
11
#define SGTOOLS_VERSIONEDKEY_H 1
12
#include <iostream>
13
#include <string>
14
class
StoreGateSvc
;
//our friend
15
class
SGImplSvc
;
//our friend
16
namespace
SG
{
17
template
<
class
T>
class
ObjectWithVersion
;
18
31
class
VersionedKey
{
32
friend
class ::StoreGateSvc;
//call copyVK
33
friend
class ::SGImplSvc;
//call copyVK
34
public
:
36
static
bool
isVersionedKey
(
const
char
*);
38
static
bool
isVersionedKey
(
const
std::string&);
39
42
static
bool
isAuto
(
const
std::string&);
43
45
VersionedKey
(
const
char
*
key
,
unsigned
char
version
);
47
VersionedKey
(
const
std::string&
key
,
unsigned
char
version
);
48
52
explicit
VersionedKey
(
const
char
* vkey);
56
explicit
VersionedKey
(
const
std::string& vkey);
57
58
//Defaulted copy and move constructors and assignment operators
59
//since the class only holds strings.
60
VersionedKey
(
const
VersionedKey
& rhs) =
default
;
61
VersionedKey
(
VersionedKey
&& rhs) =
default
;
62
VersionedKey
&
operator=
(
const
VersionedKey
& rhs) =
default
;
63
VersionedKey
&
operator=
(
VersionedKey
&& rhs) =
default
;
64
65
~VersionedKey
();
66
68
void
decode
(std::string& outKey,
unsigned
char
&
version
)
const
;
69
// cppcheck-suppress returnByReference
70
operator
std::string()
const
{
return
m_versionKey
; }
72
unsigned
char
version
()
const
;
74
const
std::string&
key
()
const
;
76
const
std::string&
rawVersionKey
()
const
{
77
return
m_versionKey
;
78
}
79
80
bool
sameKey
(
const
VersionedKey
& vkey)
const
;
82
bool
sameKey
(
const
std::string& baseKey)
const
;
84
bool
sameKey
(
const
char
* baseKey)
const
;
85
bool
isAuto
()
const
{
return
version
() ==
VersionedKey::autoV
(); }
86
87
private
:
88
template
<
class
U>
friend
class
ObjectWithVersion
;
90
VersionedKey
():
m_versionKey
() {}
91
92
void
encode
(
const
std::string& inKey,
unsigned
char
version
);
93
void
copyVK
(
const
std::string& inKey);
94
95
static
char
separator
() {
return
';'
;}
96
static
const
char
*
versionFormatString
() {
return
";%02u;"
;}
97
static
const
char
*
formatString
() {
return
";%02u;%s"
;}
98
99
static
unsigned
char
autoV
() {
return
99;}
100
static
unsigned
char
defaultV
() {
return
0;}
101
static
const
char
*
autoVS
() {
return
"_99_"
; }
102
static
const
char
*
defaultVS
() {
return
"_00_"
; }
103
106
std::string
m_versionKey
;
107
std::string
m_baseKey
;
108
};
109
}
// ns SG
110
112
bool
operator <
(
const
SG::VersionedKey
& lhs,
const
SG::VersionedKey
& rhs);
113
114
namespace
SG
{
115
inline
116
std::ostream&
operator <<
(std::ostream& ost,
const
SG::VersionedKey
& k) {
117
return
ost << k.rawVersionKey();
118
// return ost.write(k.rawVersionKey(), strlen(k.rawVersionKey()));
119
}
120
}
121
122
#endif
operator<
bool operator<(const SG::VersionedKey &lhs, const SG::VersionedKey &rhs)
sort according to highest key version
Definition
SGVersionedKey.cxx:91
SGImplSvc
The Athena Transient Store API.
Definition
SGImplSvc.h:109
SG::ObjectWithVersion
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
Definition
SGObjectWithVersion.h:20
SG::VersionedKey
a StoreGateSvc key with a version number.
Definition
SGVersionedKey.h:31
SG::VersionedKey::VersionedKey
VersionedKey(VersionedKey &&rhs)=default
SG::VersionedKey::autoV
static unsigned char autoV()
Definition
SGVersionedKey.h:99
SG::VersionedKey::sameKey
bool sameKey(const VersionedKey &vkey) const
compare base keys
Definition
SGVersionedKey.cxx:76
SG::VersionedKey::VersionedKey
VersionedKey(const char *key, unsigned char version)
version must be [0,98], 0 is the default version
Definition
SGVersionedKey.cxx:32
SG::VersionedKey::VersionedKey
VersionedKey(const VersionedKey &rhs)=default
SG::VersionedKey::defaultV
static unsigned char defaultV()
Definition
SGVersionedKey.h:100
SG::VersionedKey::version
unsigned char version() const
Definition
SGVersionedKey.cxx:67
SG::VersionedKey::isAuto
bool isAuto() const
Definition
SGVersionedKey.h:85
SG::VersionedKey::isVersionedKey
static bool isVersionedKey(const char *)
quickly determine whether a string has the right format to be a VK
Definition
SGVersionedKey.cxx:18
SG::VersionedKey::rawVersionKey
const std::string & rawVersionKey() const
Definition
SGVersionedKey.h:76
SG::VersionedKey::ObjectWithVersion
friend class ObjectWithVersion
Definition
SGVersionedKey.h:88
SG::VersionedKey::copyVK
void copyVK(const std::string &inKey)
Definition
SGVersionedKey.cxx:59
SG::VersionedKey::~VersionedKey
~VersionedKey()
Definition
SGVersionedKey.cxx:15
SG::VersionedKey::autoVS
static const char * autoVS()
Definition
SGVersionedKey.h:101
SG::VersionedKey::separator
static char separator()
Definition
SGVersionedKey.h:95
SG::VersionedKey::defaultVS
static const char * defaultVS()
Definition
SGVersionedKey.h:102
SG::VersionedKey::VersionedKey
VersionedKey()
default constructor (invalid state, do not use)
Definition
SGVersionedKey.h:90
SG::VersionedKey::encode
void encode(const std::string &inKey, unsigned char version)
Definition
SGVersionedKey.cxx:51
SG::VersionedKey::formatString
static const char * formatString()
Definition
SGVersionedKey.h:97
SG::VersionedKey::m_baseKey
std::string m_baseKey
Definition
SGVersionedKey.h:107
SG::VersionedKey::versionFormatString
static const char * versionFormatString()
Definition
SGVersionedKey.h:96
SG::VersionedKey::operator=
VersionedKey & operator=(const VersionedKey &rhs)=default
SG::VersionedKey::decode
void decode(std::string &outKey, unsigned char &version) const
sets outKey to point to base key, and version to encoded version (0 is taken to mean default version)...
Definition
SGVersionedKey.cxx:45
SG::VersionedKey::m_versionKey
std::string m_versionKey
the encoded version/key.
Definition
SGVersionedKey.h:106
SG::VersionedKey::key
const std::string & key() const
Definition
SGVersionedKey.cxx:71
StoreGateSvc
The Athena Transient Store API.
Definition
StoreGateSvc.h:120
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::operator<<
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
Definition
ArenaAllocatorBase.cxx:61
Generated on
for ATLAS Offline Software by
1.17.0