Apache Celix  2.3.0
An implementation of the OSGi specification adapted to C and C++
Public Member Functions | List of all members
celix::dm::ServiceDependency< T, I > Class Template Reference

A service dependency for a component. More...

#include <ServiceDependency.h>

Inheritance diagram for celix::dm::ServiceDependency< T, I >:
Inheritance graph
[legend]
Collaboration diagram for celix::dm::ServiceDependency< T, I >:
Collaboration graph
[legend]

Public Member Functions

 ServiceDependency (celix_dm_component_t *cCmp, const std::string &name)
 
 ~ServiceDependency () override=default
 
 ServiceDependency (const ServiceDependency &)=delete
 
ServiceDependencyoperator= (const ServiceDependency &)=delete
 
 ServiceDependency (ServiceDependency &&) noexcept=delete
 
ServiceDependencyoperator= (ServiceDependency &&) noexcept=delete
 
ServiceDependency< T, I > & setName (const std::string &_name)
 
ServiceDependency< T, I > & setFilter (const std::string &filter)
 
ServiceDependency< T, I > & setVersionRange (const std::string &versionRange)
 
ServiceDependency< T, I > & setCallbacks (void(T::*set)(I *service))
 
ServiceDependency< T, I > & setCallbacks (void(T::*set)(I *service, Properties &&properties))
 
ServiceDependency< T, I > & setCallbacks (std::function< void(I *service, Properties &&properties)> set)
 
ServiceDependency< T, I > & setCallbacks (void(T::*set)(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties))
 Set the set callback for when the service dependency becomes available using shared pointers. More...
 
ServiceDependency< T, I > & setCallbacks (std::function< void(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)> set)
 Set the set callback for when the service dependency becomes available using shared pointers. More...
 
ServiceDependency< T, I > & setCallbacks (void(T::*set)(const std::shared_ptr< I > &service))
 Set the set callback for when the service dependency becomes available using shared pointers. More...
 
ServiceDependency< T, I > & setCallbacks (std::function< void(const std::shared_ptr< I > &service)> set)
 Set the set callback for when the service dependency becomes available using shared pointers. More...
 
ServiceDependency< T, I > & setCallbacks (void(T::*add)(I *service), void(T::*remove)(I *service))
 
ServiceDependency< T, I > & setCallbacks (void(T::*add)(I *service, Properties &&properties), void(T::*remove)(I *service, Properties &&properties))
 
ServiceDependency< T, I > & setCallbacks (std::function< void(I *service, Properties &&properties)> add, std::function< void(I *service, Properties &&properties)> remove)
 
ServiceDependency< T, I > & setCallbacks (void(T::*add)(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties), void(T::*remove)(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties))
 Set the add and remove callback for a service dependency using shared pointers. More...
 
ServiceDependency< T, I > & setCallbacks (std::function< void(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)> add, std::function< void(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)> remove)
 Set the add and remove callback for a service dependency using shared pointers. More...
 
ServiceDependency< T, I > & setCallbacks (void(T::*add)(const std::shared_ptr< I > &service), void(T::*remove)(const std::shared_ptr< I > &service))
 Set the add and remove callback for a service dependency using shared pointers. More...
 
ServiceDependency< T, I > & setCallbacks (std::function< void(const std::shared_ptr< I > &service)> add, std::function< void(const std::shared_ptr< I > &service)> remove)
 Set the add and remove callback for a service dependency using shared pointers. More...
 
ServiceDependency< T, I > & setRequired (bool req)
 
ServiceDependency< T, I > & setStrategy (DependencyUpdateStrategy strategy)
 
ServiceDependency< T, I > & setAddLanguageFilter (bool addLang)
 
ServiceDependency< T, I > & build ()
 
ServiceDependency< T, I > & buildAsync ()
 
- Public Member Functions inherited from celix::dm::TypedServiceDependency< T >
 TypedServiceDependency (celix_dm_component_t *cCmp)
 
 ~TypedServiceDependency () override=default
 
 TypedServiceDependency (const TypedServiceDependency &)=delete
 
TypedServiceDependencyoperator= (const TypedServiceDependency &)=delete
 
 TypedServiceDependency (TypedServiceDependency &&) noexcept=delete
 
TypedServiceDependencyoperator= (TypedServiceDependency &&) noexcept=delete
 
void setComponentInstance (T *cmp)
 
- Public Member Functions inherited from celix::dm::BaseServiceDependency
 BaseServiceDependency (celix_dm_component_t *c)
 
virtual ~BaseServiceDependency () noexcept
 
 BaseServiceDependency (const BaseServiceDependency &)=delete
 
BaseServiceDependencyoperator= (const BaseServiceDependency &)=delete
 
 BaseServiceDependency (BaseServiceDependency &&) noexcept=delete
 
BaseServiceDependencyoperator= (BaseServiceDependency &&) noexcept=delete
 
bool isValid () const __attribute__((deprecated))
 
celix_dm_service_dependency_t * cServiceDependency () const
 
void wait () const
 
void runBuild ()
 

Additional Inherited Members

- Protected Member Functions inherited from celix::dm::BaseServiceDependency
void setDepStrategy (DependencyUpdateStrategy strategy)
 
template<typename U >
void waitForExpired (std::weak_ptr< U > observe, long svcId, const char *observeType)
 
- Protected Attributes inherited from celix::dm::TypedServiceDependency< T >
T * componentInstance {nullptr}
 
- Protected Attributes inherited from celix::dm::BaseServiceDependency
celix_dm_service_dependency_t * cServiceDep {nullptr}
 

Detailed Description

template<class T, class I>
class celix::dm::ServiceDependency< T, I >

A service dependency for a component.

Template Parameters
TThe component type
IThe service interface type

Constructor & Destructor Documentation

◆ ServiceDependency() [1/3]

template<class T , class I >
ServiceDependency::ServiceDependency ( celix_dm_component_t *  cCmp,
const std::string &  name 
)

◆ ~ServiceDependency()

template<class T , class I >
celix::dm::ServiceDependency< T, I >::~ServiceDependency ( )
overridedefault

◆ ServiceDependency() [2/3]

template<class T , class I >
celix::dm::ServiceDependency< T, I >::ServiceDependency ( const ServiceDependency< T, I > &  )
delete

◆ ServiceDependency() [3/3]

template<class T , class I >
celix::dm::ServiceDependency< T, I >::ServiceDependency ( ServiceDependency< T, I > &&  )
deletenoexcept

Member Function Documentation

◆ build()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::build

"Build" the service dependency. When build the service dependency is active and the service tracker is created.

Should not be called on the Celix event thread.

Returns
the service dependency reference for chaining (fluent API)

◆ buildAsync()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::buildAsync

Same a build, but will not wait till the underlining service trackers are opened. Can be called on the Celix event thread.

Returns
the service dependency reference for chaining (fluent API)

◆ operator=() [1/2]

template<class T , class I >
ServiceDependency& celix::dm::ServiceDependency< T, I >::operator= ( const ServiceDependency< T, I > &  )
delete

◆ operator=() [2/2]

template<class T , class I >
ServiceDependency& celix::dm::ServiceDependency< T, I >::operator= ( ServiceDependency< T, I > &&  )
deletenoexcept

◆ setAddLanguageFilter()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setAddLanguageFilter ( bool  addLang)

Specify if the service dependency should add a service.lang filter part if it is not already present For C++ service dependencies 'service.lang=C++' will be added. Should be called before

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [1/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( std::function< void(const std::shared_ptr< I > &service)>  add,
std::function< void(const std::shared_ptr< I > &service)>  remove 
)

Set the add and remove callback for a service dependency using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [2/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( std::function< void(const std::shared_ptr< I > &service)>  set)

Set the set callback for when the service dependency becomes available using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [3/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( std::function< void(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)>  add,
std::function< void(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)>  remove 
)

Set the add and remove callback for a service dependency using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [4/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( std::function< void(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)>  set)

Set the set callback for when the service dependency becomes available using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [5/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( std::function< void(I *service, Properties &&properties)>  add,
std::function< void(I *service, Properties &&properties)>  remove 
)

Set the add and remove callback for when the services of service dependency are added or removed.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [6/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( std::function< void(I *service, Properties &&properties)>  set)

Set the set callback for when the service dependency becomes available

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [7/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(const std::shared_ptr< I > &service)  add,
void(T::*)(const std::shared_ptr< I > &service)  remove 
)

Set the add and remove callback for a service dependency using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [8/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)  add,
void(T::*)(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)  remove 
)

Set the add and remove callback for a service dependency using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [9/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(I *service)  add,
void(T::*)(I *service)  remove 
)

Set the add and remove callback for when the services of service dependency are added or removed.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [10/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(I *service, Properties &&properties)  add,
void(T::*)(I *service, Properties &&properties)  remove 
)

Set the add and remove callback for when the services of service dependency are added or removed.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [11/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(const std::shared_ptr< I > &service)  set)

Set the set callback for when the service dependency becomes available using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [12/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(const std::shared_ptr< I > &service, const std::shared_ptr< const celix::Properties > &properties)  set)

Set the set callback for when the service dependency becomes available using shared pointers.

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [13/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(I *service)  set)

Set the set callback for when the service dependency becomes available

Returns
the service dependency reference for chaining (fluent API)

◆ setCallbacks() [14/14]

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setCallbacks ( void(T::*)(I *service, Properties &&properties)  set)

Set the set callback for when the service dependency becomes available

Returns
the service dependency reference for chaining (fluent API)

◆ setFilter()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setFilter ( const std::string &  filter)

Set the service filter of the service dependency.

Returns
the service dependency reference for chaining (fluent API)

◆ setName()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setName ( const std::string &  _name)

Set the service name of the service dependency.

Returns
the service dependency reference for chaining (fluent API)

◆ setRequired()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setRequired ( bool  req)

Specify if the service dependency is required. Default is false

Returns
the service dependency reference for chaining (fluent API)

◆ setStrategy()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setStrategy ( DependencyUpdateStrategy  strategy)

Specify if the update strategy to use

Returns
the service dependency reference for chaining (fluent API)

◆ setVersionRange()

template<class T , class I >
ServiceDependency< T, I > & ServiceDependency::setVersionRange ( const std::string &  versionRange)

Set the service version range of the service dependency.

Returns
the service dependency reference for chaining (fluent API)

The documentation for this class was generated from the following files: