Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Corryvreckan
Corryvreckan
Commits
51f26230
Commit
51f26230
authored
Jul 03, 2018
by
Simon Spannagel
Browse files
Config: allow setting Matrices
parent
82b93bd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/core/config/Configuration.hpp
View file @
51f26230
...
...
@@ -165,6 +165,13 @@ namespace corryvreckan {
// TODO [doc] Provide second template parameter to specify the vector type to return it in
template
<
typename
T
>
void
setArray
(
const
std
::
string
&
key
,
const
std
::
vector
<
T
>&
val
);
/**
* @brief Set matrix of values for a key in a given type
* @param key Key to set values of
* @param val List of values to assign to the key
*/
template
<
typename
T
>
void
setMatrix
(
const
std
::
string
&
key
,
const
Matrix
<
T
>&
val
);
/**
* @brief Set default value for a key only if it is not defined yet
* @param key Key to possible set value of
...
...
src/core/config/Configuration.tpp
View file @
51f26230
...
...
@@ -154,6 +154,27 @@ namespace corryvreckan {
config_
[
key
]
=
str
;
}
template
<
typename
T
>
void
Configuration
::
setMatrix
(
const
std
::
string
&
key
,
const
Matrix
<
T
>&
val
)
{
// NOTE: not the most elegant way to support arrays
if
(
val
.
empty
())
{
return
;
}
std
::
string
str
=
"["
;
for
(
auto
&
col
:
val
)
{
str
+=
"["
;
for
(
auto
&
el
:
col
)
{
str
+=
corryvreckan
::
to_string
(
el
);
str
+=
","
;
}
str
.
pop_back
();
str
+=
"],"
;
}
str
.
pop_back
();
str
+=
"]"
;
config_
[
key
]
=
str
;
}
template
<
typename
T
>
void
Configuration
::
setDefault
(
const
std
::
string
&
key
,
const
T
&
val
)
{
if
(
!
has
(
key
))
{
set
<
T
>
(
key
,
val
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment