Flow 1.0.0
Flow project: Public API.
Public Types | Public Member Functions | List of all members
flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr > Class Template 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.
 
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.
 
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.
 

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

Detailed Description

template<typename Root, typename Target, typename Target_ptr>
class flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >

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.

Template Parameters
RootType 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.
TargetType for the target configuration.
Target_ptrPlease 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).
Todo:
flow::cfg::Dynamic_cfg_context 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.

Constructor & Destructor Documentation

◆ Dynamic_cfg_context() [1/2]

template<typename Root , typename Target , typename Target_ptr >
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.

Parameters
get_root_func_movedReturns a ref-counted pointer to the (immutable) root configuration object.
root_to_target_func_movedTranslates a root configuration object to a contained target configuration object.

◆ Dynamic_cfg_context() [2/2]

template<typename Root , typename Target , typename Target_ptr >
template<typename... S_d_value_set>
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.

Parameters
config_managerA Config_manager which is currently managing the desired dynamic configuration.
root_to_target_func_movedTranslates a root configuration object to a contained target configuration object.
d_value_set_idxThe dynamic config slot index of config_manager which corresponds to the desired dynamic configuration.
See also
Config_manager.

Member Function Documentation

◆ dynamic_cfg()

template<typename Root , typename Target , typename Target_ptr >
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.

Returns
a ref-counted pointer to the (immutable) target configuration object, but which shares ownership of the containing root configuration object.

◆ root_dynamic_cfg()

template<typename Root , typename Target , typename Target_ptr >
Root::Const_ptr flow::cfg::Dynamic_cfg_context< Root, Target, Target_ptr >::root_dynamic_cfg

Obtain the root configuration.

Returns
a ref-counted pointer to the (immutable) root configuration object.

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