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.
Public Member Functions | Static Public Member Functions | List of all members
celix::ServiceRegistration Class Reference

A registered service. More...

#include <ServiceRegistration.h>

Public Member Functions

const std::string & getServiceName () const
 The service name for this service registration. More...
 
const std::string & getServiceVersion () const
 The service version for this service registration. More...
 
const celix::Properties & getServiceProperties () const
 The service properties for this service registration. More...
 
ServiceRegistrationState getState () const
 The state of the service registration. More...
 
long getServiceId () const
 The service id for this service registration. More...
 
long getServiceRanking () const
 The service ranking for this service registration. More...
 
void wait () const
 If the service registration is REGISTERING or UNREGISTERING, wait until state is REGISTERED OR UNREGISTERED. More...
 
void unregister ()
 Unregister the service from the Celix framework if the state is REGISTERED. More...
 
std::shared_ptr< ServiceRegistrationgetSelf () const
 Returns the shared_ptr of for this object. More...
 

Static Public Member Functions

static std::shared_ptr< ServiceRegistrationcreate (std::shared_ptr< celix_bundle_context_t > cCtx, std::shared_ptr< void > svc, std::string_view name, std::string_view version, celix::Properties properties, bool registerAsync, bool unregisterAsync, std::vector< std::function< void(ServiceRegistration &)>> onRegisteredCallbacks, std::vector< std::function< void(ServiceRegistration &)>> onUnregisteredCallbacks)
 

Detailed Description

A registered service.

Represent a registered service. If the ServiceRegistration is destroy the underlining service is unregistered in the Celix framework.

Note
Thread safe.

Member Function Documentation

◆ create()

static std::shared_ptr<ServiceRegistration> celix::ServiceRegistration::create ( std::shared_ptr< celix_bundle_context_t >  cCtx,
std::shared_ptr< void >  svc,
std::string_view  name,
std::string_view  version,
celix::Properties  properties,
bool  registerAsync,
bool  unregisterAsync,
std::vector< std::function< void(ServiceRegistration &)>>  onRegisteredCallbacks,
std::vector< std::function< void(ServiceRegistration &)>>  onUnregisteredCallbacks 
)
inlinestatic
Parameters
cCtxThe C bundle context.
svcThe service (shared ptr) to register
nameThe name of the service (objectClass) for the registration.
versionThe optional version of the service.
propertiesThe meta properties to register with to the service.
registerAsyncWhether the registration will be done async.
unregisterAsyncWhether the un-registration will be done async.
onRegisteredCallbacksThe callback which will be called when the service is registered.
onUnregisteredCallbacksThe callback wich will be called when the service is unregistered.
Returns
The new ServiceRegistration object as shared ptr.
Exceptions
celix::Exception

◆ getSelf()

std::shared_ptr<ServiceRegistration> celix::ServiceRegistration::getSelf ( ) const
inline

Returns the shared_ptr of for this object.

This method can return null when the ServiceRegistration in UNREGISTERED.

◆ getServiceId()

long celix::ServiceRegistration::getServiceId ( ) const
inline

The service id for this service registration.

◆ getServiceName()

const std::string& celix::ServiceRegistration::getServiceName ( ) const
inline

The service name for this service registration.

◆ getServiceProperties()

const celix::Properties& celix::ServiceRegistration::getServiceProperties ( ) const
inline

The service properties for this service registration.

◆ getServiceRanking()

long celix::ServiceRegistration::getServiceRanking ( ) const
inline

The service ranking for this service registration.

◆ getServiceVersion()

const std::string& celix::ServiceRegistration::getServiceVersion ( ) const
inline

The service version for this service registration.

Empty string if there is no service version.

◆ getState()

ServiceRegistrationState celix::ServiceRegistration::getState ( ) const
inline

The state of the service registration.

◆ unregister()

void celix::ServiceRegistration::unregister ( )
inline

Unregister the service from the Celix framework if the state is REGISTERED.

If ServiceRegistration::unregisterAsync is true still will be done async, if not this will be done synchronized.

◆ wait()

void celix::ServiceRegistration::wait ( ) const
inline

If the service registration is REGISTERING or UNREGISTERING, wait until state is REGISTERED OR UNREGISTERED.


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