Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
us::ModuleActivator Struct Referenceabstract

#include <usModuleActivator.h>

Inheritance diagram for us::ModuleActivator:

Public Member Functions

virtual ~ModuleActivator ()
 
virtual void Load (ModuleContext *context)=0
 
virtual void Unload (ModuleContext *context)=0
 

Detailed Description

Customizes the starting and stopping of a CppMicroServices module.

ModuleActivator is an interface that can be implemented by CppMicroServices modules. The CppMicroServices library can create instances of a module's ModuleActivator as required. If an instance's ModuleActivator::Load method executes successfully, it is guaranteed that the same instance's ModuleActivator::Unload method will be called when the module is to be unloaded. The CppMicroServices library does not concurrently call a ModuleActivator object.

ModuleActivator is an abstract class interface whose implementations must be exported via a special macro. Implementations are usually declared and defined directly in .cpp files.

class MyActivator : public ModuleActivator
{
public:
void Load(ModuleContext* /*context*/) override
{ /* register stuff */ }
void Unload(ModuleContext* /*context*/) override
{ /* cleanup */ }
};

The class implementing the ModuleActivator interface must have a public default constructor so that a ModuleActivator object can be created by the CppMicroServices library.

Definition at line 63 of file usModuleActivator.h.

Constructor & Destructor Documentation

virtual us::ModuleActivator::~ModuleActivator ( )
inlinevirtual

Definition at line 66 of file usModuleActivator.h.

Member Function Documentation

virtual void us::ModuleActivator::Load ( ModuleContext context)
pure virtual

Called when this module is loaded. This method can be used to register services or to allocate any resources that this module may need globally (during the whole module lifetime).

This method must complete and return to its caller in a timely manner.

Parameters
contextThe execution context of the module being loaded.
Exceptions
std::exceptionIf this method throws an exception, this module is marked as stopped and the framework will remove this module's listeners, unregister all services registered by this module, and release all services used by this module.
virtual void us::ModuleActivator::Unload ( ModuleContext context)
pure virtual

Called when this module is unloaded. In general, this method should undo the work that the ModuleActivator::Load method started. There should be no active threads that were started by this module when this method returns.

This method must complete and return to its caller in a timely manner.

Parameters
contextThe execution context of the module being unloaded.
Exceptions
std::exceptionIf this method throws an exception, the module is still marked as unloaded, and the framework will remove the module's listeners, unregister all services registered by the module, and release all services used by the module.

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