00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef HOOKMGR_H
00024 #define HOOKMGR_H
00025
00026 #include <QObject>
00027 #include <QAbstractSocket>
00028 #include <QImage>
00029
00030 class MainWindow;
00031 class Hook;
00032 class GlobalHook;
00033 class AccountHook;
00034 class ModuleHook;
00035 class Anchor;
00036
00037 enum HookType
00038 {
00039 HOOK_TYPE_GLOBAL,
00040 HOOK_TYPE_ACCOUNT,
00041 HOOK_TYPE_MODULE
00042 };
00043
00044 class HookMgr : public QObject
00045 {
00046 Q_OBJECT
00047
00048 public:
00049 static HookMgr &getInstance();
00050 static void freeInstance();
00051 void initialize(Anchor*);
00052 void registerHook(HookType, QObject*);
00054 Anchor *anchor;
00055
00056 public slots:
00057 void onPong(int);
00058 void onConnect();
00059 void onReconnect(int);
00060 void onDisconnect();
00061 void onSocketError(QAbstractSocket::SocketError);
00062 void onLoginAccepted(bool);
00063 void onReceiveMedicineModel(const QString&);
00064 void onReceivePatientsModel(const QString&);
00065 void onReceiveBodyPartsModel(const QString&);
00066 void onReceivePatientInfos(const QString&);
00067 void onReceiveNewPatientInfos(const QString&);
00068 void onReceivePatientModifs(int, const QString&);
00069 void onReceiveNewDiagnostic(int, const QString&);
00070 void onReceiveNewSymptom(int, const QString&);
00071 void onReceiveRemovePrescription(int, int);
00072 void onReceiveNewPrescription(int);
00073 void onReceiveModifyPrescription(int);
00074 void onReceiveEnterChat(const QString&);
00075 void onReceiveLeaveChat(const QString&);
00076 void onReceiveChatMessage(const QString&, const QString&);
00077 void onReceiveChatUsers(const QStringList&);
00078 void onReceiveEcgData(const QList<float>&);
00079 void onReceiveAnalysisModel(const QString&);
00080 void onReceiveScan(int, int, const QImage&);
00081 void onReceiveRadio(int, int, int, const QImage&);
00082
00083 private:
00085 explicit HookMgr() { }
00087 ~HookMgr() { }
00089 static HookMgr *_instance;
00090
00091 void addHooks();
00092 void addGlobalHooks();
00093 void addAccountHooks();
00094 void addModuleHooks();
00095
00097 QList<GlobalHook*> _globalHooks;
00099 QList<AccountHook*> _accountHooks;
00101 QList<ModuleHook*> _moduleHooks;
00102 };
00103
00105 #define hookMgr HookMgr::getInstance()
00106
00107 #define ANCHOR \
00108 if (hookMgr.anchor) \
00109 hookMgr.anchor
00110
00111 class GlobalHook : public QObject
00112 {
00113 Q_OBJECT
00114
00115 protected:
00116 GlobalHook();
00117
00118 public:
00120 virtual void onPong(int) { }
00122 virtual void onConnect() { }
00124 virtual void onReconnect(int) { }
00126 virtual void onDisconnect() { }
00128 virtual void onSocketError(QAbstractSocket::SocketError) { }
00129 };
00130
00131 class AccountHook : public QObject
00132 {
00133 Q_OBJECT
00134
00135 protected:
00136 AccountHook();
00137
00138 public:
00140 virtual void onLoginAccepted() { }
00142 virtual void onLoginRefused() { }
00143 };
00144
00145 class ModuleHook : public QObject
00146 {
00147 Q_OBJECT
00148
00149 protected:
00150 ModuleHook();
00151
00152 public:
00154 virtual void onReceiveMedicineModel(const QString&) { }
00156 virtual void onReceivePatientsModel(const QString&) { }
00158 virtual void onReceiveBodyPartsModel(const QString&) { }
00160 virtual void onReceivePatientInfos(const QString&) { }
00162 virtual void onReceiveNewPatientInfos(const QString&) { }
00164 virtual void onReceivePatientModifs(int, const QString&) { }
00166 virtual void onReceiveNewDiagnostic(int, const QString&) { }
00168 virtual void onReceiveNewSymptom(int, const QString&) { }
00170 virtual void onReceiveRemovePrescription(int, int) { }
00172 virtual void onReceiveNewPrescription(int) { }
00174 virtual void onReceiveModifyPrescription(int) { }
00176 virtual void onReceiveEnterChat(const QString&) { }
00178 virtual void onReceiveLeaveChat(const QString&) { }
00180 virtual void onReceiveChatMessage(const QString&, const QString&) { }
00182 virtual void onReceiveChatUsers(const QStringList&) { }
00184 virtual void onReceiveEcgData(const QList<float>&) { }
00186 virtual void onReceiveAnalysisModel(const QString&) { }
00188 virtual void onReceiveScan(int, int, const QImage&) { }
00190 virtual void onReceiveRadio(int, int, int, const QImage&) { }
00191 };
00192
00193 #endif // HOOKMGR_H