Poco::OSP

class ServiceListener

Library: OSP
Package: Service
Header: Poco/OSP/ServiceListener.h

Description

ServiceListener objects are used to dynamically react to service registrations and unregistrations.

A ServiceListener is created with a query string (in same format as the one passed to ServiceRegistry::find()), as well as two event delegates by calling ServiceRegistry::createListener().

Whenever a service is registered that matches the given query, the serviceRegistered event is fired.

Correspondingly, when a matching service is unregistered, the serviceUnregistered event is fired.

When the ServiceListener is created and there are already services registered that match the query, the serviceRegistered delegate is immediately called for each service.

Inheritance

Direct Base Classes: Poco::RefCountedObject

All Base Classes: Poco::RefCountedObject

Member Summary

Member Functions: init, onServiceRefRegistered, onServiceRefUnregistered, onServiceRegistered, onServiceUnregistered

Inherited Functions: duplicate, referenceCount, release

Types

ConstPtr

typedef const Ptr ConstPtr;

Ptr

typedef Poco::AutoPtr < ServiceListener > Ptr;

Constructors

ServiceListener protected inline

template < typename Delegate > ServiceListener(
    ServiceRegistry & registry,
    const std::string & query,
    const Delegate & registeredDelegate,
    const Delegate & unregisteredDelegate
);

Destructor

~ServiceListener virtual

~ServiceListener();

Destroys the ServiceListener.

Member Functions

init protected

void init(
    const std::string & query
);

onServiceRefRegistered protected

void onServiceRefRegistered(
    const ServiceRef::Ptr & pServiceRef
);

onServiceRefUnregistered protected

void onServiceRefUnregistered(
    const ServiceRef::Ptr & pServiceRef
);

onServiceRegistered protected

void onServiceRegistered(
    ServiceEvent & event
);

onServiceUnregistered protected

void onServiceUnregistered(
    ServiceEvent & event
);

Variables

serviceRegistered

Poco::BasicEvent < const ServiceRef::Ptr > serviceRegistered;

Fired when a service matching the query string has been newly registered.

serviceUnregistered

Poco::BasicEvent < const ServiceRef::Ptr > serviceUnregistered;

Fired when a previously registered service matching the query string has been unregistered.