Apache Celix
2.4.0
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.
|
Go to the documentation of this file.
29 #include <type_traits>
37 #include "celix_dependency_manager.h"
41 namespace celix {
namespace dm {
168 std::mutex instanceMutex{};
169 std::unique_ptr<T> instance {
nullptr};
170 std::shared_ptr<T> sharedInstance {
nullptr};
171 std::vector<T> valInstance {};
173 void (T::*initFp)() = {};
174 void (T::*startFp)() = {};
175 void (T::*stopFp)() = {};
176 void (T::*deinitFp)() = {};
178 int (T::*initFpNoExc)() = {};
179 int (T::*startFpNoExc)() = {};
180 int (T::*stopFpNoExc)() = {};
181 int (T::*deinitFpNoExc)() = {};
189 Component(celix_bundle_context_t *
context, celix_dependency_manager_t*
cDepMan, std::string name, std::string uuid);
198 static std::shared_ptr<Component<T>>
create(celix_bundle_context_t*, celix_dependency_manager_t*
cDepMan, std::string name, std::string uuid);
419 int invokeLifecycleMethod(
const std::string& methodName,
void (T::*lifecycleMethod)());
@ CELIX_DM_CMP_STATE_INITIALIZED_AND_WAITING_FOR_REQUIRED
Definition: celix_dm_component.h:43
Definition: ProvidedService.h:57
A service dependency for a component.
Definition: ServiceDependency.h:134
const std::string & getName() const
Definition: Component.h:90
CELIX_FRAMEWORK_EXPORT celix_status_t celix_dmComponent_setImplementation(celix_dm_component_t *component, void *implementation)
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:40
@ CELIX_DM_CMP_STATE_SUSPENDING
Definition: celix_dm_component.h:47
@ CELIX_DM_CMP_STATE_TRACKING_OPTIONAL
Definition: celix_dm_component.h:46
std::ostream & operator<<(std::ostream &out, const BaseComponent &cmp)
Definition: Component_Impl.h:54
celix_bundle_context_t * context
Definition: Component.h:145
@ CELIX_DM_CMP_STATE_SUSPENDED
Definition: celix_dm_component.h:48
std::atomic< bool > cmpAddedToDepMan
Definition: Component.h:151
Component< T > & addInterface(const std::string &version=std::string{}, const Properties &properties=Properties{})
Definition: Component_Impl.h:104
ServiceDependency< T, I > & createServiceDependency(const std::string &name=std::string{})
Definition: Component_Impl.h:147
std::vector< std::shared_ptr< BaseServiceDependency > > dependencies
Definition: Component.h:154
@ CELIX_DM_CMP_STATE_RESUMING
Definition: celix_dm_component.h:49
const CELIX_FRAMEWORK_EXPORT char * celix_dmComponent_getUUID(celix_dm_component_t *cmp)
Component< T > & removeCInterface(const I *svc)
Definition: Component_Impl.h:132
Component< T > & buildAsync()
Definition: Component_Impl.h:400
void runBuild()
Definition: Component_Impl.h:22
@ CELIX_DM_CMP_STATE_STARTING
Definition: celix_dm_component.h:44
ComponentState getState() const
Definition: Component.h:97
std::string cmpName
Definition: Component.h:149
std::string cmpUUID
Definition: Component.h:148
Definition: Component.h:165
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
celix_dm_component_t * cComponent() const
Definition: Component.h:73
CServiceDependency< T, I > & createCServiceDependency(const std::string &name)
Definition: Component_Impl.h:166
CELIX_FRAMEWORK_EXPORT celix_dm_component_state_t celix_dmComponent_currentState(celix_dm_component_t *cmp)
std::vector< std::shared_ptr< void > > componentContexts
Definition: Component.h:156
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 std::string & getUUID() const
Definition: Component.h:83
@ CELIX_DM_CMP_STATE_STOPPING
Definition: celix_dm_component.h:45
friend std::ostream & operator<<(std::ostream &out, const BaseComponent &cmp)
celix_dm_component_t * cCmp
Definition: Component.h:147
std::vector< std::shared_ptr< BaseProvidedService > > providedServices
Definition: Component.h:155
const CELIX_FRAMEWORK_EXPORT char * celix_dmComponent_getName(celix_dm_component_t *cmp)
@ INSTANTIATED_AND_WAITING_FOR_REQUIRED
void wait() const
Definition: Component_Impl.h:50
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
CELIX_FRAMEWORK_EXPORT celix_dm_component_t * celix_dmComponent_createWithUUID(celix_bundle_context_t *context, const char *name, const char *UUID)
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:146
Component< T > & removeCallbacks()
Definition: Component_Impl.h:380
ComponentState
Definition: Component.h:43
@ CELIX_DM_CMP_STATE_INITIALIZING
Definition: celix_dm_component.h:41
@ CELIX_DM_CMP_STATE_DEINITIALIZING
Definition: celix_dm_component.h:42
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:153
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