ivservice.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef IVSERVICE_H
  2. #define IVSERVICE_H
  3. #include <memory>
  4. #include <QtCore/qglobal.h>
  5. #if defined(IVSERVICE_LIBRARY)
  6. # define IVSERVICE_EXPORT Q_DECL_EXPORT
  7. #else
  8. # define IVSERVICE_EXPORT Q_DECL_IMPORT
  9. #endif
  10. typedef void (*ServiceProc)(std::shared_ptr<char> pstr_request,const int nreqsize, std::shared_ptr<char> & pstr_response,int & nsize);
  11. namespace iv {
  12. namespace service {
  13. class IVSERVICE_EXPORT Server
  14. {
  15. public:
  16. Server(const char * strservicename,ServiceProc xProc);
  17. ~Server();
  18. private:
  19. void * mpimpl;
  20. };
  21. class IVSERVICE_EXPORT Client
  22. {
  23. public:
  24. Client(const char * strservicename);
  25. ~Client();
  26. enum ServiceResRes
  27. {
  28. NO_RES = 1,
  29. HAVE_RES = 2
  30. };
  31. public:
  32. /**
  33. * @brief SendRequest 获得服务结果
  34. * @param pstr_request 请求的数据
  35. * @param pstr_response 返回的结果
  36. * @param timeout 超时时间
  37. * @return 如果成功,返回 HAVE_RES,如果超时,返回NO_RES
  38. */
  39. ServiceResRes SendRequest(std::shared_ptr<char> pstr_request,const int nreqsize,std::shared_ptr<char> & pstr_response,
  40. int & nressize,const int timeout = 100);
  41. private:
  42. void * mpimpl;
  43. };
  44. }
  45. }
  46. #endif // IVSERVICE_H