mobject::session::DefsManager Class Reference

Organize a collection of preconfigured default objects. More...

#include <defsmanager.hpp>

List of all members.

Public Member Functions

template<class TAR>
P< TAR > create (const lumiera::Query< TAR > &)
 retrieve an object fulfilling the query and register it as default.
template<class TAR>
bool define (const P< TAR > &, const lumiera::Query< TAR > &)
 register the given object as default, after ensuring it fulfills the query.
template<class TAR>
bool forget (const P< TAR > &)
 remove the defaults registration of the given object, if there was such
template<class TAR>
P< TAR > operator() (const lumiera::Query< TAR > &)
 common access point: retrieve the default object fulfilling some given conditions.
template<class TAR>
P< TAR > search (const lumiera::Query< TAR > &)
 search through the registered defaults, never create anything.

Protected Member Functions

 DefsManager () throw ()
 initialize the most basic internal defaults.

Private Attributes

scoped_ptr< DefsRegistrydefsRegistry

Friends

class SessManagerImpl


Detailed Description

For various kinds of objects we can tweek 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.

Definition at line 56 of file defsmanager.hpp.


Constructor & Destructor Documentation

mobject::session::DefsManager::DefsManager (  )  throw () [protected]

Definition at line 47 of file defsmanager.cpp.

00048       : defsRegistry(new DefsRegistry)
00049     {
00050       TODO ("setup basic defaults of the session");
00051     }


Member Function Documentation

template<class TAR>
P< TAR > mobject::session::DefsManager::create ( const lumiera::Query< TAR > &  capabilities  )  [inline]

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.

Definition at line 73 of file defsmanager.cpp.

References lumiera::query::QueryHandler< TY >::resolve().

Referenced by operator()().

00074     {
00075       P<TAR> res;
00076       QueryHandler<TAR>& typeHandler = ConfigRules::instance();  
00077       typeHandler.resolve (res, capabilities);
00078       if (res)
00079         defsRegistry->put (res, capabilities);
00080       return res;
00081     }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TAR>
bool mobject::session::DefsManager::define ( const P< TAR > &  defaultObj,
const lumiera::Query< TAR > &  capabilities 
) [inline]

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 successfull and object is registered as default
Note:
only a weak ref to the object is stored

Definition at line 86 of file defsmanager.cpp.

References lumiera::query::QueryHandler< TY >::resolve().

00087     {
00088       P<TAR> candidate (defaultObj);
00089       QueryHandler<TAR>& typeHandler = ConfigRules::instance();  
00090       typeHandler.resolve (candidate, capabilities);
00091       if (!candidate)
00092         return false;
00093       else
00094         return defsRegistry->put (candidate, capabilities);
00095     }

Here is the call graph for this function:

template<class TAR>
bool mobject::session::DefsManager::forget ( const P< TAR > &  defaultObj  )  [inline]

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

Definition at line 100 of file defsmanager.cpp.

00101     {
00102       return defsRegistry->forget (defaultObj);
00103     }

template<class TAR>
P< TAR > mobject::session::DefsManager::operator() ( const lumiera::Query< TAR > &  capabilities  )  [inline]

May silently trigger object creation.

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

Definition at line 108 of file defsmanager.cpp.

References lumiera::Query< OBJ >::asKey(), create(), and search().

00109     {
00110       P<TAR> res (search (capabilities));
00111       if (res) 
00112         return res;
00113       else
00114         res = create (capabilities); // not yet known as default, create new
00115       
00116       if (!res)
00117         throw lumiera::error::Config ( str(format("The following Query could not be resolved: %s.") 
00118                                                  % capabilities.asKey())
00119                                      , LUMIERA_ERROR_CAPABILITY_QUERY );
00120       else
00121         return res;
00122     }

Here is the call graph for this function:

template<class TAR>
P< TAR > mobject::session::DefsManager::search ( const lumiera::Query< TAR > &  capabilities  )  [inline]

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

Definition at line 56 of file defsmanager.cpp.

References lumiera::query::QueryHandler< TY >::resolve().

Referenced by operator()().

00057     {
00058       P<TAR> res;
00059       QueryHandler<TAR>& typeHandler = ConfigRules::instance();  
00060       for (DefsRegistry::Iter<TAR> i = defsRegistry->candidates(capabilities); 
00061            res = *i ; ++i )
00062         {
00063           typeHandler.resolve (res, capabilities);
00064           if (res)
00065             return res;
00066         }
00067       return res; // "no solution found"
00068     }

Here is the call graph for this function:

Here is the caller graph for this function:


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

Generated on Sat Aug 16 18:10:47 2008 for Lumiera by  doxygen 1.5.5