ctkNetworkConnectorZeroMQ.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * ctkNetworkConnectorZeroMQ.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. #ifndef ctkNetworkConnectorZeroMQ_H
  12. #define ctkNetworkConnectorZeroMQ_H
  13. // include list
  14. #include "ctkNetworkConnector.h"
  15. namespace ctkEventBus {
  16. /**
  17. Class name: ctkNetworkConnectorZeroMQ
  18. This class is the implementation class for client/server objects that works over network
  19. with xml-rpc protocol. The server side part also create a new ID named REGISTER_SERVER_METHODS_XXX
  20. (where the XXX is the port on which run the server) that allows you to register your own remote
  21. callbacks. The library used is qxmlrpc.
  22. */
  23. class org_commontk_eventbus_EXPORT ctkNetworkConnectorZeroMQ : public ctkNetworkConnector {
  24. Q_OBJECT
  25. public:
  26. /// object constructor.
  27. ctkNetworkConnectorZeroMQ();
  28. /// object destructor.
  29. /*virtual*/ ~ctkNetworkConnectorZeroMQ();
  30. /// create the unique instance of the client.
  31. /*virtual*/ void createClient(const QString hostName, const unsigned int port);
  32. /// create the unique instance of the server.
  33. /*virtual*/ void createServer(const unsigned int port);
  34. /// Start the server.
  35. /*virtual*/ void startListen();
  36. //retrieve an instance of the object
  37. /*virtual*/ ctkNetworkConnector *clone();
  38. /// register all the signals and slots
  39. /*virtual*/ void initializeForEventBus();
  40. /// Allow to send a network request.
  41. /** Contains the conversion between maf datatypes and qxmlrpc datatype based both on QVariant. */
  42. /*virtual*/ void send(const QString event_id, ctkEventArgumentsList *argList);
  43. private Q_SLOTS:
  44. /// callback for the client which retrieve the variable from the server
  45. virtual void processReturnValue( int requestId, QVariant value );
  46. //// here goes slots which handle the connection
  47. protected:
  48. //here goes zeromq vars
  49. private:
  50. //here ges function for zeromq connection
  51. /// stop and destroy the server instance.
  52. void stopServer();
  53. };
  54. } //namespace ctkEventBus
  55. #endif // ctkNetworkConnectorZeroMQ_H