Allows services to provide customized service objects in the module environment. More...
Public Member Functions | |
| virtual | ~ServiceFactory () |
| virtual us::Base * | GetService (Module *module, const ServiceRegistration ®istration)=0 |
| Creates a new service object. More... | |
| virtual void | UngetService (Module *module, const ServiceRegistration ®istration, us::Base *service)=0 |
| Releases a service object. More... | |
Allows services to provide customized service objects in the module environment.
When registering a service, a ServiceFactory object can be used instead of a service object, so that the module developer can gain control of the specific service object granted to a module that is using the service.
When this happens, the ModuleContext::GetService(const ServiceReference&) method calls the ServiceFactory::GetService method to create a service object specifically for the requesting module. The service object returned by the ServiceFactory is cached by the framework until the module releases its use of the service.
When the module's use count for the service equals zero (including the module unloading or the service being unregistered), the ServiceFactory::UngetService method is called.
ServiceFactory objects are only used by the framework and are not made available to other modules in the module environment. The framework may concurrently call a ServiceFactory.
|
inlinevirtual |
|
pure virtual |
Creates a new service object.
The Framework invokes this method the first time the specified module requests a service object using the ModuleContext::GetService(const ServiceReference&) method. The service factory can then return a specific service object for each module.
The framework caches the value returned (unless it is 0), and will return the same service object on any future call to ModuleContext::GetService for the same modules. This means the framework must not allow this method to be concurrently called for the same module.
| module | The module using the service. |
| registration | The ServiceRegistration object for the service. |
|
pure virtual |
Releases a service object.
The framework invokes this method when a service has been released by a module. The service object may then be destroyed.
| module | The Module releasing the service. |
| registration | The ServiceRegistration object for the service. |
| service | The service object returned by a previous call to the ServiceFactory::GetService method. |