CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkEventDispatcher.h
Go to the documentation of this file.
1/*
2 * ctkEventDispatcher.h
3 * ctkEventBus
4 *
5 * Created by Paolo Quadrani on 27/03/09.
6 * Copyright 2009 B3C. All rights reserved.
7 *
8 * See Licence at: http://tiny.cc/QXJ4D
9 *
10 */
11
12#ifndef CTKEVENTDISPATCHER_H
13#define CTKEVENTDISPATCHER_H
14
15#include "ctkEventDefinitions.h"
16
17namespace ctkEventBus {
18
23class org_commontk_eventbus_EXPORT ctkEventDispatcher : public QObject {
24 Q_OBJECT
25
26public:
29
32
34
37
40
42 bool removeObserver(const QObject *obj, const QString topic, bool qt_disconnect = true);
43
45 bool removeSignal(const QObject *obj, const QString topic = "", bool qt_disconnect = true);
46
48
52
55
57 bool isLocalSignalPresent(const QString topic) const;
58
60 virtual void notifyEvent(ctkBusEvent &event_dictionary, ctkEventArgumentsList *argList = NULL, ctkGenericReturnArgument *returnArg = NULL) const;
61
63
65Q_SIGNALS:
68
71
74
75protected:
77 virtual void initializeGlobalEvents();
78
81
83 ctkEventItemListType signalItemProperty(const QString topic) const;
84
85private:
87 bool isSignaturePresent(ctkBusEvent &props) const;
88
90
91 bool disconnectSignal(ctkBusEvent &props);
92
94 bool disconnectCallback(ctkBusEvent &props);
95
97 bool removeFromHash(ctkEventsHashType *hash, const QObject *obj, const QString topic, bool qt_disconnect = true);
98
99 ctkEventsHashType m_CallbacksHash;
100 ctkEventsHashType m_SignalsHash;
101};
102
104// Inline methods
106
108 return m_SignalsHash.values(topic);
109}
110
111} // namespace ctkEventBus
112
113#endif // CTKEVENTDISPATCHER_H
void remoteCommunicationDone()
Signal used to notify to observers that the remote communication has been terminated with success.
ctkEventDispatcher()
object constructor.
bool removeObserver(ctkBusEvent &props)
remove the callback from the observer's hash.
bool registerSignal(ctkBusEvent &props)
register custom signals use by objects to raise them events.
virtual void initializeGlobalEvents()
Register MAF global events.
bool removeObserver(const QObject *obj, const QString topic, bool qt_disconnect=true)
remove the callback from the observer's hash.
bool removeSignal(const QObject *obj, const QString topic="", bool qt_disconnect=true)
Remove the signal from the signal's hash.
bool isLocalSignalPresent(const QString topic) const
method used to check if the given signal has been already registered for the given id.
bool addObserver(ctkBusEvent &props)
Add the observer to the events.
virtual void notifyEvent(ctkBusEvent &event_dictionary, ctkEventArgumentsList *argList=NULL, QGenericReturnArgument *returnArg=NULL) const
Emit event corresponding to the given id (present into the event_dictionary) locally to the applicati...
void resetHashes()
clean the signal and callback hashes.
ctkEventItemListType signalItemProperty(const QString topic) const
Return the signal item property associated to the given ID.
bool removeSignal(ctkBusEvent &props)
Remove the signal from the signal's hash.
bool removeEventItem(ctkBusEvent &props)
Interanl method used to remove the given event property.
void notifyDefaultEvent()
Default notification signals for default events.
virtual ~ctkEventDispatcher()
object destructor.
void remoteCommunicationFailed()
Signal used to notify to observers that the remote communication failed.
#define ctkGenericReturnArgument