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
af6ef2a0
Commit
af6ef2a0
authored
Mar 22, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to set default INI file name
parent
b54c3372
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
17 deletions
+23
-17
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+7
-1
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+16
-16
No files found.
libcaf_core/caf/actor_system_config.hpp
View file @
af6ef2a0
...
...
@@ -358,6 +358,12 @@ public:
error_renderer_map
error_renderers
;
// -- parsing parameters -----------------------------------------------------
/// Configures the file path for the INI file, `caf-application.ini` per
/// default.
std
::
string
config_file_path
;
// -- convenience functions --------------------------------------------------
template
<
class
F
>
...
...
@@ -393,7 +399,7 @@ private:
static
std
::
string
render_exit_reason
(
uint8_t
,
atom_value
,
const
message
&
);
std
::
string
extract_config_file_name
(
message
&
args
);
void
extract_config_file_path
(
message
&
args
);
option_vector
options_
;
};
...
...
libcaf_core/src/actor_system_config.cpp
View file @
af6ef2a0
...
...
@@ -101,7 +101,8 @@ actor_system_config::actor_system_config()
slave_mode
(
false
),
logger_filename
(
logger_file_name
),
logger_filter
(
logger_component_filter
),
slave_mode_fun
(
nullptr
)
{
slave_mode_fun
(
nullptr
),
config_file_path
(
"caf-application.ini"
)
{
// add `vector<T>` and `stream<T>` for each statically known type
add_message_type_impl
<
stream
<
actor
>>
(
"stream<@actor>"
);
add_message_type_impl
<
stream
<
actor_addr
>>
(
"stream<@addr>"
);
...
...
@@ -282,18 +283,7 @@ actor_system_config& actor_system_config::parse(int argc, char** argv,
message
args
;
if
(
argc
>
1
)
args
=
message_builder
(
argv
+
1
,
argv
+
argc
).
move_to_message
();
// set default config file name if not set by user
if
(
ini_file_cstr
==
nullptr
)
ini_file_cstr
=
"caf-application.ini"
;
std
::
string
config_file_name
;
// CLI file name has priority over default file name
args
.
extract_opts
({
{
"caf#config-file"
,
""
,
config_file_name
}
});
if
(
config_file_name
.
empty
())
config_file_name
=
ini_file_cstr
;
std
::
ifstream
ini
{
config_file_name
};
return
parse
(
args
,
ini
);
return
parse
(
args
,
ini_file_cstr
);
}
actor_system_config
&
actor_system_config
::
parse
(
int
argc
,
char
**
argv
,
...
...
@@ -306,9 +296,12 @@ actor_system_config& actor_system_config::parse(int argc, char** argv,
actor_system_config
&
actor_system_config
::
parse
(
message
&
args
,
const
char
*
ini_file_cstr
)
{
if
(
ini_file_cstr
==
nullptr
)
ini_file_cstr
=
"caf-application.ini"
;
std
::
ifstream
ini
{
ini_file_cstr
};
// Override default config file name if set by user.
if
(
ini_file_cstr
!=
nullptr
)
config_file_path
=
ini_file_cstr
;
// CLI arguments always win.
extract_config_file_path
(
args
);
std
::
ifstream
ini
{
config_file_path
};
return
parse
(
args
,
ini
);
}
...
...
@@ -459,4 +452,11 @@ std::string actor_system_config::render_exit_reason(uint8_t x, atom_value,
meta
::
omittable_if_empty
(),
xs
);
}
void
actor_system_config
::
extract_config_file_path
(
message
&
args
)
{
auto
res
=
args
.
extract_opts
({
{
"caf#config-file"
,
""
,
config_file_path
}
});
args
=
res
.
remainder
;
}
}
// namespace caf
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