CAF  0.17.3
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Related Functions | List of all members
caf::actor_system_config Class Reference

Configures an actor_system on startup. More...

#include <actor_system_config.hpp>

Public Types

using hook_factory = std::function< io::hook *(actor_system &)>
 
using hook_factory_vector = std::vector< hook_factory >
 
using thread_hooks = std::vector< std::unique_ptr< thread_hook > >
 
template<class K , class V >
using hash_map = std::unordered_map< K, V >
 
using module_factory = std::function< actor_system::module *(actor_system &)>
 
using module_factory_vector = std::vector< module_factory >
 
using value_factory = std::function< type_erased_value_ptr()>
 
using value_factory_string_map = hash_map< std::string, value_factory >
 
using value_factory_rtti_map = hash_map< std::type_index, value_factory >
 
using actor_factory_map = hash_map< std::string, actor_factory >
 
using portable_name_map = hash_map< std::type_index, std::string >
 
using error_renderer = std::function< std::string(uint8_t, const message &)>
 
using error_renderer_map = hash_map< uint8_t, error_renderer >
 
using group_module_factory = std::function< group_module *()>
 
using group_module_factory_vector = std::vector< group_module_factory >
 
using config_map = dictionary< config_value::dictionary >
 
using string_list = std::vector< std::string >
 
using named_actor_config_map = hash_map< std::string, named_actor_config >
 
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 (string_view name, T &&value)
 Sets a config by using its INI name config_name to config_value.
 
error parse (string_list args, std::istream &ini)
 Parses args as tuple of strings containing CLI options and ini_stream as INI formatted input stream.
 
error parse (string_list args, const char *ini_file_cstr=nullptr)
 Parses args as tuple of strings containing CLI options and tries to open ini_file_cstr as INI formatted config file. More...
 
error parse (int argc, char **argv, std::istream &ini)
 Parses the CLI options {argc, argv} and ini_stream as INI formatted input stream.
 
error parse (int argc, char **argv, const char *ini_file_cstr=nullptr)
 Parses the CLI options {argc, argv} and tries to open ini_file_cstr as INI formatted config file. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class T >
actor_system_configadd_message_type (std::string name)
 Adds message type T with runtime type info name.
 
actor_system_configadd_error_category (uint8_t category, error_renderer f)
 Enables the actor system to convert errors of this error category to human-readable strings via renderer.
 
template<class T >
actor_system_configadd_error_category (uint8_t category, string_view category_name)
 Enables the actor system to convert errors of this error category to human-readable strings via to_string(T).
 
template<class T , class... Ts>
actor_system_configload ()
 Loads module T with optional template parameters Ts....
 
template<class Factory >
actor_system_configadd_hook_factory (Factory f)
 Adds a factory for a new hook type to the middleman (if loaded).
 
template<class Hook >
actor_system_configadd_hook_type ()
 Adds a hook type to the middleman (if loaded).
 
template<class Hook , class... Ts>
actor_system_configadd_thread_hook (Ts &&... ts)
 Adds a hook type to the scheduler.
 

Static Public Member Functions

static std::string render (const error &err)
 
static std::string render_sec (uint8_t, const message &)
 
static std::string render_exit_reason (uint8_t, const message &)
 
static std::string render_pec (uint8_t, const message &)
 
static expected< settingsparse_config_file (const char *filename)
 Tries to open filename and parses its content as CAF config file. More...
 
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. More...
 
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). More...
 
static expected< settingsparse_config (std::istream &source)
 Parses the content of source using CAF's config format. More...
 
static expected< settingsparse_config (std::istream &source, const config_option_set &opts)
 Parses the content of source using CAF's config format. More...
 
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). More...
 

Public Attributes

bool cli_helptext_printed
 Stores whether the help text was printed. More...
 
string_list remainder
 Stores CLI arguments that were not consumed by CAF.
 
bool slave_mode
 Stores whether this node was started in slave mode.
 
std::string slave_name
 Name of this node when started in slave mode.
 
std::string bootstrap_node
 Credentials for connecting to the bootstrap node.
 
std::string openssl_certificate
 
std::string openssl_key
 
std::string openssl_passphrase
 
std::string openssl_capath
 
std::string openssl_cafile
 
value_factory_string_map value_factories_by_name
 
value_factory_rtti_map value_factories_by_rtti
 
actor_factory_map actor_factories
 
module_factory_vector module_factories
 
hook_factory_vector hook_factories
 
group_module_factory_vector group_module_factories
 
thread_hooks thread_hooks_
 
actor_profilerprofiler = nullptr
 Provides system-wide callbacks for several actor operations. More...
 
tracing_data_factorytracing_context = nullptr
 Enables CAF to deserialize application-specific tracing information. More...
 
portable_name_map type_names_by_rtti
 
error_renderer_map error_renderers
 
std::string config_file_path
 Configures the file path for the INI file, caf-application.ini per default.
 
named_actor_config_map named_actor_configs
 
int(* slave_mode_fun )(actor_system &, const actor_system_config &)
 

Protected Attributes

config_option_set custom_options_
 

Related Functions

(Note that these are not member functions.)

template<class T >
auto get_if (const actor_system_config *cfg, string_view name)
 Tries to retrieve the value associated to name from cfg.
 
template<class T >
get (const actor_system_config &cfg, string_view name)
 Retrieves the value associated to name from cfg.
 
template<class T , class = typename std::enable_if< !std::is_pointer<T>::value && !std::is_convertible<T, string_view>::value>::type>
get_or (const actor_system_config &cfg, string_view name, T default_value)
 Retrieves the value associated to name from cfg or returns default_value.
 
std::string get_or (const actor_system_config &cfg, string_view name, string_view default_value)
 Retrieves the value associated to name from cfg or returns default_value.
 
template<class T >
bool holds_alternative (const actor_system_config &cfg, string_view name)
 Returns whether xs associates a value of type T to name.
 
const CAF_CORE_EXPORT settingscontent (const actor_system_config &)
 

Detailed Description

Configures an actor_system on startup.

Examples
dining_philosophers.cpp.

Member Function Documentation

◆ add_actor_factory()

actor_system_config& caf::actor_system_config::add_actor_factory ( std::string  name,
actor_factory  fun 
)

Allows other nodes to spawn actors created by fun dynamically by using name as identifier.

Attention
This feature is experimental.

◆ add_actor_type() [1/2]

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

Allows other nodes to spawn actors of type T dynamically by using name as identifier.

Attention
This feature is experimental.

◆ add_actor_type() [2/2]

template<class F >
actor_system_config& caf::actor_system_config::add_actor_type ( std::string  name,
f 
)

Allows other nodes to spawn actors implemented by function f dynamically by using name as identifier.

Attention
This feature is experimental.

◆ parse() [1/2]

error caf::actor_system_config::parse ( int  argc,
char **  argv,
const char *  ini_file_cstr = nullptr 
)

Parses the CLI options {argc, argv} and tries to open ini_file_cstr as INI formatted config file.

The parsers tries to open caf-application.ini if ini_file_cstr is nullptr.

◆ parse() [2/2]

error caf::actor_system_config::parse ( string_list  args,
const char *  ini_file_cstr = nullptr 
)

Parses args as tuple of strings containing CLI options and tries to open ini_file_cstr as INI formatted config file.

The parsers tries to open caf-application.ini if ini_file_cstr is nullptr.

◆ parse_config() [1/3]

static 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]

static 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]

static 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]

static 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]

static 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.

Member Data Documentation

◆ cli_helptext_printed

bool caf::actor_system_config::cli_helptext_printed

Stores whether the help text was printed.

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

◆ profiler

actor_profiler* caf::actor_system_config::profiler = nullptr

Provides system-wide callbacks for several actor operations.

Attention
This feature is experimental.
Note
Has no effect unless building CAF with CAF_ENABLE_ACTOR_PROFILER.

◆ tracing_context

tracing_data_factory* caf::actor_system_config::tracing_context = nullptr

Enables CAF to deserialize application-specific tracing information.

Attention
This feature is experimental.
Note
Has no effect unless building CAF with CAF_ENABLE_ACTOR_PROFILER.

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