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 
17 namespace ctkEventBus {
18 
23 class org_commontk_eventbus_EXPORT ctkEventDispatcher : public QObject {
24  Q_OBJECT
25 
26 public:
29 
31  virtual ~ctkEventDispatcher();
32 
34 
36  bool addObserver(ctkBusEvent &props);
37 
39  bool removeObserver(ctkBusEvent &props);
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 
51  bool registerSignal(ctkBusEvent &props);
52 
54  bool removeSignal(ctkBusEvent &props);
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 
64  void resetHashes();
65 Q_SIGNALS:
67  void notifyDefaultEvent();
68 
70  void remoteCommunicationDone();
71 
73  void remoteCommunicationFailed();
74 
75 protected:
77  virtual void initializeGlobalEvents();
78 
80  bool removeEventItem(ctkBusEvent &props);
81 
83  ctkEventItemListType signalItemProperty(const QString topic) const;
84 
85 private:
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
ctkEventDefinitions.h
QList
Definition: ctkCmdLineModuleBackend.h:30
ctkGenericReturnArgument
#define ctkGenericReturnArgument
Definition: ctkEventDefinitions.h:107
QHash< QString, ctkBusEvent * >
ctkBusEvent
Definition: ctkBusEvent.h:40
ctkEventBus::ctkEventDispatcher::signalItemProperty
ctkEventItemListType signalItemProperty(const QString topic) const
Return the signal item property associated to the given ID.
Definition: ctkEventDispatcher.h:107
ctkEventBus::ctkEventDispatcher
Definition: ctkEventDispatcher.h:23
ctkEventBus
Definition: ctkEventBusManager.h:21