CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkEventDefinitions.h
Go to the documentation of this file.
1/*
2 * ctkEventDefinitions.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 CTKEVENTDEFINITIONS_H
13#define CTKEVENTDEFINITIONS_H
14
15// Qt includes
16#include <QByteArray>
17#include <QList>
18#include <QMap>
19#include <QVariant>
20#include <QString>
21#include <QStringList>
22#include <QHash>
23#include <QThread>
24#include <QThreadPool>
25#include <QObject>
26#include <QDebug>
27
28#include "org_commontk_eventbus_Export.h"
29
30//defines
31
32#define TOPIC "event.topics"
33#define TYPE "EventType"
34#define SIGTYPE "SignatureType"
35#define OBJECT "ObjectPointer"
36#define SIGNATURE "Signature"
37
38class ctkBusEvent;
39
40#define ctkRegisterLocalSignal(topic, sender, signature) \
41 {\
42 ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeLocal, ctkEventBus::ctkSignatureTypeSignal, static_cast<QObject*>(sender), signature); \
43 bool ok = ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
44 if(!ok) {\
45 qWarning("%s", tr("Some problem occourred during the signal registration with ID '%1'.").arg(topic).toLatin1().data());\
46 if(properties) {delete properties; properties = NULL;} \
47 }\
48 }
49
50#define ctkRegisterRemoteSignal(topic, sender, signature) \
51 {\
52 ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeRemote, ctkEventBus::ctkSignatureTypeSignal, static_cast<QObject*>(sender), signature); \
53 bool ok = ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
54 if(!ok) {\
55 qWarning("%s", tr("Some problem occourred during the signal registration with ID '%1'.").arg(topic).toLatin1().data());\
56 if(properties) {delete properties; properties = NULL;} \
57 }\
58 }
59
60#define ctkRegisterLocalCallback(topic, observer, signature) \
61 {\
62 ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeLocal, ctkEventBus::ctkSignatureTypeCallback, static_cast<QObject*>(observer), signature); \
63 bool ok = ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
64 if(!ok) {\
65 qWarning("%s", tr("Some problem occourred during the callback registration with ID '%1'.").arg(topic).toLatin1().data());\
66 if(properties) {delete properties; properties = NULL;} \
67 }\
68 }
69
70#define ctkRegisterRemoteCallback(topic, sender, signature) \
71 {\
72 ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeRemote, ctkEventBus::ctkSignatureTypeCallback, static_cast<QObject*>(sender), signature); \
73 bool ok = ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
74 if(!ok) {\
75 qWarning("%s", tr("Some problem occourred during the callback registration with ID '%1'.").arg(topic).toLatin1().data());\
76 if(properties) {delete properties; properties = NULL;} \
77 }\
78 }
79
80
81namespace ctkEventBus {
82//forward classes
83class ctkNetworkConnector;
84
87
90
92typedef enum {
96
98typedef enum {
102
106#define ctkEventArgument(type, data) QArgument<type >(#type, data)
107#define ctkGenericReturnArgument QGenericReturnArgument
108#define ctkEventReturnArgument(type, data) QReturnArgument<type >(#type, data)
109
110
113
116
118typedef QMap<QString, QList<QVariant::Type> > mafRegisterMethodsMap;
119
120} // namespace ctkEventBus
121
122
125
126#endif // CTKEVENTDEFINITIONS_H
Q_DECLARE_METATYPE(ctkEventBus::ctkEventArgumentsListPointer)
QMap< QString, QList< QVariant::Type > > mafRegisterMethodsMap
map which represent list of function to be registered in the server, with parameters
QHash< QString, QVariant > ctkEventHash
typedef that represents dictionary entries ( key , value )
ctkEventArgumentsList * ctkEventArgumentsListPointer
QList< QGenericArgument > ctkEventArgumentsList
List of the arguments to be sent through the event bus.
QList< ctkBusEvent * > ctkEventItemListType
type definition for observers' properties list to be stored into the event's hash.
QHash< QString, ctkNetworkConnector * > ctkNetworkConnectorHash
Hash table that associate the communication protocol with the corresponding network connector class (...
QHash< QString, ctkBusEvent * > ctkEventsHashType
Types definitions for events' hash (to be more readable).