Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApplicationCore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
ChimeraTK Mirror
ApplicationCore
Commits
50d5a70f
Commit
50d5a70f
authored
2 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
fix Booleans in ConfigReader
parent
68e82ab5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/src/ConfigReader.cc
+2
-68
2 additions, 68 deletions
Modules/src/ConfigReader.cc
with
2 additions
and
68 deletions
Modules/src/ConfigReader.cc
+
2
−
68
View file @
50d5a70f
...
...
@@ -212,19 +212,7 @@ namespace ChimeraTK {
template
<
typename
T
>
void
ConfigReader
::
createVar
(
const
std
::
string
&
name
,
const
std
::
string
&
value
)
{
// convert value into user type
/// @todo error handling!
std
::
stringstream
stream
(
value
);
T
convertedValue
;
if
constexpr
(
std
::
is_same
<
T
,
int8_t
>::
value
||
std
::
is_same
<
T
,
uint8_t
>::
value
)
{
// prevent interpreting int8-types as characters
int16_t
intermediate
;
stream
>>
intermediate
;
convertedValue
=
intermediate
;
}
else
{
// note: string is done in template specialisation
stream
>>
convertedValue
;
}
T
convertedValue
=
ChimeraTK
::
userTypeToUserType
<
T
>
(
value
);
auto
moduleName
=
branch
(
name
);
auto
varName
=
leaf
(
name
);
...
...
@@ -237,20 +225,6 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
template
<
>
void
ConfigReader
::
createVar
<
std
::
string
>
(
const
std
::
string
&
name
,
const
std
::
string
&
value
)
{
auto
moduleName
=
branch
(
name
);
auto
varName
=
leaf
(
name
);
auto
varOwner
=
_moduleTree
->
lookup
(
moduleName
);
// place the variable onto the vector
std
::
unordered_map
<
std
::
string
,
ConfigReader
::
Var
<
std
::
string
>>&
theMap
=
boost
::
fusion
::
at_key
<
std
::
string
>
(
variableMap
.
table
);
theMap
.
emplace
(
std
::
make_pair
(
name
,
ConfigReader
::
Var
<
std
::
string
>
(
varOwner
,
varName
,
value
)));
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
template
<
typename
T
>
...
...
@@ -268,17 +242,7 @@ namespace ChimeraTK {
++
expectedIndex
;
// convert value into user type
std
::
stringstream
stream
(
it
->
second
);
T
convertedValue
;
if
constexpr
(
std
::
is_same
<
T
,
int8_t
>::
value
||
std
::
is_same
<
T
,
uint8_t
>::
value
)
{
// prevent interpreting int8-types as characters
int16_t
intermediate
;
stream
>>
intermediate
;
convertedValue
=
intermediate
;
}
else
{
// note: string is done in template specialisation
stream
>>
convertedValue
;
}
T
convertedValue
=
ChimeraTK
::
userTypeToUserType
<
T
>
(
it
->
second
);
// store value in vector
Tvalues
.
push_back
(
convertedValue
);
...
...
@@ -295,36 +259,6 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
template
<
>
void
ConfigReader
::
createArray
<
std
::
string
>
(
const
std
::
string
&
name
,
const
std
::
map
<
size_t
,
std
::
string
>&
values
)
{
std
::
vector
<
std
::
string
>
Tvalues
;
size_t
expectedIndex
=
0
;
for
(
auto
it
=
values
.
begin
();
it
!=
values
.
end
();
++
it
)
{
// check index (std::map should be ordered by the index)
if
(
it
->
first
!=
expectedIndex
)
{
parsingError
(
"Array index "
+
std
::
to_string
(
expectedIndex
)
+
" not found, but "
+
std
::
to_string
(
it
->
first
)
+
" was. "
"Sparse arrays are not supported!"
);
}
++
expectedIndex
;
// store value in vector
Tvalues
.
push_back
(
it
->
second
);
}
auto
moduleName
=
branch
(
name
);
auto
arrayName
=
leaf
(
name
);
auto
arrayOwner
=
_moduleTree
->
lookup
(
moduleName
);
// place the variable onto the vector
std
::
unordered_map
<
std
::
string
,
ConfigReader
::
Array
<
std
::
string
>>&
theMap
=
boost
::
fusion
::
at_key
<
std
::
string
>
(
arrayMap
.
table
);
theMap
.
emplace
(
std
::
make_pair
(
name
,
ConfigReader
::
Array
<
std
::
string
>
(
arrayOwner
,
arrayName
,
Tvalues
)));
}
/*********************************************************************************************************************/
ConfigReader
::
ConfigReader
(
EntityOwner
*
owner
,
const
std
::
string
&
name
,
const
std
::
string
&
fileName
,
HierarchyModifier
hierarchyModifier
,
const
std
::
unordered_set
<
std
::
string
>&
tags
)
:
ApplicationModule
(
owner
,
name
,
"Configuration read from file '"
+
fileName
+
"'"
,
hierarchyModifier
,
tags
),
...
...
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