ContextSubscriber::IProviderPlugin Class Reference

Interface for provider plugins. More...

#include <iproviderplugin.h>

Inheritance diagram for ContextSubscriber::IProviderPlugin:

ContextSubscriber::ContextKitPlugin

List of all members.

Signals

void ready ()
void failed (QString error)
void subscribeFinished (QString key)
void subscribeFinished (QString key, TimedValue timedvalue)
void subscribeFailed (QString failedKey, QString error)
void valueChanged (QString key, QVariant value)
void valueChanged (QString key, TimedValue timedvalue)

Public Member Functions

virtual void subscribe (QSet< QString > keys)=0
virtual void unsubscribe (QSet< QString > keys)=0
virtual void blockUntilReady ()=0
virtual void blockUntilSubscribed (const QString &key)=0


Detailed Description

Interface for provider plugins.

Note: this interface is private, currently it is not advised to use it and create ContextKit subscriber plugins on your own, we can and will change this interface anytime in the future even between small bugfix releases.

Every Provider instance contains exactly one plugin (pointer) with this interface which is constructed on initialization time and never change after that. This way the concrete protocol (dbus, shared memory, etc.) between the library and the provider is abstracted.

The Provider instance communicates need for subscribe and unsubscribe calls (on the wire) using the subscribe and unsubscribe methods.

When the plugin is constructed, it should emit the signal ready() when it is ready to take in subscriptions. However, the signal ready() should not be emitted in the plugin constructor. If the plugin is able to take in subscriptions immediately, you can use QMetaObject::invokeMethod with QueuedConnection to emit the signal when the main loop is entered the next time.

The plugin can fail or became ready again anytime because of things happening on the wire inside the plugin (socket closed, dbus service appears/disappears). Whenever the plugin has new information about this it should emit the signal ready or failed accordingly.

When the plugin is ready, it has to be able to handle subscribe and unsubscribe function calls. Also, after emitting ready it should be in a state where it is not subscribed to anything on the wire, since immediately after ready is emitted, the provider will place a subscribe call with all of the properties that should be subscribed.

Subscription failures or successes can be signaled with emitting subscribeFailed and subscribeFinished. When the upper layer has called subscribe(), the plugin must eventually emit subscribeFinished or subscribeFailed for all the subscribed keys, or emit failed.

At last, but not least, the plugin can emit valueChanged, when it has a new value for any property. It is not required to only signal new values, the library takes care of keeping the old value and only emit change signals to the upper layers if the new value is really new.

An implementation of this interface doesn't have to care about threads at all, all of the methods, starting from the constructor will be only called from inside the Qt event loop of the main thread. This means that neither the constructor nor the subscribe, unsubscribe calls should block. They have to finish as soon as possible and signal the results later via signals.


Member Function Documentation

virtual void ContextSubscriber::IProviderPlugin::subscribe ( QSet< QString >  keys  )  [pure virtual]

virtual void ContextSubscriber::IProviderPlugin::unsubscribe ( QSet< QString >  keys  )  [pure virtual]

virtual void ContextSubscriber::IProviderPlugin::blockUntilReady (  )  [pure virtual]

virtual void ContextSubscriber::IProviderPlugin::blockUntilSubscribed ( const QString &  key  )  [pure virtual]

void ContextSubscriber::IProviderPlugin::ready (  )  [signal]

void ContextSubscriber::IProviderPlugin::failed ( QString  error  )  [signal]

void ContextSubscriber::IProviderPlugin::subscribeFinished ( QString  key  )  [signal]

void ContextSubscriber::IProviderPlugin::subscribeFinished ( QString  key,
TimedValue  timedvalue 
) [signal]

void ContextSubscriber::IProviderPlugin::subscribeFailed ( QString  failedKey,
QString  error 
) [signal]

void ContextSubscriber::IProviderPlugin::valueChanged ( QString  key,
QVariant  value 
) [signal]

void ContextSubscriber::IProviderPlugin::valueChanged ( QString  key,
TimedValue  timedvalue 
) [signal]


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

Generated on Thu Feb 21 18:31:19 2013 for libcontextsubscriber by  doxygen 1.5.6