Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
d633d19e
Commit
d633d19e
authored
Nov 09, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'topic/config_option_set'
parents
84607e71
49f51fdc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
23 deletions
+54
-23
libcaf_core/caf/config_option_set.hpp
libcaf_core/caf/config_option_set.hpp
+44
-9
libcaf_core/src/config_option_set.cpp
libcaf_core/src/config_option_set.cpp
+0
-4
libcaf_core/test/config_option_set.cpp
libcaf_core/test/config_option_set.cpp
+3
-3
libcaf_core/test/ini_consumer.cpp
libcaf_core/test/ini_consumer.cpp
+7
-7
No files found.
libcaf_core/caf/config_option_set.hpp
View file @
d633d19e
...
@@ -59,10 +59,6 @@ public:
...
@@ -59,10 +59,6 @@ public:
/// Categorized settings.
/// Categorized settings.
using
config_map
=
caf
::
dictionary
<
dictionary
>
;
using
config_map
=
caf
::
dictionary
<
dictionary
>
;
// -- constructors, destructors, and assignment operators --------------------
config_option_set
();
// -- properties -------------------------------------------------------------
// -- properties -------------------------------------------------------------
/// Returns the first `config_option` that matches the CLI name.
/// Returns the first `config_option` that matches the CLI name.
...
@@ -84,34 +80,73 @@ public:
...
@@ -84,34 +80,73 @@ public:
option_pointer
qualified_name_lookup
(
string_view
name
)
const
;
option_pointer
qualified_name_lookup
(
string_view
name
)
const
;
/// Returns the number of stored config options.
/// Returns the number of stored config options.
inline
size_t
size
()
const
noexcept
{
size_t
size
()
const
noexcept
{
return
opts_
.
size
();
return
opts_
.
size
();
}
}
/// Returns an iterator to the first ::config_option object.
/// Returns an iterator to the first ::config_option object.
i
nline
i
terator
begin
()
noexcept
{
iterator
begin
()
noexcept
{
return
opts_
.
begin
();
return
opts_
.
begin
();
}
}
/// Returns the past-the-end iterator.
/// Returns the past-the-end iterator.
i
nline
i
terator
end
()
noexcept
{
iterator
end
()
noexcept
{
return
opts_
.
end
();
return
opts_
.
end
();
}
}
/// Adds a config option to the set.
/// Adds a config option to the set.
template
<
class
T
>
template
<
class
T
>
config_option_set
&
add
(
string_view
category
,
string_view
name
,
config_option_set
&
add
(
string_view
category
,
string_view
name
,
string_view
description
=
""
)
{
string_view
description
)
&
{
return
add
(
make_config_option
<
T
>
(
category
,
name
,
description
));
return
add
(
make_config_option
<
T
>
(
category
,
name
,
description
));
}
}
/// Adds a config option to the set.
template
<
class
T
>
config_option_set
&
add
(
string_view
name
,
string_view
description
)
&
{
return
add
(
make_config_option
<
T
>
(
"global"
,
name
,
description
));
}
/// Adds a config option to the set.
template
<
class
T
>
config_option_set
&&
add
(
string_view
category
,
string_view
name
,
string_view
description
)
&&
{
return
std
::
move
(
add
<
T
>
(
category
,
name
,
description
));
}
/// Adds a config option to the set.
template
<
class
T
>
config_option_set
&&
add
(
string_view
name
,
string_view
description
)
&&
{
return
std
::
move
(
add
<
T
>
(
"global"
,
name
,
description
));
}
/// Adds a config option to the set that synchronizes its value with `ref`.
/// Adds a config option to the set that synchronizes its value with `ref`.
template
<
class
T
>
template
<
class
T
>
config_option_set
&
add
(
T
&
ref
,
string_view
category
,
string_view
name
,
config_option_set
&
add
(
T
&
ref
,
string_view
category
,
string_view
name
,
string_view
description
=
""
)
{
string_view
description
)
&
{
return
add
(
make_config_option
<
T
>
(
ref
,
category
,
name
,
description
));
return
add
(
make_config_option
<
T
>
(
ref
,
category
,
name
,
description
));
}
}
/// Adds a config option to the set that synchronizes its value with `ref`.
template
<
class
T
>
config_option_set
&
add
(
T
&
ref
,
string_view
name
,
string_view
description
)
&
{
return
add
(
ref
,
"global"
,
name
,
description
);
}
/// Adds a config option to the set that synchronizes its value with `ref`.
template
<
class
T
>
config_option_set
&&
add
(
T
&
ref
,
string_view
category
,
string_view
name
,
string_view
description
)
&&
{
return
std
::
move
(
add
(
ref
,
category
,
name
,
description
));
}
/// Adds a config option to the set that synchronizes its value with `ref`.
template
<
class
T
>
config_option_set
&&
add
(
T
&
ref
,
string_view
name
,
string_view
description
)
&&
{
return
std
::
move
(
add
(
ref
,
"global"
,
name
,
description
));
}
/// Adds a config option to the set.
/// Adds a config option to the set.
/// @private
/// @private
config_option_set
&
add
(
config_option
&&
opt
);
config_option_set
&
add
(
config_option
&&
opt
);
...
...
libcaf_core/src/config_option_set.cpp
View file @
d633d19e
...
@@ -52,10 +52,6 @@ void insert(string_builder& builder, size_t count, char ch) {
...
@@ -52,10 +52,6 @@ void insert(string_builder& builder, size_t count, char ch) {
namespace
caf
{
namespace
caf
{
config_option_set
::
config_option_set
()
{
// nop
}
config_option_set
&
config_option_set
::
add
(
config_option
&&
opt
)
{
config_option_set
&
config_option_set
::
add
(
config_option
&&
opt
)
{
opts_
.
emplace_back
(
std
::
move
(
opt
));
opts_
.
emplace_back
(
std
::
move
(
opt
));
return
*
this
;
return
*
this
;
...
...
libcaf_core/test/config_option_set.cpp
View file @
d633d19e
...
@@ -43,7 +43,7 @@ struct fixture {
...
@@ -43,7 +43,7 @@ struct fixture {
CAF_TEST_FIXTURE_SCOPE
(
config_option_set_tests
,
fixture
)
CAF_TEST_FIXTURE_SCOPE
(
config_option_set_tests
,
fixture
)
CAF_TEST
(
lookup
)
{
CAF_TEST
(
lookup
)
{
opts
.
add
<
int
>
(
"
global"
,
"
opt1,1"
,
"test option 1"
)
opts
.
add
<
int
>
(
"opt1,1"
,
"test option 1"
)
.
add
<
float
>
(
"test"
,
"opt2,2"
,
"test option 2"
)
.
add
<
float
>
(
"test"
,
"opt2,2"
,
"test option 2"
)
.
add
<
bool
>
(
"test"
,
"flag,fl3"
,
"test flag"
);
.
add
<
bool
>
(
"test"
,
"flag,fl3"
,
"test flag"
);
CAF_CHECK_EQUAL
(
opts
.
size
(),
3u
);
CAF_CHECK_EQUAL
(
opts
.
size
(),
3u
);
...
@@ -101,7 +101,7 @@ CAF_TEST(parse with ref syncing) {
...
@@ -101,7 +101,7 @@ CAF_TEST(parse with ref syncing) {
}
}
CAF_TEST
(
implicit
global
)
{
CAF_TEST
(
implicit
global
)
{
opts
.
add
<
int
>
(
"
global"
,
"value"
).
add
<
bool
>
(
"global"
,
"help
"
);
opts
.
add
<
int
>
(
"
value"
,
"some value"
).
add
<
bool
>
(
"help"
,
"print help text
"
);
CAF_MESSAGE
(
"test long option with argument"
);
CAF_MESSAGE
(
"test long option with argument"
);
dictionary
<
config_value
::
dictionary
>
cfg
;
dictionary
<
config_value
::
dictionary
>
cfg
;
auto
res
=
opts
.
parse
(
cfg
,
{
"--value=42"
});
auto
res
=
opts
.
parse
(
cfg
,
{
"--value=42"
});
...
@@ -115,7 +115,7 @@ CAF_TEST(implicit global) {
...
@@ -115,7 +115,7 @@ CAF_TEST(implicit global) {
}
}
CAF_TEST
(
atom
parameters
)
{
CAF_TEST
(
atom
parameters
)
{
opts
.
add
<
atom_value
>
(
"
global"
,
"value,v
"
);
opts
.
add
<
atom_value
>
(
"
value,v"
,
"some value
"
);
CAF_MESSAGE
(
"test atom option without quotes"
);
CAF_MESSAGE
(
"test atom option without quotes"
);
auto
parse_args
=
[
&
](
std
::
vector
<
std
::
string
>
args
)
->
expected
<
atom_value
>
{
auto
parse_args
=
[
&
](
std
::
vector
<
std
::
string
>
args
)
->
expected
<
atom_value
>
{
dictionary
<
config_value
::
dictionary
>
cfg
;
dictionary
<
config_value
::
dictionary
>
cfg
;
...
...
libcaf_core/test/ini_consumer.cpp
View file @
d633d19e
...
@@ -51,13 +51,13 @@ struct fixture {
...
@@ -51,13 +51,13 @@ struct fixture {
config_option_set
::
config_map
config
;
config_option_set
::
config_map
config
;
fixture
()
{
fixture
()
{
options
.
add
<
bool
>
(
"global"
,
"is_server"
)
options
.
add
<
bool
>
(
"global"
,
"is_server"
,
"enables server mode"
)
.
add
<
uint16_t
>
(
"global"
,
"port"
)
.
add
<
uint16_t
>
(
"global"
,
"port"
,
"sets local or remote port"
)
.
add
<
ls
>
(
"global"
,
"nodes"
)
.
add
<
ls
>
(
"global"
,
"nodes"
,
"list of remote nodes"
)
.
add
<
string
>
(
"logger"
,
"file-name"
)
.
add
<
string
>
(
"logger"
,
"file-name"
,
"log output file"
)
.
add
<
int
>
(
"scheduler"
,
"padding"
)
.
add
<
int
>
(
"scheduler"
,
"padding"
,
"some integer"
)
.
add
<
timespan
>
(
"scheduler"
,
"timing"
)
.
add
<
timespan
>
(
"scheduler"
,
"timing"
,
"some timespan"
)
.
add
<
atom_value
>
(
"scheduler"
,
"impl"
);
.
add
<
atom_value
>
(
"scheduler"
,
"impl"
,
"some atom"
);
}
}
};
};
...
...
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