C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::actor_system_config Class Reference

Configures an actor_system on startup. More...

#include <actor_system_config.hpp>

Public Types

using opt_group = config_option_adder
 

Public Member Functions

 actor_system_config (actor_system_config &&)=default
 
 actor_system_config (const actor_system_config &)=delete
 
actor_system_configoperator= (const actor_system_config &)=delete
 
virtual settings dump_content () const
 Extracts all parameters from the config, including entries with default values.
 
template<class T >
actor_system_configset (std::string_view name, T &&value)
 Sets a config by using its name config_name to config_value.
 
error parse (std::vector< std::string > args, std::istream &config)
 Parses args as tuple of strings containing CLI options and config as configuration file.
 
error parse (std::vector< std::string > args)
 Parses args as CLI options and tries to locate a config file via config_file_path and config_file_path_alternative unless the user provides a config file path on the command line.
 
error parse (int argc, char **argv, std::istream &config)
 Parses the CLI options {argc, argv} and config as configuration file.
 
error parse (int argc, char **argv)
 Parses the CLI options {argc, argv} and tries to locate a config file via config_file_path and config_file_path_alternative unless the user provides a config file path on the command line.
 
actor_system_configadd_actor_factory (std::string name, actor_factory fun)
 Allows other nodes to spawn actors created by fun dynamically by using name as identifier.
 
template<class T , class... Ts>
actor_system_configadd_actor_type (std::string name)
 Allows other nodes to spawn actors of type T dynamically by using name as identifier.
 
template<class F , class T , class... Ts>
actor_system_configadd_actor_type (std::string name, F f, T t, Ts... ts)
 Allows other nodes to spawn actors implemented as an actor_from_state<T> dynamically by using name as identifier.
 
template<class F >
actor_system_configadd_actor_type (std::string name, F f)
 Allows other nodes to spawn actors implemented by function f dynamically by using name as identifier.
 
template<class T >
actor_system_configload (version::abi_token token=make_abi_token())
 Loads module T.
 
template<class Hook , class... Ts>
actor_system_configadd_thread_hook (Ts &&... ts)
 Adds a hook type to the scheduler.
 
bool helptext_printed () const noexcept
 Returns whether the help text was printed.
 
const std::string & program_name () const noexcept
 Stores the content of argv[0] from the arguments passed to parse.
 
span< const std::string > remainder () const noexcept
 Stores CLI arguments that were not consumed by CAF.
 
std::pair< int, char ** > c_args_remainder () const noexcept
 Returns the remainder including the program name (argv[0]) suitable for passing the returned pair of arguments to C-style functions that usually accept (argc, argv) input as passed to main.
 
void config_file_path (std::string path)
 Sets the default path of the configuration file.
 
void config_file_paths (std::vector< std::string > paths)
 Sets the default paths of the configuration file.
 
span< const std::string > config_file_paths ()
 Returns the default paths of the configuration file.
 

Static Public Member Functions

static expected< settingsparse_config_file (const char *filename)
 Tries to open filename and parses its content as CAF config file.
 
static expected< settingsparse_config_file (const char *filename, const config_option_set &opts)
 Tries to open filename and parses its content as CAF config file.
 
static error parse_config_file (const char *filename, const config_option_set &opts, settings &result)
 Tries to open filename, parses its content as CAF config file and stores all entries in result (overrides conflicting entries).
 
static expected< settingsparse_config (std::istream &source)
 Parses the content of source using CAF's config format.
 
static expected< settingsparse_config (std::istream &source, const config_option_set &opts)
 Parses the content of source using CAF's config format.
 
static error parse_config (std::istream &source, const config_option_set &opts, settings &result)
 Parses the content of source using CAF's config format and stores all entries in result (overrides conflicting entries).
 

Public Attributes

settings content
 Stores user-defined configuration parameters.
 

Protected Attributes

config_option_set custom_options_
 

Friends

class actor_system
 
class detail::actor_system_config_access
 

Related Symbols

(Note that these are not member symbols.)

template<class T >
bool holds_alternative (const actor_system_config &cfg, std::string_view name)
 Returns whether xs associates a value of type T to name.
 
template<class T >
auto get_if (const actor_system_config *cfg, std::string_view name)
 Tries to retrieve the value associated to name from cfg.
 
template<class T >
get (const actor_system_config &cfg, std::string_view name)
 Retrieves the value associated to name from cfg.
 
template<class To = get_or_auto_deduce, class Fallback >
auto get_or (const actor_system_config &cfg, std::string_view name, Fallback &&fallback)
 Retrieves the value associated to name from cfg or returns fallback.
 
template<class T >
expected< T > get_as (const actor_system_config &cfg, std::string_view name)
 Tries to retrieve the value associated to name from cfg as an instance of type T.
 
CAF_CORE_EXPORT const settingscontent (const actor_system_config &)
 
template<class T >
get (const settings &xs, std::string_view name)
 Retrieves the value associated to name from xs.
 
template<class To = get_or_auto_deduce, class Fallback >
auto get_or (const settings &xs, std::string_view name, Fallback &&fallback)
 Retrieves the value associated to name from xs or returns fallback.
 
template<class T >
expected< T > get_as (const settings &xs, std::string_view name)
 Tries to retrieve the value associated to name from xs as an instance of type T.
 

Detailed Description

Configures an actor_system on startup.

Member Function Documentation

◆ add_actor_type()

template<class F , class T , class... Ts>
actor_system_config & caf::actor_system_config::add_actor_type ( std::string name,
F f,
T t,
Ts... ts )

Allows other nodes to spawn actors implemented as an actor_from_state<T> dynamically by using name as identifier.

Parameters
tconveys the state constructor signature as a type list.
tstype lists conveying alternative constructor signatures.

◆ c_args_remainder()

std::pair< int, char ** > caf::actor_system_config::c_args_remainder ( ) const
noexcept

Returns the remainder including the program name (argv[0]) suitable for passing the returned pair of arguments to C-style functions that usually accept (argc, argv) input as passed to main.

This function creates the necessary buffers lazily on first call.

Note
The returned pointer remains valid only as long as the actor_system_config object exists.

◆ helptext_printed()

bool caf::actor_system_config::helptext_printed ( ) const
noexcept

Returns whether the help text was printed.

If this function return true, the application should not use this config object to initialize an actor_system and instead return from main immediately.

◆ parse_config() [1/3]

expected< settings > caf::actor_system_config::parse_config ( std::istream & source)
static

Parses the content of source using CAF's config format.

Parameters
sourceCharacter sequence in CAF's config format.
Returns
A settings dictionary with the parsed content of source on success, an error otherwise.

◆ parse_config() [2/3]

expected< settings > caf::actor_system_config::parse_config ( std::istream & source,
const config_option_set & opts )
static

Parses the content of source using CAF's config format.

Also type-checks user-defined parameters in opts.

Parameters
sourceCharacter sequence in CAF's config format.
optsUser-defined config options for type checking.
Returns
A settings dictionary with the parsed content of source on success, an error otherwise.

◆ parse_config() [3/3]

error caf::actor_system_config::parse_config ( std::istream & source,
const config_option_set & opts,
settings & result )
static

Parses the content of source using CAF's config format and stores all entries in result (overrides conflicting entries).

Also type-checks user-defined parameters in opts.

Parameters
sourceCharacter sequence in CAF's config format.
optsUser-defined config options for type checking.
resultStorage for parsed entries. Note that result will contain partial results if this function returns an error.
Returns
A default-constructed error on success, the error code of the parser otherwise.

◆ parse_config_file() [1/3]

expected< settings > caf::actor_system_config::parse_config_file ( const char * filename)
static

Tries to open filename and parses its content as CAF config file.

Parameters
filenameRelative or absolute path to the config file.
Returns
A settings dictionary with the parsed content of filename on success, an error otherwise.

◆ parse_config_file() [2/3]

expected< settings > caf::actor_system_config::parse_config_file ( const char * filename,
const config_option_set & opts )
static

Tries to open filename and parses its content as CAF config file.

Also type-checks user-defined parameters in opts.

Parameters
filenameRelative or absolute path to the config file.
optsUser-defined config options for type checking.
Returns
A settings dictionary with the parsed content of filename on success, an error otherwise.

◆ parse_config_file() [3/3]

static error caf::actor_system_config::parse_config_file ( const char * filename,
const config_option_set & opts,
settings & result )
static

Tries to open filename, parses its content as CAF config file and stores all entries in result (overrides conflicting entries).

Also type-checks user-defined parameters in opts.

Parameters
filenameRelative or absolute path to the config file.
optsUser-defined config options for type checking.
resultStorage for parsed entries. Note that result will contain partial results if this function returns an error.
Returns
A default-constructed error on success, the error code of the parser otherwise.

The documentation for this class was generated from the following files: