(API): unify initialization of libraries
Description
Many libraries need to execute some code at start to initialize their internal state. And symmetrically before exit. Most often this code is executed in the Plugin.cpp
of a module.
However, this code is often obscure and not documented. Someone not knowing the library could not easily identify which functions to execute, and in which order if he wants to used it in a standalone application.
Proposal
Expose a single method init()
or start
at the root of the namespace of each library which needs initialization. And of course, we need a method for the exit. We may need to pass some parameters to the function, but I don't think that hurts.
After this, we should remove the functions previously called outside from the public API.
Links / references
Some examples
fwRenderVTK
m_factory = ::fwRenderVTK::vtk::Instantiator::New();
m_factory->getClassOverrides();
vtkObjectFactory::RegisterFactory(m_factory);
...
vtkObjectFactory::UnRegisterFactory(m_factory);
m_factory->Delete();
fwServices
::fwServices::registry::ServiceFactory::getDefault()->parseBundleInformation();
::fwServices::registry::ServiceConfig::getDefault()->parseBundleInformation();
::fwServices::registry::AppConfig::getDefault()->parseBundleInformation();
::fwServices::registry::AppConfigParameters::getDefault()->parseBundleInformation();
...
::fwServices::registry::ServiceConfig::getDefault()->clearRegistry();
::fwServices::registry::AppConfig::getDefault()->clearRegistry();
::fwServices::registry::AppConfigParameters::getDefault()->clearRegistry();
::fwServices::registry::ServiceFactory::getDefault()->clearFactory();
::fwServices::registry::ActiveWorkers::getDefault()->clearRegistry();