Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
us::ServiceFactory Class Referenceabstract

#include <usServiceFactory.h>

Inheritance diagram for us::ServiceFactory:

Public Member Functions

virtual ~ServiceFactory ()
 
virtual InterfaceMap GetService (Module *module, const ServiceRegistrationBase &registration)=0
 
virtual void UngetService (Module *module, const ServiceRegistrationBase &registration, const InterfaceMap &service)=0
 

Detailed Description

A factory for module scope services. The factory can provide service objects unique to each module.

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.

See also
ModuleContext::GetService
PrototypeServiceFactory
Remarks
This class is thread safe.

Definition at line 64 of file usServiceFactory.h.

Constructor & Destructor Documentation

◆ ~ServiceFactory()

virtual us::ServiceFactory::~ServiceFactory ( )
inlinevirtual

Definition at line 69 of file usServiceFactory.h.

Member Function Documentation

◆ GetService()

virtual InterfaceMap us::ServiceFactory::GetService ( Module module,
const ServiceRegistrationBase registration 
)
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 ServiceReferenceBase&) method. The service factory can then return a specific service object for each module.

The framework caches the value returned (unless the InterfaceMap is empty), and will return the same service object on any future call to ModuleContext::GetService for the same modules. This means the framework does not allow this method to be concurrently called for the same module.

Parameters
moduleThe module using the service.
registrationThe ServiceRegistrationBase object for the service.
Returns
A service object that must contain entries for all the interfaces named when the service was registered.
See also
ModuleContext::GetService
InterfaceMap

Implemented in us::PrototypeServiceFactory.

◆ UngetService()

virtual void us::ServiceFactory::UngetService ( Module module,
const ServiceRegistrationBase registration,
const InterfaceMap 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.

Parameters
moduleThe Module releasing the service.
registrationThe ServiceRegistration object for the service.
serviceThe service object returned by a previous call to the ServiceFactory::GetService method.
See also
ModuleContext::UngetService
InterfaceMap

Implemented in us::PrototypeServiceFactory.


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