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

Fluent builder API to track services. More...

#include <TrackerBuilders.h>

Public Member Functions

 ServiceTrackerBuilder (std::shared_ptr< celix_bundle_context_t > _cCtx, std::string_view _name)
 
ServiceTrackerBuilderoperator= (ServiceTrackerBuilder &&)=delete
 
 ServiceTrackerBuilder (const ServiceTrackerBuilder &)=delete
 
ServiceTrackerBuilder operator= (const ServiceTrackerBuilder &)=delete
 
ServiceTrackerBuildersetFilter (std::string_view f)
 Set filter to be used to matching services. More...
 
ServiceTrackerBuildersetFilter (celix::Filter f)
 Set filter to be used to matching services. More...
 
template<typename F >
ServiceTrackerBuilderaddAddCallback (F &&add)
 Adds a add callback function, which will be called - on the Celix event thread - when a new service match is found. More...
 
template<typename F >
ServiceTrackerBuilderaddAddWithPropertiesCallback (F &&add)
 Adds a add callback function, which will be called - on the Celix event thread - when a new service match is found. More...
 
template<typename F >
ServiceTrackerBuilderaddAddWithOwnerCallback (F &&add)
 Adds a add callback function, which will be called - on the Celix event thread - when a new service match is found. More...
 
template<typename F >
ServiceTrackerBuilderaddRemCallback (F &&remove)
 Adds a remove callback function, which will be called - on the Celix event thread - when a service match is being removed. More...
 
template<typename F >
ServiceTrackerBuilderaddRemWithPropertiesCallback (F &&remove)
 Adds a remove callback function, which will be called - on the Celix event thread - when a service match is being removed. More...
 
template<typename F >
ServiceTrackerBuilderaddRemWithOwnerCallback (F &&remove)
 Adds a remove callback function, which will be called - on the Celix event thread - when a service match is being removed. More...
 
template<typename F >
ServiceTrackerBuilderaddSetCallback (F &&set)
 Adds a set callback function, which will be called - on the Celix event thread - when there is a new highest ranking service match. This can can also be an empty match (nullptr). More...
 
template<typename F >
ServiceTrackerBuilderaddSetWithPropertiesCallback (F &&set)
 Adds a set callback function, which will be called - on the Celix event thread - when there is a new highest ranking service match. This can can also be an empty match (nullptr). More...
 
template<typename F >
ServiceTrackerBuilderaddSetWithOwner (F &&set)
 Adds a set callback function, which will be called - on the Celix event thread - when there is a new highest ranking service match. This can can also be an empty match (nullptr). More...
 
std::shared_ptr< ServiceTracker< I > > build ()
 "Builds" the service tracker and returns a ServiceTracker. More...
 

Friends

class BundleContext
 

Detailed Description

template<typename I>
class celix::ServiceTrackerBuilder< I >

Fluent builder API to track services.

See also
celix::BundleContext::trackServices for more info.
Template Parameters
IThe service type to track.
Note
Not thread safe.

Constructor & Destructor Documentation

◆ ServiceTrackerBuilder() [1/2]

template<typename I >
celix::ServiceTrackerBuilder< I >::ServiceTrackerBuilder ( std::shared_ptr< celix_bundle_context_t >  _cCtx,
std::string_view  _name 
)
inlineexplicit

◆ ServiceTrackerBuilder() [2/2]

template<typename I >
celix::ServiceTrackerBuilder< I >::ServiceTrackerBuilder ( const ServiceTrackerBuilder< I > &  )
delete

Member Function Documentation

◆ addAddCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addAddCallback ( F &&  add)
inline

Adds a add callback function, which will be called - on the Celix event thread - when a new service match is found.

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service)>
Parameters
addThe callback function which will be called when a new service is found.
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addAddWithOwnerCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addAddWithOwnerCallback ( F &&  add)
inline

Adds a add callback function, which will be called - on the Celix event thread - when a new service match is found.

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties, const std::shared_ptr<const celix::Bundle>&)>
Parameters
addThe callback function which will be called when a new service is found.
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addAddWithPropertiesCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addAddWithPropertiesCallback ( F &&  add)
inline

Adds a add callback function, which will be called - on the Celix event thread - when a new service match is found.

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)>
Parameters
addThe callback function which will be called when a new service is found.
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addRemCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addRemCallback ( F &&  remove)
inline

Adds a remove callback function, which will be called - on the Celix event thread - when a service match is being removed.

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service)>
Parameters
removeThe callback function which will be called when a added service is being removed.
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addRemWithOwnerCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addRemWithOwnerCallback ( F &&  remove)
inline

Adds a remove callback function, which will be called - on the Celix event thread - when a service match is being removed.

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties, const std::shared_ptr<const celix::Bundle>&)>
Parameters
removeThe callback function which will be called when a added service is being removed.
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addRemWithPropertiesCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addRemWithPropertiesCallback ( F &&  remove)
inline

Adds a remove callback function, which will be called - on the Celix event thread - when a service match is being removed.

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)>
Parameters
removeThe callback function which will be called when a added service is being removed.
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addSetCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addSetCallback ( F &&  set)
inline

Adds a set callback function, which will be called - on the Celix event thread - when there is a new highest ranking service match. This can can also be an empty match (nullptr).

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service)>
Parameters
setThe callback function which will be called when a new highest ranking service is found or when the last matching service is being removed (svc and properties will be a nullptr).
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addSetWithOwner()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addSetWithOwner ( F &&  set)
inline

Adds a set callback function, which will be called - on the Celix event thread - when there is a new highest ranking service match. This can can also be an empty match (nullptr).

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties, const std::shared_ptr<const celix::Bundle>&)>>
Parameters
setThe callback function which will be called when a new highest ranking service is found or when the last matching service is being removed (svc and properties will be a nullptr).
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ addSetWithPropertiesCallback()

template<typename I >
template<typename F >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::addSetWithPropertiesCallback ( F &&  set)
inline

Adds a set callback function, which will be called - on the Celix event thread - when there is a new highest ranking service match. This can can also be an empty match (nullptr).

Template Parameters
FThe callback function type. Signature should be compatible with std::function<void(const std::share_ptr<I>& service, const std::shared_ptr<const celix::Properties>& properties)>
Parameters
setThe callback function which will be called when a new highest ranking service is found or when the last matching service is being removed (svc and properties will be a nullptr).
Returns
The ServiceTrackerBuilder reference for chaining (Fluent API).

◆ build()

template<typename I >
std::shared_ptr<ServiceTracker<I> > celix::ServiceTrackerBuilder< I >::build ( )
inline

"Builds" the service tracker and returns a ServiceTracker.

The ServiceTracker will be started async.

◆ operator=() [1/2]

template<typename I >
ServiceTrackerBuilder celix::ServiceTrackerBuilder< I >::operator= ( const ServiceTrackerBuilder< I > &  )
delete

◆ operator=() [2/2]

template<typename I >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::operator= ( ServiceTrackerBuilder< I > &&  )
delete

◆ setFilter() [1/2]

template<typename I >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::setFilter ( celix::Filter  f)
inline

Set filter to be used to matching services.

◆ setFilter() [2/2]

template<typename I >
ServiceTrackerBuilder& celix::ServiceTrackerBuilder< I >::setFilter ( std::string_view  f)
inline

Set filter to be used to matching services.

The filter must be LDAP filter. Example: "(property_key=value)"

Friends And Related Function Documentation

◆ BundleContext

template<typename I >
friend class BundleContext
friend

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