Flow 1.0.0
Flow project: Full implementation reference.
|
Class which facilitates managing access to a dynamic configuration. More...
#include <dynamic_cfg_context.hpp>
Public Types | |
using | Target_ptr_type = Target_ptr |
Type alias for Target_ptr . More... | |
using | Get_root_func = Function< typename Root::Const_ptr()> |
Type for a function object which returns a ref-counted pointer to an immutable root configuration object. More... | |
using | Root_to_target_func = Function< const Target &(const Root &)> |
Type for a function object which translates a Root object to a contained Target object. More... | |
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... | |
Private Attributes | |
const Get_root_func | m_get_root_func |
Called to obtain the root configuration. More... | |
const Root_to_target_func | m_root_to_target_func |
Translates a root configuration object to a contained target configuration object. 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. Definition at line 56 of file dynamic_cfg_context.hpp.
using flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::Get_root_func = Function<typename Root::Const_ptr ()> |
Type for a function object which returns a ref-counted pointer to an immutable root configuration object.
Definition at line 68 of file dynamic_cfg_context.hpp.
using flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::Root_to_target_func = Function<const Target& (const Root&)> |
Type for a function object which translates a Root
object to a contained Target
object.
Definition at line 71 of file dynamic_cfg_context.hpp.
using flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::Target_ptr_type = Target_ptr |
Type alias for Target_ptr
.
Definition at line 65 of file dynamic_cfg_context.hpp.
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. |
Definition at line 135 of file dynamic_cfg_context.hpp.
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
. Definition at line 144 of file dynamic_cfg_context.hpp.
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.
Definition at line 162 of file dynamic_cfg_context.hpp.
Root::Const_ptr flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::root_dynamic_cfg |
Obtain the root configuration.
Definition at line 156 of file dynamic_cfg_context.hpp.
|
private |
Called to obtain the root configuration.
Definition at line 126 of file dynamic_cfg_context.hpp.
|
private |
Translates a root configuration object to a contained target configuration object.
Definition at line 129 of file dynamic_cfg_context.hpp.