Hyperspace::CapabilityWatcher Class Reference

Watches over a list of capabilities throughout all Hyperspace accessible devices. More...

#include <HyperspaceClient/CapabilityWatcher>

Inheritance diagram for Hyperspace::CapabilityWatcher:

Public Types

enum  Status : quint8 { Status::Unknown, Status::Announced, Status::Expired, Status::Purged }
 
enum  WatchedEvent : quint8 {
  WatchedEvent::NoEvent, WatchedEvent::Announced, WatchedEvent::Expired, WatchedEvent::Purged,
  WatchedEvent::Introspection, WatchedEvent::IntrospectionData, WatchedEvent::PresenceEvents, WatchedEvent::All
}
 

Signals

void capabilityStatusChanged (const QByteArray &capability, Hyperspace::CapabilityWatcher::Status status)
 
void capabilityIntrospectionChanged (const QByteArray &capability)
 
void capabilityIntrospectionDataChanged (const QByteArray &capability, const QList< QByteArray > &servicesUrl)
 
- Signals inherited from Hemera::AsyncInitObject
void ready ()
 

Public Member Functions

 CapabilityWatcher (const QList< QByteArray > &capabilities, WatchedEvents watchedEvents=WatchedEvent::PresenceEvents, QObject *parent=0)
 
virtual ~CapabilityWatcher ()
 
void addCapabilities (const QList< QByteArray > &capabilities)
 
void removeCapabilities (const QList< QByteArray > &capabilities)
 
WatchedEvents watchedEvents () const
 

Protected Member Functions

virtual void initImpl () Q_DECL_OVERRIDE Q_DECL_FINAL
 
- Protected Member Functions inherited from Hemera::AsyncInitObject
void setParts (uint parts)
 

Additional Inherited Members

- Public Slots inherited from Hemera::AsyncInitObject
Hemera::Operationinit ()
 
- Protected Slots inherited from Hemera::AsyncInitObject
void setReady ()
 
void setInitError (const QString &errorName, const QString &message=QString())
 
void setOnePartIsReady ()
 

Detailed Description

Watches over a list of capabilities throughout all Hyperspace accessible devices.

CapabilityWatcher exposes Hyperspace's discovery features as a stateful object, monitoring capabilities the user is interested in. To minimize data transfer and processing, the user MUST specify a set of capabilities he wants to monitor.

When using CapabilityWatcher, the user needs to specify both the set of Capabilities to watch for and a set of WatchedEvents. WatchedEvents are specific to a CapabilityWatcher: if you need to monitor different capabilities for different events, create different CapabilityWatchers.

Note
Into an Hemera Application, any number of CapabilityWatchers can be created without any relevant impact on performances, due to the fact the processing and transfer logic is centralized among all the discovery classes.
Semantics in this class are similar to QDBusServiceWatcher 's ones.
See also
QDBusServiceWatcher

Member Enumeration Documentation

Defines the status of a specific Capability. Several discovery services might expose the same capability, hence this represents a grouped presence of a specific capability over a variety of services.

To retrieve the list of URLs the capability can be accessed from, you will need to introspect it.

Enumerator
Unknown 

The capability is in an unknown state. It probably has been never advertised.

Announced 

The capability has been announced and is present on one or more networks.

Expired 

The capability has expired or been purged from every known network.

Purged 

The capability has been purged from every known network.

Specifies events CapabilityWatcher can watch for. Use the WatchedEvents flags to specify the behavior of a CapabilityWatcher instance.

Enumerator
NoEvent 

Watches for no event.

Announced 

Watches for "Announced" event.

Expired 

Watches for "Expired" event.

Purged 

Watches for "Purged" event.

Introspection 

Watches for introspection changes, notifying when URLs referring to this capability have changed.

IntrospectionData 

Watches introspection data, and processes the actual introspection as well. Increases significantly data exchanges over the pipes.

PresenceEvents 

Watches for all presence events.

All 

Watches for every event, and downloads services URL data. Uses a lot of bandwidth.

Constructor & Destructor Documentation

Hyperspace::CapabilityWatcher::CapabilityWatcher ( const QList< QByteArray > &  capabilities,
WatchedEvents  watchedEvents = WatchedEvent::PresenceEvents,
QObject *  parent = 0 
)
explicit

Constructs a CapabilityWatcher object, and starts monitoring for capabilities right after its initialization.

capabilities A list of capabilities to watch for watchedEvents The events this CapabilityWatcher should watch for for its capabilities parent A parent for QObject's parenting system.

Hyperspace::CapabilityWatcher::~CapabilityWatcher ( )
virtual

Destroys the object, and stops watching for the capabilities it was assigned to.

Member Function Documentation

void Hyperspace::CapabilityWatcher::addCapabilities ( const QList< QByteArray > &  capabilities)

Adds more capabilities to the list of watched capabilities.

Note
This method can be called only after the object has been initialized.

capabilities The list of additional capabilities to watch for

void Hyperspace::CapabilityWatcher::removeCapabilities ( const QList< QByteArray > &  capabilities)

Removes capabilities from the list of watched capabilities.

Note
This method can be called only after the object has been initialized.

capabilities The list of capabilities not to watch for anymore.

CapabilityWatcher::WatchedEvents Hyperspace::CapabilityWatcher::watchedEvents ( ) const
Returns
the WatchedEvents of this CapabilityWatcher
void Hyperspace::CapabilityWatcher::initImpl ( )
protectedvirtual

Implements the object intialization

When implementing an AsyncInitObject, this method should hold your initialization logic. It is called by AsyncInitObject when needed, and the developer should just reimplement it without invoking it.

Once the initialization procedure is completed, either setReady, setOnePartIsReady or setInitError must be called.

Implements Hemera::AsyncInitObject.

void Hyperspace::CapabilityWatcher::capabilityStatusChanged ( const QByteArray &  capability,
Hyperspace::CapabilityWatcher::Status  status 
)
signal

Emitted upon the status changed of a monitored capability.

This signal will be emitted only for those statuses enabled in watchedEvents and for this CapabilityWatcher 's assigned capabilities. Any other change in Hyperspace will not be notified.

capability The changed capability status The new status of capability

void Hyperspace::CapabilityWatcher::capabilityIntrospectionChanged ( const QByteArray &  capability)
signal

Emitted upon the introspection change of a monitored capability.

This signal will be emitted only if CapabilityWatcher 's watchedEvents include Introspection.

Whenever Introspection changes, the capability changed its list of accessible URLs. If you are interested in those changes, you will need to introspect the capability or, in case you are always interested in the URL list, you can instead watch for IntrospectionData and listen to capabilityIntrospectionDataChanged.

capability The changed capability

void Hyperspace::CapabilityWatcher::capabilityIntrospectionDataChanged ( const QByteArray &  capability,
const QList< QByteArray > &  servicesUrl 
)
signal

Emitted upon the introspection change of a monitored capability.

This signal will be emitted only if CapabilityWatcher 's watchedEvents include IntrospectionData.

Whenever Introspection changes, the capability changed its list of accessible URLs. With this signal, the capability is introspected and the URL list delivered. Please note you should use this signal only if you are always interested in the capability's URLs, as it increases data exchange on Hyperspace pipes significantly.

capability The changed capability