Signals | Public Member Functions

ContextProvider::Group Class Reference

Groups the firstSubscriberAppeared and lastSubscriberDisappeared from multiple Property objects together. More...

#include <ContextProvider>

List of all members.

Signals

void firstSubscriberAppeared ()
 Emitted when the group of Context objects is subscribed to.
void lastSubscriberDisappeared ()
 Emitted when the group of Context objects is unsubscribed from.

Public Member Functions

 Group (QObject *parent=0)
 Contructs an empty Group object with the given parent.
 ~Group ()
 Destructor.
void add (const Property &prop)
 Adds a Property object to the Group.
bool isSubscribedTo () const
 Returns true iff any Property objects in the group are subscribed to.
QSet< const Property * > getProperties ()
 Returns the set of properties currently belonging to the Group.
Groupoperator<< (const Property &prop)
Groupoperator<< (const Property *prop)

Detailed Description

Groups the firstSubscriberAppeared and lastSubscriberDisappeared from multiple Property objects together.

Group is useful in cases when multiple properties are provided by the same source, such as a hardware sensor. When any of these properties is subscribed to, the source needs to be turned on, and when none of these properties are subscribed to, the source needs to be turned off.

For example,

    Property location("Location");
    Property altitude("Altitude");

    Group gps;
    gps << location << altitude;

    connect(gps, SIGNAL(firstSubscriberAppeared()), this, SLOT(turnGpsOn()));
    connect(gps, SIGNAL(lastSubscriberDisappeared()), this, SLOT(onGpsOff()));

This way, the provider doesn't need to store the subscription statuses of the related keys.

Initially, none of the Property objects related to a Group are subscribed to. When some of them are subscribed to, Group emits the firstSubscriberAppeared signal. When all of them are again unsubscribed, Group emits the lastSubscriberDisappeared signal.


Constructor & Destructor Documentation

ContextProvider::Group::Group ( QObject *  parent = 0  )  [explicit]

Contructs an empty Group object with the given parent.

ContextProvider::Group::~Group (  ) 

Destructor.


Member Function Documentation

void ContextProvider::Group::add ( const Property property  ) 

Adds a Property object to the Group.

The Property object needs to exist as long as the Group object is in use.

void ContextProvider::Group::firstSubscriberAppeared (  )  [signal]

Emitted when the group of Context objects is subscribed to.

I.e., when none of them were subscribed to and now some of them were subscribed to.

QSet< const Property * > ContextProvider::Group::getProperties (  ) 

Returns the set of properties currently belonging to the Group.

bool ContextProvider::Group::isSubscribedTo (  )  const

Returns true iff any Property objects in the group are subscribed to.

void ContextProvider::Group::lastSubscriberDisappeared (  )  [signal]

Emitted when the group of Context objects is unsubscribed from.

I.e., when some of them were subscribed to and now all of them were unsubscribed from.

Group& ContextProvider::Group::operator<< ( const Property prop  )  [inline]
Group& ContextProvider::Group::operator<< ( const Property prop  )  [inline]

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