CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkNetworkConnectorQXMLRPC.h
Go to the documentation of this file.
1 /*
2  * ctkNetworkConnectorQXMLRPC.h
3  * ctkEventBus
4  *
5  * Created by Daniele Giunchi on 11/04/10.
6  * Copyright 2009 B3C. All rights reserved.
7  *
8  * See Licence at: http://tiny.cc/QXJ4D
9  *
10  */
11 
12 #ifndef ctkNetworkConnectorQXMLRPC_H
13 #define ctkNetworkConnectorQXMLRPC_H
14 
15 // include list
16 #include "ctkNetworkConnector.h"
17 
18 // Foundation Library include list
19 #include <xmlrpc/client.h>
20 #include <xmlrpc/server.h>
21 
22 namespace ctkEventBus {
23 
31 class org_commontk_eventbus_EXPORT ctkNetworkConnectorQXMLRPC : public ctkNetworkConnector {
32  Q_OBJECT
33 
34 
35 public:
38 
41 
43  /*virtual*/ void createClient(const QString hostName, const unsigned int port);
44 
46  /*virtual*/ void createServer(const unsigned int port);
47 
49  /*virtual*/ void startListen();
50 
51  //retrieve an instance of the object
52  /*virtual*/ ctkNetworkConnector *clone();
53 
55  /*virtual*/ void initializeForEventBus();
56 
57 Q_SIGNALS:
59  void registerMethodsServer(mafRegisterMethodsMap registerMethodsList);
60 
61 public Q_SLOTS:
63  void registerServerMethod(mafRegisterMethodsMap registerMethodsList);
64 
66 
67  /*virtual*/ void send(const QString event_id, ctkEventArgumentsList *argList);
68 
69 private Q_SLOTS:
71  virtual void processReturnValue( int requestId, QVariant value );
72 
74  void processFault( int requestId, int errorCode, QString errorString );
75 
77  virtual void processRequest( int requestId, QString methodName, QList<xmlrpc::Variant> parameters );
78 
79 protected:
80  xmlrpc::Client *m_Client;
81  xmlrpc::Server *m_Server;
82 
83 private:
85  void xmlrpcSend(const QString &methodName, QList<xmlrpc::Variant> parameters);
86 
88  void stopServer();
89 
90  int m_RequestId;
91 };
92 
93 } //namespace ctkEventBus
94 
95 Q_DECLARE_METATYPE(xmlrpc::Variant);
96 
97 
98 #endif // ctkNetworkConnectorQXMLRPC_H
void registerMethodsServer(mafRegisterMethodsMap registerMethodsList)
signal for the registration of the functions with parameters
xmlrpc::Client * m_Client
xml-rpc client provided by qxmlrpc library
void startListen()
Start the server.
void registerServerMethod(mafRegisterMethodsMap registerMethodsList)
register methods on the server
ctkNetworkConnector * clone()
retrieve an instance of the object
void send(const QString event_id, ctkEventArgumentsList *argList)
Allow to send a network request.
void createClient(const QString hostName, const unsigned int port)
create the unique instance of the client.
~ctkNetworkConnectorQXMLRPC()
object destructor.
ctkNetworkConnectorQXMLRPC()
object constructor.
xmlrpc::Server * m_Server
xml-rpc server provided by qxmlrpc library
void createServer(const unsigned int port)
create the unique instance of the server.
void initializeForEventBus()
register all the signals and slots
Q_DECLARE_METATYPE(xmlrpc::Variant)
QMap< QString, QList< QVariant::Type > > mafRegisterMethodsMap
map which represent list of function to be registered in the server, with parameters