Apache Celix
2.3.0
An implementation of the OSGi specification adapted to C and C++
|
Go to the documentation of this file.
29 #include <type_traits>
33 #include "dm_component.h"
37 #include "celix_dependency_manager.h"
41 namespace celix {
namespace dm {
166 std::mutex instanceMutex{};
167 std::unique_ptr<T> instance {
nullptr};
168 std::shared_ptr<T> sharedInstance {
nullptr};
169 std::vector<T> valInstance {};
171 void (T::*initFp)() = {};
172 void (T::*startFp)() = {};
173 void (T::*stopFp)() = {};
174 void (T::*deinitFp)() = {};
176 int (T::*initFpNoExc)() = {};
177 int (T::*startFpNoExc)() = {};
178 int (T::*stopFpNoExc)() = {};
179 int (T::*deinitFpNoExc)() = {};
187 Component(celix_bundle_context_t *
context, celix_dependency_manager_t*
cDepMan, std::string name, std::string uuid);
196 static std::shared_ptr<Component<T>>
create(celix_bundle_context_t*, celix_dependency_manager_t*
cDepMan, std::string name, std::string uuid);
417 int invokeLifecycleMethod(
const std::string& methodName,
void (T::*lifecycleMethod)());
@ CELIX_DM_CMP_STATE_INITIALIZED_AND_WAITING_FOR_REQUIRED
Definition: celix_dm_component.h:42
Definition: ProvidedService.h:57
A service dependency for a component.
Definition: ServiceDependency.h:134
const std::string & getName() const
Definition: Component.h:90
virtual ~BaseComponent() noexcept
Component< T > & build()
Definition: Component_Impl.h:393
celix_bundle_context_t * bundleContext() const
Definition: Component.h:78
ProvidedService< T, I > & createProvidedService(std::string serviceName={})
Creates a provided C++ services for the component.
Definition: Component_Impl.h:417
Component< T > & addCInterface(I *svc, const std::string &serviceName, const std::string &version=std::string{}, const Properties &properties=Properties{})
Definition: Component_Impl.h:120
@ CELIX_DM_CMP_STATE_WAITING_FOR_REQUIRED
Definition: celix_dm_component.h:39
@ CELIX_DM_CMP_STATE_SUSPENDING
Definition: celix_dm_component.h:46
@ CELIX_DM_CMP_STATE_TRACKING_OPTIONAL
Definition: celix_dm_component.h:45
std::ostream & operator<<(std::ostream &out, const BaseComponent &cmp)
Definition: Component_Impl.h:54
celix_dm_component_t * celix_dmComponent_createWithUUID(celix_bundle_context_t *context, const char *name, const char *UUID)
celix_bundle_context_t * context
Definition: Component.h:143
@ CELIX_DM_CMP_STATE_SUSPENDED
Definition: celix_dm_component.h:47
std::atomic< bool > cmpAddedToDepMan
Definition: Component.h:149
Component< T > & addInterface(const std::string &version=std::string{}, const Properties &properties=Properties{})
Definition: Component_Impl.h:104
celix_dm_component_state_t celix_dmComponent_currentState(celix_dm_component_t *cmp)
ServiceDependency< T, I > & createServiceDependency(const std::string &name=std::string{})
Definition: Component_Impl.h:147
celix_status_t celix_dmComponent_setImplementation(celix_dm_component_t *component, void *implementation)
std::vector< std::shared_ptr< BaseServiceDependency > > dependencies
Definition: Component.h:152
@ CELIX_DM_CMP_STATE_RESUMING
Definition: celix_dm_component.h:48
Component< T > & removeCInterface(const I *svc)
Definition: Component_Impl.h:132
Component< T > & buildAsync()
Definition: Component_Impl.h:400
ComponentState
Definition: Component.h:43
void runBuild()
Definition: Component_Impl.h:22
@ CELIX_DM_CMP_STATE_STARTING
Definition: celix_dm_component.h:43
ComponentState getState() const
Definition: Component.h:97
std::string cmpName
Definition: Component.h:147
std::string cmpUUID
Definition: Component.h:146
Definition: Component.h:163
static std::shared_ptr< Component< T > > create(celix_bundle_context_t *, celix_dependency_manager_t *cDepMan, std::string name, std::string uuid)
Definition: Component_Impl.h:184
@ INSTANTIATED_AND_WAITING_FOR_REQUIRED
celix_dm_component_t * cComponent() const
Definition: Component.h:73
CServiceDependency< T, I > & createCServiceDependency(const std::string &name)
Definition: Component_Impl.h:166
std::vector< std::shared_ptr< void > > componentContexts
Definition: Component.h:154
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 t...
Definition: Component_Impl.h:386
ProvidedService< T, I > & createUnassociatedProvidedService(std::shared_ptr< I > svc, std::string serviceName={})
Creates a unassociated provided services for the component.
Definition: Component_Impl.h:440
const char * celix_dmComponent_getUUID(celix_dm_component_t *cmp)
const std::string & getUUID() const
Definition: Component.h:83
@ CELIX_DM_CMP_STATE_STOPPING
Definition: celix_dm_component.h:44
friend std::ostream & operator<<(std::ostream &out, const BaseComponent &cmp)
celix_dm_component_t * cCmp
Definition: Component.h:145
std::vector< std::shared_ptr< BaseProvidedService > > providedServices
Definition: Component.h:153
void wait() const
Definition: Component_Impl.h:50
const char * celix_dmComponent_getName(celix_dm_component_t *cmp)
Component< T > & remove(ServiceDependency< T, I > &dep)
Definition: Component_Impl.h:157
Component< T > & setCallbacks(void(T::*init)(), void(T::*start)(), void(T::*stop)(), void(T::*deinit)())
Definition: Component_Impl.h:291
ProvidedService< T, I > & createProvidedCService(I *svc, std::string serviceName)
Creates a provided C services the component.
Definition: Component_Impl.h:407
celix_dependency_manager_t * cDepMan
Definition: Component.h:144
Component< T > & removeCallbacks()
Definition: Component_Impl.h:380
@ CELIX_DM_CMP_STATE_INITIALIZING
Definition: celix_dm_component.h:40
@ CELIX_DM_CMP_STATE_DEINITIALIZING
Definition: celix_dm_component.h:41
celix::Properties Properties
Definition: Properties.h:25
BaseComponent(celix_bundle_context_t *con, celix_dependency_manager_t *cdm, std::string name, std::string uuid)
Definition: Component.h:59
Definition: Component.h:57
A service dependency for a component.
Definition: ServiceDependency.h:266
std::mutex mutex
Definition: Component.h:151
T & getInstance()
Definition: Component_Impl.h:223
Component< T > & addInterfaceWithName(const std::string &serviceName, const std::string &version=std::string{}, const Properties &properties=Properties{})
Definition: Component_Impl.h:84
Component< T > & setInstance(std::shared_ptr< T > inst)
Definition: Component_Impl.h:239
bool isValid() const
Definition: Component_Impl.h:203