CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Member Functions | List of all members
ctkEventAdmin Struct Referenceabstract

#include <Libs/PluginFramework/service/event/ctkEventAdmin.h>

Inheritance diagram for ctkEventAdmin:
Inheritance graph
[legend]

Public Member Functions

virtual void postEvent (const ctkEvent &event)=0
 
virtual void publishSignal (const QObject *publisher, const char *signal, const QString &topic, Qt::ConnectionType type=Qt::QueuedConnection)=0
 
virtual void sendEvent (const ctkEvent &event)=0
 
virtual qlonglong subscribeSlot (const QObject *subscriber, const char *member, const ctkDictionary &properties, Qt::ConnectionType type=Qt::AutoConnection)=0
 
virtual void unpublishSignal (const QObject *publisher, const char *signal=0, const QString &topic="")=0
 
virtual void unsubscribeSlot (qlonglong subscriptionId)=0
 
virtual bool updateProperties (qlonglong subscriptionId, const ctkDictionary &properties)=0
 
virtual ~ctkEventAdmin ()
 

Detailed Description

The Event Admin service. Plugins wishing to publish events can either obtain the Event Admin service and call one of the event delivery methods or publish a Qt signal for a specific event topic.

Definition at line 36 of file ctkEventAdmin.h.

Constructor & Destructor Documentation

◆ ~ctkEventAdmin()

virtual ctkEventAdmin::~ctkEventAdmin ( )
inlinevirtual

Definition at line 38 of file ctkEventAdmin.h.

Member Function Documentation

◆ postEvent()

virtual void ctkEventAdmin::postEvent ( const ctkEvent event)
pure virtual

Initiate asynchronous, ordered delivery of an event. This method returns to the caller before delivery of the event is completed. Events are delivered in the order that they are received by this method.

Parameters
eventThe event to send to all listeners which subscribe to the topic of the event.

◆ publishSignal()

virtual void ctkEventAdmin::publishSignal ( const QObject *  publisher,
const char *  signal,
const QString &  topic,
Qt::ConnectionType  type = Qt::QueuedConnection 
)
pure virtual

Publish (register) a Qt signal for event delivery. Emitting the signal has the same effect as calling postEvent() if type is Qt::QueuedConnection and as sendEvent() if type is Qt::DirectConnection.

The signal will be associated with the given topic and must have the following signature:

someSignal(const ctkDictionary& props)

where props will be used to construct a ctkEvent class which will additionally have the EVENT_TOPIC property set to the given topic.

This method can be called multiple times for the same signal to publish it under multiple topics. In that case, emitting the signal will result in multiple events being send.

Parameters
publisherThe owner of the signal.
signalThe signal in normalized form.
topicThe event topic to use.
typeQt::QueuedConnection for asynchronous delivery and Qt::DirectConnection for synchronous delivery.
See also
unpublishSignal()

◆ sendEvent()

virtual void ctkEventAdmin::sendEvent ( const ctkEvent event)
pure virtual

Initiate synchronous delivery of an event. This method does not return to the caller until delivery of the event is completed.

Parameters
eventThe event to send to all listeners which subscribe to the topic of the event.

◆ subscribeSlot()

virtual qlonglong ctkEventAdmin::subscribeSlot ( const QObject *  subscriber,
const char *  member,
const ctkDictionary properties,
Qt::ConnectionType  type = Qt::AutoConnection 
)
pure virtual

Subsribe for (observe) events. The slot is called whenever an event is sent which matches the topic string and LDAP search expression contained in the properties. Slots are executed either in the event delivery thread of the Event Admin implemenation or in the subscriber's thread, depending on the type argument.

Slots should be registered with a property ctkEventConstants::EVENT_TOPIC. The value being a QString or QStringList object that describes which topics the slot is interested in. A wildcard ('*' \u002A) may be used as the last token of a topic name, for example com/action&#47*. This matches any topic that shares the same first tokens. For example, com/action&#47* matches com/action/listen. Slots which have not been specified with the EVENT_TOPIC property must not receive events. The value of each entry in the EVENT_TOPIC property must conform to the following grammar:

* topic-scope ::= '*' | ( topic '&#47*' ? )
* 

Slots can also be registered with a property named ctkEventConstants::EVENT_FILTER. The value of this property must be a string containing a filter specification. Any of the event's properties can be used in the filter expression. Each slot is notified for any event which belongs to the topics the slot has expressed an interest in. If the handler has defined a EVENT_FILTER property then the event properties must also match the filter expression. If the filter is an error, then the Event Admin service should log a warning and further ignore the registered slot.

Parameters
subscriberThe owner of the slot.
memberThe slot in normalized form.
propertiesA map containing topics and a filter expression.
typeOne of Qt::AutoConnection, Qt::DirectConnection, Qt::QueuedConnection, or Qt::BlockingQueuedConnection. Only a direct or blocking queued connection ensures that calls to sendEvent() will block until all event handlers completed their tasks.
Returns
Returns an id which can be used to update the properties.
Exceptions
ctkInvalidArgumentExceptionIf subscriber or member is 0 or type is invalid.
See also
unsubscribeSlot(qlonglong)

◆ unpublishSignal()

virtual void ctkEventAdmin::unpublishSignal ( const QObject *  publisher,
const char *  signal = 0,
const QString &  topic = "" 
)
pure virtual

Unpublish (unregister) a previously published signal. After unpublishing a signal, no events will be send when the signal is emitted.

Parameters
publisherThe owner of the signal.
signalThe signal in normalized form. If the signal is NULL all signals from the given publisher published under the given topic will be unpublished.
topicThe event topic under which the given signal was published. If the topic is empty, the signal is unpublished for all topics it was previously pubished under.
See also
publishSlot()

◆ unsubscribeSlot()

virtual void ctkEventAdmin::unsubscribeSlot ( qlonglong  subscriptionId)
pure virtual

Unsubscribe a previously subscribed slot. Use this method to allow the EventAdmin implementation to clean up resources.

Parameters
subscriptionIdThe id obtained from a previous call to subscribeSlot()
See also
subscribeSlot()

◆ updateProperties()

virtual bool ctkEventAdmin::updateProperties ( qlonglong  subscriptionId,
const ctkDictionary properties 
)
pure virtual

Updates the properties of a previously registered slot. This can be used to change the topics the slot is interested in or to change the filter expression. A previously registered property can be removed by providing an invalid QVariant.

Parameters
subscriptionIdThe slot id obtained by a call to subscribeSlot().
propertiesThe properties which should be updated.
Returns
true if a slot was registered under this subscriptionId and its properties where changed, false otherwise.

The documentation for this struct was generated from the following file: