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::CServiceDependency< T, I > Class Template Reference

A service dependency for a component. More...

#include <ServiceDependency.h>

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

Public Member Functions

 CServiceDependency (celix_dm_component_t *cCmp, const std::string &name)
 
 ~CServiceDependency () override=default
 
 CServiceDependency (const CServiceDependency &)=delete
 
CServiceDependencyoperator= (const CServiceDependency &)=delete
 
 CServiceDependency (CServiceDependency &&) noexcept=delete
 
CServiceDependencyoperator= (CServiceDependency &&) noexcept=delete
 
CServiceDependency< T, I > & setVersionRange (const std::string &serviceVersionRange)
 
CServiceDependency< T, I > & setFilter (const std::string &filter)
 
CServiceDependency< T, I > & setRequired (bool req)
 
CServiceDependency< T, I > & setStrategy (DependencyUpdateStrategy strategy)
 
CServiceDependency< T, I > & setCallbacks (void(T::*set)(const I *service))
 
CServiceDependency< T, I > & setCallbacks (void(T::*set)(const I *service, Properties &&properties))
 
CServiceDependency< T, I > & setCallbacks (std::function< void(const I *service, Properties &&properties)> set)
 
CServiceDependency< T, I > & setCallbacks (void(T::*add)(const I *service), void(T::*remove)(const I *service))
 
CServiceDependency< T, I > & setCallbacks (void(T::*add)(const I *service, Properties &&properties), void(T::*remove)(const I *service, Properties &&properties))
 
CServiceDependency< T, I > & setCallbacks (std::function< void(const I *service, Properties &&properties)> add, std::function< void(const I *service, Properties &&properties)> remove)
 
CServiceDependency< T, I > & setAddLanguageFilter (bool addLang)
 
CServiceDependency< T, I > & build ()
 
CServiceDependency< 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, typename I>
class celix::dm::CServiceDependency< T, I >

A service dependency for a component.

Template Parameters
TThe component type
IThe service interface type
Warning
CServiceDependency is considered deprecated use celix::dm::ServiceDependency instead.

Constructor & Destructor Documentation

◆ CServiceDependency() [1/3]

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

◆ ~CServiceDependency()

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

◆ CServiceDependency() [2/3]

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

◆ CServiceDependency() [3/3]

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

Member Function Documentation

◆ build()

template<class T , class I >
CServiceDependency< T, I > & CServiceDependency::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.

◆ buildAsync()

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

Same a build, but will not wait till the underlining service tracker is created. Can be called on the Celix event thread.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ setAddLanguageFilter()

template<class T , typename I >
CServiceDependency< T, I > & CServiceDependency::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.

◆ setCallbacks() [1/6]

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

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

Returns
the C service dependency reference for chaining (fluent API)

◆ setCallbacks() [2/6]

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

Set the set callback for when the service dependency becomes available

Returns
the C service dependency reference for chaining (fluent API)

◆ setCallbacks() [3/6]

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

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

Returns
the C service dependency reference for chaining (fluent API)

◆ setCallbacks() [4/6]

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

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

Returns
the C service dependency reference for chaining (fluent API)

◆ setCallbacks() [5/6]

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

Set the set callback for when the service dependency becomes available

Returns
the C service dependency reference for chaining (fluent API)

◆ setCallbacks() [6/6]

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

Set the set callback for when the service dependency becomes available

Returns
the C service dependency reference for chaining (fluent API)

◆ setFilter()

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

Sets the service filter for the C service dependency.

Parameters
filterThe (additional) filter to use (e.g. "(location=front)")
Returns
the C service dependency reference for chaining (fluent API)

◆ setRequired()

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

Specify if the service dependency is required. Default is false

Returns
the C service dependency reference for chaining (fluent API)

◆ setStrategy()

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

Specify if the update strategy to use

Returns
the C service dependency reference for chaining (fluent API)

◆ setVersionRange()

template<class T , typename I >
CServiceDependency< T, I > & CServiceDependency::setVersionRange ( const std::string &  serviceVersionRange)

Sets the service version range for the C service dependency.

Parameters
serviceVersionRangeThe service version range, can be an empty string
Returns
the C service dependency reference for chaining (fluent API)

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