Flow 1.0.0
Flow project: Public API.
|
Class which facilitates managing access to a dynamic configuration. More...
#include <dynamic_cfg_context.hpp>
Public Member Functions | |
Dynamic_cfg_context (Get_root_func &&get_root_func_moved, Root_to_target_func &&root_to_target_func_moved) | |
Constructor. More... | |
template<typename... S_d_value_set> | |
Dynamic_cfg_context (const Config_manager< S_d_value_set... > &config_manager, Root_to_target_func &&root_to_target_func_moved, size_t d_value_set_idx=0) | |
Constructor. More... | |
Root::Const_ptr | root_dynamic_cfg () const |
Obtain the root configuration. More... | |
Target_ptr | dynamic_cfg () const |
Obtain the target configuration. More... | |
Class which facilitates managing access to a dynamic configuration.
Another class can make use of this one by means of a composition relationship, either through inheritance (probably private
or protected
) or by containing one or more Dynamic_cfg_context
members. If using inheritance, the class will gain methods which can be used to access the dynamic configuration. If using composition by members, more than one dynamic configuration can be used, each of which can be accessed separately by calling the access methods of the associated member.
A "configuration," here, is a data object (probably a struct
), which is referred to as the "root", containing an internal data object, which is referred to as the "target". The target is the configuration object which is expected to be normally accessed. The root and the target can be the same.
Root | Type for the root configuration. This should meet the requirements of the template argument for Option_set . A Root::Const_ptr type for a ref-counted pointer to an immutable Root must at least be defined (which can be provided by deriving from util::Shared_ptr_alias_holder ). See Option_set. |
Target | Type for the target configuration. |
Target_ptr | Please leave this at its default. Background: This would not have been a template parameter in the first place, had the authors known of pointer_traits::rebind at that the time. To preserve backwards compatibility this parameter remains for now (albeit deprecated). |
Target_ptr
is deprecated and shall be always left at its default value in future code; eventually remove it entirely and hard-code the default value internally. flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::Dynamic_cfg_context | ( | Get_root_func && | get_root_func_moved, |
Root_to_target_func && | root_to_target_func_moved | ||
) |
Constructor.
get_root_func_moved | Returns a ref-counted pointer to the (immutable) root configuration object. |
root_to_target_func_moved | Translates a root configuration object to a contained target configuration object. |
flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::Dynamic_cfg_context | ( | const Config_manager< S_d_value_set... > & | config_manager, |
Root_to_target_func && | root_to_target_func_moved, | ||
size_t | d_value_set_idx = 0 |
||
) |
Constructor.
This produces a Dynamic_cfg_context
which will obtain its configuration from a Config_manager
.
config_manager | A Config_manager which is currently managing the desired dynamic configuration. |
root_to_target_func_moved | Translates a root configuration object to a contained target configuration object. |
d_value_set_idx | The dynamic config slot index of config_manager which corresponds to the desired dynamic configuration. |
Config_manager
. Target_ptr flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::dynamic_cfg |
Obtain the target configuration.
This method provides the key mechanism of the class. The returned pointer object can be used to easily access the target object, but will additionally cause the containing root object to be held valid in memory.
Root::Const_ptr flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::root_dynamic_cfg |
Obtain the root configuration.