14 #ifndef USSERVICETRACKER_H
15 #define USSERVICETRACKER_H
50 template<
class T,
class TTT>
58 throw std::runtime_error(
"A custom ServiceTrackerCustomizer instance is required for custom tracked objects.");
65 throw std::runtime_error(
"A custom ServiceTrackerCustomizer instance is required for custom tracked objects.");
71 template<
class S,
class T>
72 struct TrackedTypeTraits;
86 template<
class S,
class T>
109 struct TrackedTypeTraits<S,S*>
111 typedef S* TrackedType;
113 static bool IsValid(
const TrackedType& t)
118 static TrackedType DefaultValue()
123 static void Dispose(TrackedType& t)
128 static TrackedType ConvertToTrackedType(S* s)
143 struct TrackedTypeTraits<void,void*>
147 static bool IsValid(
const TrackedType& t)
152 static TrackedType DefaultValue()
154 return TrackedType();
157 static void Dispose(TrackedType& t)
162 static TrackedType ConvertToTrackedType(
const InterfaceMap& im)
221 template<
class S,
class TTT = TrackedTypeTraits<S,S*> >
229 typedef typename TTT::TrackedType
T;
589 #include <usServiceTracker.tpp>
An RFC 1960-based Filter.
virtual void GetTracked(TrackingMap &tracked) const
Return a sorted map of the ServiceReferences and service objects for all services being tracked by th...
~ServiceTracker() override
Destructor.
virtual void Close()
Close this ServiceTracker.
virtual T GetService(const ServiceReferenceType &reference) const
Returns the service object for the specified ServiceReference if the specified referenced service is ...
ServiceTracker(ModuleContext *context, const ServiceReferenceType &reference, ServiceTrackerCustomizer< S, T > *customizer=nullptr)
Create a ServiceTracker on the specified ServiceReference.
virtual int Size() const
Return the number of services being tracked by this ServiceTracker.
virtual T GetService() const
Returns a service object for one of the services being tracked by this ServiceTracker.
virtual void Remove(const ServiceReferenceType &reference)
Remove a service from this ServiceTracker.
TTT::TrackedType T
The type of the tracked object.
ServiceTracker(ModuleContext *context, ServiceTrackerCustomizer< S, T > *customizer=nullptr)
Create a ServiceTracker on the class template argument S.
virtual ServiceReferenceType GetServiceReference() const
Returns a ServiceReference for one of the services being tracked by this ServiceTracker.
ServiceReference< S > ServiceReferenceType
The service reference type.
T AddingService(const ServiceReferenceType &reference) override
Default implementation of the ServiceTrackerCustomizer::AddingService method.
ServiceTracker(ModuleContext *context, const LDAPFilter &filter, ServiceTrackerCustomizer< S, T > *customizer=nullptr)
Create a ServiceTracker on the specified LDAPFilter object.
void RemovedService(const ServiceReferenceType &reference, T service) override
Default implementation of the ServiceTrackerCustomizer::RemovedService method.
virtual bool IsEmpty() const
Return if this ServiceTracker is empty.
virtual int GetTrackingCount() const
Returns the tracking count for this ServiceTracker.
S ServiceType
The type of the service being tracked.
std::map< ServiceReference< S >, T > TrackingMap
A map type from ServiceReference to tracked objects.
ServiceTracker(ModuleContext *context, const std::string &clazz, ServiceTrackerCustomizer< S, T > *customizer=0)
Create a ServiceTracker on the specified class name.
virtual std::vector< ServiceReferenceType > GetServiceReferences() const
Return a list of ServiceReferences for all services being tracked by this ServiceTracker.
virtual void Open()
Open this ServiceTracker and begin tracking services.
void ModifiedService(const ServiceReferenceType &reference, T service) override
Default implementation of the ServiceTrackerCustomizer::ModifiedService method.
virtual T WaitForService(unsigned long timeoutMillis=0)
Wait for at least one service to be tracked by this ServiceTracker. This method will also return when...
virtual std::vector< T > GetServices() const
Return a list of service objects for all services being tracked by this ServiceTracker.
std::map< std::string, void * > InterfaceMap
A map containing interfaces ids and their corresponding service object pointers.
static TrackedType ConvertToTrackedType(void *)
static TrackedType ConvertToTrackedType(const InterfaceMap &)
static TrackedType DefaultValue()
static bool IsValid(const TrackedType &t)
static void Dispose(TrackedType &t)