MarlinMT
0.1.0
RunHeader.h
Go to the documentation of this file.
1
#pragma once
2
3
// -- std headers
4
#include <string>
5
#include <map>
6
7
// -- marlinmt headers
8
#include <
marlinmt/Extensions.h
>
9
#include <
marlinmt/Utils.h
>
10
11
namespace
marlinmt
{
12
22
class
RunHeader
{
23
using
ParameterMap
= std::map<std::string, std::string> ;
24
25
public
:
26
RunHeader
() = default ;
27
~RunHeader
() = default ;
28
RunHeader
(
const
RunHeader
&) = delete ;
29
RunHeader
&
operator=
(
const
RunHeader
&) = delete ;
30
RunHeader
(
RunHeader
&&) = default ;
31
RunHeader
&
operator=
(
RunHeader
&&) = default ;
32
36
int
runNumber
()
const
;
37
43
RunHeader
&
setRunNumber
(
int
n ) ;
44
48
const
std::string &
description
()
const
;
49
55
RunHeader
&
setDescription
(
const
std::string &desc ) ;
56
60
const
std::string &
detectorName
()
const
;
61
67
RunHeader
&
setDetectorName
(
const
std::string &det ) ;
68
72
const
ParameterMap
&
parameters
()
const
;
73
77
ParameterMap
&
parameters
() ;
78
84
template
<
typename
T>
85
std::optional<T>
parameter
(
const
std::string &name )
const
;
86
94
template
<
typename
T>
95
RunHeader
&
setParameter
(
const
std::string &name,
const
T &
value
) ;
96
100
Extensions
&
extensions
() ;
101
105
const
Extensions
&
extensions
()
const
;
106
107
private
:
109
int
_runNumber
{0} ;
111
std::string
_detectorName
{} ;
113
std::string
_description
{} ;
115
ParameterMap
_parameters
{} ;
117
Extensions
_extensions
{} ;
118
};
119
120
//--------------------------------------------------------------------------
121
//--------------------------------------------------------------------------
122
123
inline
int
RunHeader::runNumber
()
const
{
124
return
_runNumber
;
125
}
126
127
//--------------------------------------------------------------------------
128
129
inline
RunHeader
&
RunHeader::setRunNumber
(
int
n ) {
130
_runNumber
= n ;
131
return
*this ;
132
}
133
134
//--------------------------------------------------------------------------
135
136
inline
const
std::string &
RunHeader::description
()
const
{
137
return
_description
;
138
}
139
140
//--------------------------------------------------------------------------
141
142
inline
RunHeader
&
RunHeader::setDescription
(
const
std::string &desc ) {
143
_description
= desc ;
144
return
*this ;
145
}
146
147
//--------------------------------------------------------------------------
148
149
inline
const
std::string &
RunHeader::detectorName
()
const
{
150
return
_detectorName
;
151
}
152
153
//--------------------------------------------------------------------------
154
155
inline
RunHeader
&
RunHeader::setDetectorName
(
const
std::string &det ) {
156
_detectorName
= det ;
157
return
*this ;
158
}
159
160
//--------------------------------------------------------------------------
161
162
inline
const
RunHeader::ParameterMap
&
RunHeader::parameters
()
const
{
163
return
_parameters
;
164
}
165
166
//--------------------------------------------------------------------------
167
168
inline
RunHeader::ParameterMap
&
RunHeader::parameters
() {
169
return
_parameters
;
170
}
171
172
//--------------------------------------------------------------------------
173
174
template
<
typename
T>
175
inline
std::optional<T>
RunHeader::parameter
(
const
std::string &name )
const
{
176
auto
iter =
_parameters
.find( name ) ;
177
if
(
_parameters
.end() != iter ) {
178
return
details::convert<T>::from_string
( iter->second ) ;
179
}
180
return
std::nullopt ;
181
}
182
183
//--------------------------------------------------------------------------
184
185
template
<
typename
T>
186
inline
RunHeader
&
RunHeader::setParameter
(
const
std::string &name,
const
T &
value
) {
187
_parameters
[name] =
details::convert<T>::to_string
( value ) ;
188
return
*this ;
189
}
190
191
//--------------------------------------------------------------------------
192
193
inline
Extensions
&
RunHeader::extensions
() {
194
return
_extensions
;
195
}
196
197
//--------------------------------------------------------------------------
198
199
inline
const
Extensions
&
RunHeader::extensions
()
const
{
200
return
_extensions
;
201
}
202
203
}
marlinmt::RunHeader::setRunNumber
RunHeader & setRunNumber(int n)
Set the run number.
Definition:
RunHeader.h:129
marlinmt::RunHeader::parameters
const ParameterMap & parameters() const
Get the run parameters.
Definition:
RunHeader.h:162
marlinmt::RunHeader::_parameters
ParameterMap _parameters
The run parameters map.
Definition:
RunHeader.h:115
marlinmt::RunHeader::setDetectorName
RunHeader & setDetectorName(const std::string &det)
Set the detector name.
Definition:
RunHeader.h:155
marlinmt::RunHeader::extensions
Extensions & extensions()
Get the run extensions.
Definition:
RunHeader.h:193
marlinmt::RunHeader::setDescription
RunHeader & setDescription(const std::string &desc)
Set the run description.
Definition:
RunHeader.h:142
marlinmt::Extensions
Extensions class.
Definition:
Extensions.h:71
marlinmt::book::Flags::value
constexpr unsigned long long value(const Flag_t &flag)
Definition:
Flags.h:106
Utils.h
marlinmt::RunHeader::_extensions
Extensions _extensions
The run extensions.
Definition:
RunHeader.h:117
marlinmt::RunHeader::RunHeader
RunHeader()=default
marlinmt::RunHeader::_detectorName
std::string _detectorName
The detector name.
Definition:
RunHeader.h:111
marlinmt::details::convert::from_string
static T from_string(const std::string &str)
Definition:
Utils.h:378
marlinmt::RunHeader::ParameterMap
std::map< std::string, std::string > ParameterMap
Definition:
RunHeader.h:23
marlinmt
Definition:
BookStore.h:29
marlinmt::RunHeader::detectorName
const std::string & detectorName() const
Get the detector name.
Definition:
RunHeader.h:149
Extensions.h
marlinmt::RunHeader::parameter
std::optional< T > parameter(const std::string &name) const
Get a parameter by name.
Definition:
RunHeader.h:175
marlinmt::RunHeader::_description
std::string _description
The run description.
Definition:
RunHeader.h:113
marlinmt::details::convert::to_string
static std::string to_string(const T &value)
Definition:
Utils.h:370
marlinmt::RunHeader
RunHeader class.
Definition:
RunHeader.h:22
marlinmt::RunHeader::_runNumber
int _runNumber
The run number.
Definition:
RunHeader.h:109
marlinmt::RunHeader::operator=
RunHeader & operator=(const RunHeader &)=delete
marlinmt::RunHeader::~RunHeader
~RunHeader()=default
marlinmt::RunHeader::description
const std::string & description() const
Get the run description.
Definition:
RunHeader.h:136
marlinmt::RunHeader::runNumber
int runNumber() const
Get the run number.
Definition:
RunHeader.h:123
marlinmt::RunHeader::setParameter
RunHeader & setParameter(const std::string &name, const T &value)
Set a run parameter.
Definition:
RunHeader.h:186
source
framework
include
marlinmt
RunHeader.h
Generated by
1.8.13