Apache Celix
latest
Apache Celix is a framework for C, C++14 and C++17 to develop dynamic modular software applications using component and in-process service-oriented programming.
|
#include <Component.h>
Public Member Functions | |
~Component () override | |
bool | isValid () const |
T & | getInstance () |
Component< T > & | setInstance (std::shared_ptr< T > inst) |
Component< T > & | setInstance (std::unique_ptr< T > &&inst) |
Component< T > & | setInstance (T &&inst) |
template<class I > | |
Component< T > & | addInterfaceWithName (const std::string &serviceName, const std::string &version=std::string{}, const Properties &properties=Properties{}) |
template<class I > | |
Component< T > & | addInterface (const std::string &version=std::string{}, const Properties &properties=Properties{}) |
template<class I > | |
Component< T > & | addCInterface (I *svc, const std::string &serviceName, const std::string &version=std::string{}, const Properties &properties=Properties{}) |
template<class I > | |
ProvidedService< T, I > & | createProvidedCService (I *svc, std::string serviceName) |
Creates a provided C services the component. More... | |
template<class I > | |
ProvidedService< T, I > & | createProvidedService (std::string serviceName={}) |
Creates a provided C++ services for the component. More... | |
template<class I > | |
ProvidedService< T, I > & | createUnassociatedProvidedService (std::shared_ptr< I > svc, std::string serviceName={}) |
Creates a unassociated provided services for the component. More... | |
template<class I > | |
Component< T > & | removeCInterface (const I *svc) |
template<class I > | |
ServiceDependency< T, I > & | createServiceDependency (const std::string &name=std::string{}) |
template<class I > | |
Component< T > & | remove (ServiceDependency< T, I > &dep) |
template<typename I > | |
CServiceDependency< T, I > & | createCServiceDependency (const std::string &name) |
template<typename I > | |
Component< T > & | remove (CServiceDependency< T, I > &dep) |
Component< T > & | setCallbacks (void(T::*init)(), void(T::*start)(), void(T::*stop)(), void(T::*deinit)()) |
Component< T > & | setCallbacks (int(T::*init)(), int(T::*start)(), int(T::*stop)(), int(T::*deinit)()) |
Component< T > & | removeCallbacks () |
Component< T > & | addContext (std::shared_ptr< void >) |
Add context to the component. This can be used to ensure a object lifespan at least matches that of the component. More... | |
Component< T > & | build () |
Component< T > & | buildAsync () |
Public Member Functions inherited from celix::dm::BaseComponent | |
BaseComponent (celix_bundle_context_t *con, celix_dependency_manager_t *cdm, std::string name, std::string uuid) | |
virtual | ~BaseComponent () noexcept |
BaseComponent (const BaseComponent &)=delete | |
BaseComponent & | operator= (const BaseComponent &)=delete |
celix_dm_component_t * | cComponent () const |
celix_bundle_context_t * | bundleContext () const |
const std::string & | getUUID () const |
const std::string & | getName () const |
ComponentState | getState () const |
void | wait () const |
void | runBuild () |
Static Public Member Functions | |
static std::shared_ptr< Component< T > > | create (celix_bundle_context_t *, celix_dependency_manager_t *cDepMan, std::string name, std::string uuid) |
Additional Inherited Members | |
Protected Attributes inherited from celix::dm::BaseComponent | |
celix_bundle_context_t * | context |
celix_dependency_manager_t * | cDepMan |
celix_dm_component_t * | cCmp |
std::string | cmpUUID {} |
std::string | cmpName {} |
std::atomic< bool > | cmpAddedToDepMan {false} |
std::mutex | mutex {} |
std::vector< std::shared_ptr< BaseServiceDependency > > | dependencies {} |
std::vector< std::shared_ptr< BaseProvidedService > > | providedServices {} |
std::vector< std::shared_ptr< void > > | componentContexts {} |
|
overridedefault |
Component< T > & Component::addCInterface | ( | I * | svc, |
const std::string & | serviceName, | ||
const std::string & | version = std::string{} , |
||
const Properties & | properties = Properties{} |
||
) |
Adds a C interface to provide as service to the Celix framework.
svc | The service struct |
serviceName | The service name to use |
version | The version of the interface (e.g. "1.0.0"), can be an empty string |
properties | To (meta) properties to provide with the service |
Component< T > & Component::addContext | ( | std::shared_ptr< void > | context | ) |
Add context to the component. This can be used to ensure a object lifespan at least matches that of the component.
Component< T > & Component::addInterface | ( | const std::string & | version = std::string{} , |
const Properties & | properties = Properties{} |
||
) |
Adds a C++ interface to provide as service to the Celix framework.
serviceName | The service name to use |
version | The version of the interface (e.g. "1.0.0"), can be an empty string |
properties | To (meta) properties to provide with the service |
Component< T > & Component::addInterfaceWithName | ( | const std::string & | serviceName, |
const std::string & | version = std::string{} , |
||
const Properties & | properties = Properties{} |
||
) |
Adds a C++ interface to provide as service to the Celix framework.
serviceName | The service name to use |
version | The version of the interface (e.g. "1.0.0"), can be an empty string |
properties | To (meta) properties to provide with the service |
Component< T > & Component::build |
Build the component.
When building the component all provided services and services dependencies are enabled. This is not done automatically so that user can first construct component with their provided service and service dependencies.
Note that the after this call the component will be created and if the component can be started, it will be started and the services will be registered.
Should not be called from the Celix event thread.
Component< T > & Component::buildAsync |
Same as build, but this call will not wait til all service registrations and tracker are registered/openend on the Celix event thread. Can be called on the Celix event thread.
|
static |
CServiceDependency< T, I > & Component::createCServiceDependency | ( | const std::string & | name | ) |
Adds a C service dependency to the component
ProvidedService< T, I > & Component::createProvidedCService | ( | I * | svc, |
std::string | serviceName | ||
) |
Creates a provided C services the component.
The provided service can be fine tuned and build using a fluent API
svc | The pointer to a C service (c struct) |
serviceName | The service name to use |
ProvidedService< T, I > & Component::createProvidedService | ( | std::string | serviceName = {} | ) |
Creates a provided C++ services for the component.
The provided service can be fine tuned and build using a fluent API
serviceName | The optional service name. If not provided the service name is inferred from I. |
ServiceDependency< T, I > & Component::createServiceDependency | ( | const std::string & | name = std::string{} | ) |
Creates and adds a C++ service dependency to the component
ProvidedService< T, I > & Component::createUnassociatedProvidedService | ( | std::shared_ptr< I > | svc, |
std::string | serviceName = {} |
||
) |
Creates a unassociated provided services for the component.
The provided service can be fine tuned and build using a fluent API
serviceName | The optional service name. If not provided the service name is inferred from I. |
T & Component::getInstance |
Get the component instance. If no instance is explicitly set with setInstance than a instance will be create using a default constructor.
bool Component::isValid |
Whether the component is valid. Invalid component can occurs when no new components can be created and exceptions are not allowed.
Component< T > & Component::remove | ( | CServiceDependency< T, I > & | dep | ) |
Removes a C service dependency to the component
Component< T > & Component::remove | ( | ServiceDependency< T, I > & | dep | ) |
Removes a C++ service dependency from the component
Component< T > & Component::removeCallbacks |
Remove the previously registered callbacks for the component life cycle control
Adds a C interface to provide as service to the Celix framework.
svc | The service struct |
serviceName | The service name to use |
version | The version of the interface (e.g. "1.0.0"), can be an empty string |
properties | To (meta) properties to provide with the service |
Component< T > & Component::setCallbacks | ( | int(T::*)() | init, |
int(T::*)() | start, | ||
int(T::*)() | stop, | ||
int(T::*)() | deinit | ||
) |
Set the callback for the component life cycle control with a int return to indicate an error.
init | The init callback. |
start | The start callback. |
stop | The stop callback. |
deinit | The deinit callback. |
Component< T > & Component::setCallbacks | ( | void(T::*)() | init, |
void(T::*)() | start, | ||
void(T::*)() | stop, | ||
void(T::*)() | deinit | ||
) |
Set the callback for the component life cycle control
init | The init callback. |
start | The start callback. |
stop | The stop callback. |
deinit | The deinit callback. |
Component< T > & Component::setInstance | ( | std::shared_ptr< T > | inst | ) |
Set the component instance using a shared pointer.
Component< T > & Component::setInstance | ( | std::unique_ptr< T > && | inst | ) |
Set the component instance using a unique pointer.
Component< T > & Component::setInstance | ( | T && | inst | ) |