File Information
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 Aliases
ConstPtr
Ptr
using Ptr = Poco::AutoPtr < ServiceListener >;
Constructors
ServiceListener
template < typename Delegate > ServiceListener(
ServiceRegistry & registry,
const std::string & query,
const Delegate & registeredDelegate,
const Delegate & unregisteredDelegate
);
Destructor
~ServiceListener
~ServiceListener();
Destroys the ServiceListener.
Member Functions
init
void init(
const std::string & query
);
onServiceRefRegistered
void onServiceRefRegistered(
const ServiceRef::Ptr & pServiceRef
);
onServiceRefUnregistered
void onServiceRefUnregistered(
const ServiceRef::Ptr & pServiceRef
);
onServiceRegistered
void onServiceRegistered(
ServiceEvent & event
);
onServiceUnregistered
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.