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.
|
Go to the documentation of this file.
30 #include <type_traits>
38 #include "celix_dependency_manager.h"
42 namespace celix {
namespace dm {
169 std::mutex instanceMutex{};
170 std::unique_ptr<T> instance {
nullptr};
171 std::shared_ptr<T> sharedInstance {
nullptr};
172 std::vector<T> valInstance {};
174 void (T::*initFp)() = {};
175 void (T::*startFp)() = {};
176 void (T::*stopFp)() = {};
177 void (T::*deinitFp)() = {};
179 int (T::*initFpNoExc)() = {};
180 int (T::*startFpNoExc)() = {};
181 int (T::*stopFpNoExc)() = {};
182 int (T::*deinitFpNoExc)() = {};
190 Component(celix_bundle_context_t *
context, celix_dependency_manager_t*
cDepMan, std::string name, std::string uuid);
199 static std::shared_ptr<Component<T>>
create(celix_bundle_context_t*, celix_dependency_manager_t*
cDepMan, std::string name, std::string uuid);
420 int invokeLifecycleMethod(
const std::string& methodName,
void (T::*lifecycleMethod)());
@ CELIX_DM_CMP_STATE_INITIALIZED_AND_WAITING_FOR_REQUIRED
Definition: celix_dm_component.h:44
Definition: ProvidedService.h:57
A service dependency for a component.
Definition: ServiceDependency.h:134
const std::string & getName() const
Definition: Component.h:91
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:79
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:41
@ CELIX_DM_CMP_STATE_SUSPENDING
Definition: celix_dm_component.h:48
@ CELIX_DM_CMP_STATE_TRACKING_OPTIONAL
Definition: celix_dm_component.h:47
std::ostream & operator<<(std::ostream &out, const BaseComponent &cmp)
Definition: Component_Impl.h:54
celix_bundle_context_t * context
Definition: Component.h:146
@ CELIX_DM_CMP_STATE_SUSPENDED
Definition: celix_dm_component.h:49
std::atomic< bool > cmpAddedToDepMan
Definition: Component.h:152
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:155
@ CELIX_DM_CMP_STATE_RESUMING
Definition: celix_dm_component.h:50
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:45
ComponentState getState() const
Definition: Component.h:98
std::string cmpName
Definition: Component.h:150
std::string cmpUUID
Definition: Component.h:149
Definition: Component.h:166
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:74
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:157
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:84
@ CELIX_DM_CMP_STATE_STOPPING
Definition: celix_dm_component.h:46
friend std::ostream & operator<<(std::ostream &out, const BaseComponent &cmp)
celix_dm_component_t * cCmp
Definition: Component.h:148
std::vector< std::shared_ptr< BaseProvidedService > > providedServices
Definition: Component.h:156
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:147
Component< T > & removeCallbacks()
Definition: Component_Impl.h:380
ComponentState
Definition: Component.h:44
@ CELIX_DM_CMP_STATE_INITIALIZING
Definition: celix_dm_component.h:42
@ CELIX_DM_CMP_STATE_DEINITIALIZING
Definition: celix_dm_component.h:43
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:60
Definition: Component.h:58
A service dependency for a component.
Definition: ServiceDependency.h:260
std::mutex mutex
Definition: Component.h:154
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