1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef IVSERVICE_H
- #define IVSERVICE_H
- #include <memory>
- #include <QtCore/qglobal.h>
- #if defined(IVSERVICE_LIBRARY)
- # define IVSERVICE_EXPORT Q_DECL_EXPORT
- #else
- # define IVSERVICE_EXPORT Q_DECL_IMPORT
- #endif
- typedef void (*ServiceProc)(std::shared_ptr<char> pstr_request,const int nreqsize, std::shared_ptr<char> & pstr_response,int & nsize);
- //nRes 0 超时 1 正确返回
- typedef void (*ServiceAsycnProc)(std::shared_ptr<char> & pstr_response,int & nsize,int nRes);
- namespace iv {
- namespace service {
- class IVSERVICE_EXPORT Server
- {
- public:
- Server(const char * strservicename,ServiceProc xProc);
- ~Server();
- private:
- void * mpimpl;
- };
- class IVSERVICE_EXPORT Client
- {
- public:
- Client(const char * strservicename);
- ~Client();
- enum ServiceResRes
- {
- NO_RES = 1,
- HAVE_RES = 2
- };
- public:
- /**
- * @brief SendRequest 获得服务结果
- * @param pstr_request 请求的数据
- * @param pstr_response 返回的结果
- * @param timeout 超时时间
- * @return 如果成功,返回 HAVE_RES,如果超时,返回NO_RES
- */
- ServiceResRes SendRequest(std::shared_ptr<char> pstr_request,const int nreqsize,std::shared_ptr<char> & pstr_response,
- int & nressize,const int timeout = 100);
- /**
- * @brief AsyncSendRequest 异步请求服务
- * @param pstr_request 请求数据
- * @param nreqsize 请求数据大小
- * @param xProc 回调函数
- * @param timeout 超时时间,默认30秒
- * @return 0 Last Async Call Not Complete 1 Prepare Run Async
- */
- int AsyncSendRequest(std::shared_ptr<char> pstr_request,const int nreqsize,
- ServiceAsycnProc xProc,const int timeout = 30000);
- private:
- void * mpimpl;
- };
- }
- }
- #endif // IVSERVICE_H
|