The C++ Dependency Manager contains a static library which can be used to manage (dynamic) services on a higher abstraction level in a declarative style. The Apache Celix C++ Dependency Manager is inspired by the Apache Felix Dependency Manager.
The C++ Dependency Manager uses fluent interface to make specifying DM components and service dependencies very concise and relies on features introduced in C++11.
The C++ Dependency Manager is build on top of the C Dependency Manager. To get a good overview of the C++ Dependency Manager please read the Dependency Manager documentation
The C++ Dependency Manager consist out of four main parts:
DmActivator class should be inherited by a bundle specific Activator.
DmActivator::createmethod needs to be implemented and should return a bundle specific subclass instance of the DmActivator.
DmActivator::initmethod should be overridden and can be used to specify which components to use in the bundle.
DmActivator::deinitmethod can be overridden if some cleanup is needed when a bundle is stopped.
DependencyManager act as an entry point to create (DM) Components.
Component manages the life cycle of a component (of the template type T). For example, when all required service dependencies are available the
Component will call the
start specified callback function of the component.
Component::setInstancemethod can be used to set the component instance to used. If no instance is set the (DM)
Componentwill (lazy) create a component instance using the default constructor.
Component::addInterfacemethod can be used to specify one additional C++ service provided by the component.
Component::addCInterfacemethod can be used to specify one additional C service provided by the component.
Component::createServiceDependencymethod can be used to specify one additional typed C++ service dependency.
Component::createCServiceDependencymethod can be used to specify one additional typed C service dependency.
ServiceDependency can be used to specify C++ service dependencies for a component and the (DM)
CServiceDependency can be used to specify C service dependencies for a component.
When these dependencies are set to required the
Component will ensure that components will only be started when all required dependencies are available and stop the component if any of the required dependencies are removed.
This feature should prevent a lot of boiler plating code compared to using a service tracker or services references directly.
A service dependency update strategy can also be specified (suspend or locking. Default this strategy is set to
DependencyUpdateStrategy::suspend this strategy will stop and start (suspend) a component when any of the specified service dependencies changes (are removed, added or modified).
When correctly used this strategy removes the need for locking services during updates/invocation. See the dependency manager_cxx example for more details.
(C)ServiceDependency::setCallbacksmethods can be used to specify the function callback used when services are added, set, removed or modified.
(C)ServiceDependency::setRequiredmethods can be used to specify if a service dependency is required.
(C)ServiceDependency::setStrategymethods can be used to specify the service dependency update strategy (suspend or locking).
For more information examples please see