Lumiera  0.pre.03
»edit your freedom«
DefsManager Class Reference

#include "common/query/defs-manager.hpp"

Description

Organise a collection of preconfigured default objects.

For various kinds of objects we can tweak the default parametrisation as part of the general session configuration. A ref to an instance of this class is accessible through the current session and can be used to fill in parts of the configuration of new objects, if the user code didn't give more specific parameters. Necessary sub-objects will be created on demand, and any default configuration, once found, will be remembered and stored with the current session.

Note
while the logic of defaults handling can be considered roughly final, as of 12/09 most of the actual object handling is placeholder code.

Definition at line 129 of file defs-manager.hpp.

Public Member Functions

 DefsManager () noexcept
 initialise the most basic internal defaults. More...
 
 ~DefsManager ()
 
void clear ()
 
template<class TAR >
P< TAR > create (const Query< TAR > &capabilities)
 
template<class TAR >
lib::P< TAR > create (Query< TAR > const &)
 retrieve an object fulfilling the query and register it as default. More...
 
template<class TAR >
bool define (lib::P< TAR > const &, Query< TAR > const &=Query< TAR >())
 register the given object as default, after ensuring it fulfils the query. More...
 
template<class TAR >
bool forget (lib::P< TAR > const &)
 remove the defaults registration of the given object, if there was such More...
 
template<class TAR >
P< TAR > operator() (const Query< TAR > &capabilities)
 
template<class TAR >
lib::P< TAR > operator() (Query< TAR > const &)
 common access point: retrieve the default object fulfilling some given conditions. More...
 
template<class TAR >
P< TAR > search (const Query< TAR > &capabilities)
 
template<class TAR >
lib::P< TAR > search (Query< TAR > const &)
 search through the registered defaults, never create anything. More...
 

Private Attributes

unique_ptr< impl::DefsRegistrydefsRegistry_
 

Additional Inherited Members

- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Constructor & Destructor Documentation

◆ DefsManager()

DefsManager ( )
noexcept

initialise the most basic internal defaults.

Definition at line 56 of file defs-manager-impl.hpp.

◆ ~DefsManager()

causes std::default_delete from unique_ptr<DefsRegistry> to be emitted here, where the declaration of DefsRegistry is available.

Definition at line 67 of file defs-manager-impl.hpp.

Member Function Documentation

◆ operator()()

lib::P<TAR> operator() ( Query< TAR > const &  )

common access point: retrieve the default object fulfilling some given conditions.

May silently trigger object creation.

Exceptions
error::Configin case no solution is possible, which is considered misconfiguration.

Referenced by DefsManager::forget().

+ Here is the caller graph for this function:

◆ search()

lib::P<TAR> search ( Query< TAR > const &  )

search through the registered defaults, never create anything.

Returns
object fulfilling the query, empty ptr if not found.

Referenced by DefsManager::clear(), and DefsManager::forget().

+ Here is the caller graph for this function:

◆ create()

lib::P<TAR> create ( Query< TAR > const &  )

retrieve an object fulfilling the query and register it as default.

The resolution is delegated to the ConfigQuery system (which may cause creation of new object instances)

Returns
object fulfilling the query, empty ptr if no solution.

Referenced by DefsManager::forget().

+ Here is the caller graph for this function:

◆ define()

template bool define ( lib::P< TAR > const &  ,
Query< TAR > const &  = Query< TAR >() 
)

register the given object as default, after ensuring it fulfils the query.

The latter may cause some properties of the object to be set, trigger creation of additional objects, and may fail altogether.

Returns
true if query was successful and object is registered as default
Note
only a weak ref to the object is stored

Definition at line 111 of file defs-manager-impl.hpp.

◆ forget()

template bool forget ( lib::P< TAR > const &  )

remove the defaults registration of the given object, if there was such

Returns
false if nothing has been changed because the object wasn't registered

Definition at line 125 of file defs-manager-impl.hpp.

References DefsManager::create(), DefsManager::operator()(), and DefsManager::search().

+ Here is the call graph for this function:

◆ clear()

void clear ( )

for session lifecycle

Definition at line 71 of file defs-manager-impl.hpp.

References DefsManager::search().

+ Here is the call graph for this function:
+ Inheritance diagram for DefsManager:
+ Collaboration diagram for DefsManager:

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