Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scdaq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scouting-demonstrator
scdaq
Commits
b98d604c
Commit
b98d604c
authored
1 year ago
by
Giovanna Lazzari Miotto
Browse files
Options
Downloads
Patches
Plain Diff
except: Handle parsing errors
parent
4be5a1f8
No related branches found
No related tags found
1 merge request
!86
refactor: config: Overhaul `Config` interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/config.cc
+39
-6
39 additions, 6 deletions
src/config.cc
with
39 additions
and
6 deletions
src/config.cc
+
39
−
6
View file @
b98d604c
...
@@ -17,17 +17,50 @@ bool ends_with(const std::string &str, const std::string &suffix) {
...
@@ -17,17 +17,50 @@ bool ends_with(const std::string &str, const std::string &suffix) {
template
<
>
template
<
>
uint32_t
ConfigMap
::
Get
<
uint32_t
>
(
const
std
::
string
&
k
)
{
uint32_t
ConfigMap
::
Get
<
uint32_t
>
(
const
std
::
string
&
k
)
{
return
get
(
k
).
asUInt
();
ValueType
value
=
get
(
k
);
try
{
return
value
.
asUInt
();
}
catch
(
std
::
exception
&
e
)
{
LOG
(
DEBUG
)
<<
"Value '"
<<
value
.
asString
()
<<
"' not natively convertible to uint32"
;
try
{
return
static_cast
<
uint32_t
>
(
std
::
stoul
(
value
.
asString
()));
}
catch
(
std
::
exception
&
e
)
{
LOG
(
ERROR
)
<<
"Configuration error with key: '"
<<
k
<<
"'"
;
throw
;
}
}
}
}
template
<
>
template
<
>
uint64_t
ConfigMap
::
Get
<
uint64_t
>
(
const
std
::
string
&
k
)
{
uint64_t
ConfigMap
::
Get
<
uint64_t
>
(
const
std
::
string
&
k
)
{
return
get
(
k
).
asUInt64
();
ValueType
value
=
get
(
k
);
try
{
return
value
.
asUInt64
();
}
catch
(
std
::
exception
&
e
)
{
LOG
(
DEBUG
)
<<
"Value '"
<<
value
.
asString
()
<<
"' not natively convertible to uint64"
;
try
{
return
static_cast
<
uint64_t
>
(
std
::
stoul
(
value
.
asString
()));
}
catch
(
std
::
exception
&
e
)
{
LOG
(
ERROR
)
<<
"Configuration error with key: '"
<<
k
<<
"'"
;
throw
;
}
}
}
}
template
<
>
template
<
>
int
ConfigMap
::
Get
<
int
>
(
const
std
::
string
&
k
)
{
int
ConfigMap
::
Get
<
int
>
(
const
std
::
string
&
k
)
{
return
get
(
k
).
asInt
();
ValueType
value
=
get
(
k
);
try
{
return
value
.
asInt
();
}
catch
(
std
::
exception
&
e
)
{
LOG
(
DEBUG
)
<<
"Value '"
<<
value
.
asString
()
<<
"' not natively convertible to integer"
;
try
{
return
std
::
stoi
(
value
.
asString
());
}
catch
(
std
::
exception
&
e
)
{
LOG
(
ERROR
)
<<
"Configuration error with key: '"
<<
k
<<
"'"
;
throw
;
}
}
}
}
template
<
>
template
<
>
...
@@ -128,8 +161,8 @@ Config::Config(const std::string &filename) {
...
@@ -128,8 +161,8 @@ Config::Config(const std::string &filename) {
dma_device_
=
dict_
.
at
(
"dma_dev"
);
dma_device_
=
dict_
.
at
(
"dma_dev"
);
attempt_tcp_reconnect_
=
dict_
.
Get
<
bool
>
(
"dev_TCPAutoReconnectOnFailure"
);
attempt_tcp_reconnect_
=
dict_
.
Get
<
bool
>
(
"dev_TCPAutoReconnectOnFailure"
);
source_id_
=
dict_
.
Get
<
uint32_t
>
(
"sourceID"
);
//
source_id_ = dict_.Get<uint32_t>("sourceID");
port_
=
dict_
.
Get
<
u
int
32_t
>
(
"port"
),
port_
=
dict_
.
Get
<
int
>
(
"port"
),
num_threads_
=
dict_
.
Get
<
uint32_t
>
(
"threads"
);
num_threads_
=
dict_
.
Get
<
uint32_t
>
(
"threads"
);
max_file_size_
=
dict_
.
Get
<
uint64_t
>
(
"max_file_size"
);
max_file_size_
=
dict_
.
Get
<
uint64_t
>
(
"max_file_size"
);
...
@@ -147,7 +180,7 @@ Config::Config(const std::string &filename) {
...
@@ -147,7 +180,7 @@ Config::Config(const std::string &filename) {
num_orbits_per_file_
=
dict_
.
Get
<
uint64_t
>
(
"nOrbitsPerFile"
);
num_orbits_per_file_
=
dict_
.
Get
<
uint64_t
>
(
"nOrbitsPerFile"
);
force_write_out_
=
dict_
.
Get
<
bool
>
(
"output_force_write"
);
force_write_out_
=
dict_
.
Get
<
bool
>
(
"output_force_write"
);
processor_type_
=
ToProcessorType
(
dict_
.
Get
(
"processor
T
ype"
));
processor_type_
=
ToProcessorType
(
dict_
.
Get
(
"processor
_t
ype"
));
enable_processing_
=
dict_
.
Get
<
bool
>
(
"enable_stream_processor"
);
enable_processing_
=
dict_
.
Get
<
bool
>
(
"enable_stream_processor"
);
apply_zero_suppression_
=
dict_
.
Get
<
bool
>
(
"doZS"
);
apply_zero_suppression_
=
dict_
.
Get
<
bool
>
(
"doZS"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment