#include <defsmanager.hpp>
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< DefsRegistry > | defsRegistry |
Friends | |
| class | SessManagerImpl |
Definition at line 56 of file defsmanager.hpp.
| 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 }
| 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)
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 }


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

| bool mobject::session::DefsManager::forget | ( | const P< TAR > & | defaultObj | ) | [inline] |
Definition at line 100 of file defsmanager.cpp.
| P< TAR > mobject::session::DefsManager::operator() | ( | const lumiera::Query< TAR > & | capabilities | ) | [inline] |
May silently trigger object creation.
| 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 }

| P< TAR > mobject::session::DefsManager::search | ( | const lumiera::Query< TAR > & | capabilities | ) | [inline] |
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 }


1.5.5