Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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.
 
 ~DefsManager ()
 
template<class TAR >
lib::P< TAR > operator() (Query< TAR > const &)
 common access point: retrieve the default object fulfilling some given conditions.
 
template<class TAR >
lib::P< TAR > search (Query< TAR > const &)
 search through the registered defaults, never create anything.
 
template<class TAR >
lib::P< TAR > create (Query< TAR > const &)
 retrieve an object fulfilling the query and register it as default.
 
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.
 
template<class TAR >
bool forget (lib::P< TAR > const &)
 remove the defaults registration of the given object, if there was such
 
void clear ()
 
template<class TAR >
P< TAR > search (const Query< TAR > &capabilities)
 
template<class TAR >
P< TAR > create (const Query< TAR > &capabilities)
 
template<class TAR >
P< TAR > operator() (const Query< TAR > &capabilities)
 

Private Attributes

unique_ptr< impl::DefsRegistrydefsRegistry_
 

Additional Inherited Members

- Private Member Functions inherited from NonCopyable
 ~NonCopyable ()=default
 
 NonCopyable ()=default
 
 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()() [1/2]

template<class TAR >
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.

◆ search() [1/2]

template<class TAR >
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::operator()().

+ Here is the caller graph for this function:

◆ create() [1/2]

template<class TAR >
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 DefsManagerImpl_test::create(), and DefsManager::operator()().

+ Here is the caller graph for this function:

◆ define()

template<class TAR >
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.

References DefsManager::defsRegistry_, and QueryHandler< TY >::resolve().

Referenced by DefsManager_test::verifyRemoval().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ forget()

template<class TAR >
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::defsRegistry_.

◆ clear()

void clear ( )

for session lifecycle

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

References DefsManager::defsRegistry_.

◆ search() [2/2]

template<class TAR >
P< TAR > search ( const Query< TAR > &  capabilities)

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

References DefsManager::defsRegistry_, and QueryHandler< TY >::resolve().

+ Here is the call graph for this function:

◆ create() [2/2]

template<class TAR >
P< TAR > create ( const Query< TAR > &  capabilities)

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

References DefsManager::defsRegistry_, and QueryHandler< TY >::resolve().

+ Here is the call graph for this function:

◆ operator()() [2/2]

template<class TAR >
P< TAR > operator() ( const Query< TAR > &  capabilities)

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

References Query< RES >::Builder::asKey(), DefsManager::create(), LERR_, Query< RES >::rebuild(), and DefsManager::search().

+ Here is the call graph for this function:

Member Data Documentation

◆ defsRegistry_

unique_ptr<impl::DefsRegistry> defsRegistry_
private
+ Inheritance diagram for DefsManager:
+ Collaboration diagram for DefsManager:

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