CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkEventBusManager.h
Go to the documentation of this file.
1 /*
2  * ctkEventBusManager.h
3  * ctkEventBus
4  *
5  * Created by Paolo Quadrani on 27/03/09.
6  * Copyright 2010 B3C. All rights reserved.
7  *
8  * See Licence at: http://tiny.cc/QXJ4D
9  *
10  */
11 
12 #ifndef CTKEVENTBUSMANAGER_H
13 #define CTKEVENTBUSMANAGER_H
14 
15 // Includes list
16 #include "ctkEventDefinitions.h"
19 #include "ctkBusEvent.h"
20 
21 namespace ctkEventBus {
22 
23 // Class forwarding list
24 
30 class org_commontk_eventbus_EXPORT ctkEventBusManager : public QObject {
31  Q_OBJECT
32 
33 public:
35  static ctkEventBusManager *instance();
36 
38 
40  bool addEventProperty(ctkBusEvent &props) const;
41 
43  bool removeEventProperty(ctkBusEvent &props) const;
44 
46 
49  void removeObserver(const QObject *obj, const QString topic = "", bool qt_disconnect = true);
50 
52 
55  void removeSignal(const QObject *obj, QString topic = "", bool qt_disconnect = true);
56 
58  void notifyEvent(ctkBusEvent &event_dictionary, ctkEventArgumentsList *argList = NULL, ctkGenericReturnArgument *returnArg = NULL) const;
59 
61  void notifyEvent(const QString topic, ctkEventType ev_type = ctkEventTypeLocal, ctkEventArgumentsList *argList = NULL, ctkGenericReturnArgument *returnArg = NULL) const;
62 
64  void enableEventLogging(bool enable = true);
65 
67  void logEventTopic(const QString topic);
68 
70  void logAllEvents();
71 
73  void shutdown();
74 
76  void initializeNetworkConnectors();
77 
79  bool isLocalSignalPresent(const QString topic) const;
80 
82  void plugNetworkConnector(const QString &protocol, ctkNetworkConnector *connector);
83 
85  bool createServer(const QString &communication_protocol, unsigned int listen_port);
86 
88  void startListen();
89 
91  bool createClient(const QString &communication_protocol, const QString &server_host, unsigned int port);
92 
93 public Q_SLOTS:
95  void detachObjectFromBus();
96 
97 private:
100 
103 
104  ctkEventDispatcherLocal *m_LocalDispatcher;
105  ctkEventDispatcherRemote *m_RemoteDispatcher;
106 
107  bool m_EnableEventLogging;
108  QString m_LogEventTopic;
109  ctkNetworkConnectorHash m_NetworkConnectorHash;
110 
111  bool m_SkipDetach;
112 
113 };
114 
115 } // namespace ctkEventBus
116 
117 #endif // CTKEVENTBUSMANAGER
#define ctkGenericReturnArgument