LivenessDetection_client_g.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #ifndef __LIVENESSDETECTION_CLIENT_G_H
  2. #define __LIVENESSDETECTION_CLIENT_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "LivenessDetection_def_g.h"
  6. namespace LivenessDetection {
  7. class LivenessDetectionService_ClientBase : public CClientSessionBase {
  8. public:
  9. explicit LivenessDetectionService_ClientBase(CEntityBase *pEntity) : m_pEntityBase(pEntity), m_bSysManaged(false) {}
  10. LivenessDetectionService_ClientBase* operator () (const linkContext &curLink)
  11. {
  12. m_context = curLink;
  13. return this;
  14. }
  15. protected:
  16. virtual ~LivenessDetectionService_ClientBase()
  17. {
  18. /// override by user
  19. }
  20. public:
  21. void OnConnectSucceed()
  22. {
  23. bSessionClosed = false;
  24. }
  25. void OnClose(ErrorCodeEnum)
  26. {
  27. Dbg("session closed.");
  28. bSessionClosed = true;
  29. }
  30. bool QuerySessionClosed()
  31. {
  32. return bSessionClosed;
  33. }
  34. ErrorCodeEnum Connect(CSmartPointer<IAsynWaitSp> &spAsyncWait)
  35. {
  36. CSmartPointer<IEntityFunction> pFunc = m_pEntityBase->GetFunction();
  37. ErrorCodeEnum Error = pFunc->ConnectRemoteEntity(this, "LivenessDetection", "LivenessDetectionService", spAsyncWait);
  38. if (Error == Error_Succeed) {
  39. m_bSysManaged = true;
  40. bSessionClosed = false;
  41. }
  42. return Error;
  43. }
  44. ErrorCodeEnum Connect()
  45. {
  46. CSmartPointer<IAsynWaitSp> spAsyncWait;
  47. ErrorCodeEnum Error = Connect(spAsyncWait);
  48. if (Error == Error_Succeed) {
  49. Error = spAsyncWait->WaitAnswer();
  50. }
  51. return Error;
  52. }
  53. ErrorCodeEnum StartLivenessDetection(LivenessDetectionService_StartLivenessDetection_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
  54. {
  55. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  56. CAutoBuffer Buf = SpObject2Buffer(Req);
  57. if (m_context.checkEmpty())
  58. {
  59. m_context.AutoGenerate();
  60. DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
  61. m_context = m_context.upgradeLink();
  62. }
  63. auto ret = pFunc->AsyncRequest(LivenessDetectionService_Method_StartLivenessDetection, LivenessDetectionService_MethodSignature_StartLivenessDetection, Buf, spAsyncWait, m_context, dwTimeout);
  64. m_context.clear();
  65. return ret;
  66. }
  67. ErrorCodeEnum StartLivenessDetection(LivenessDetectionService_StartLivenessDetection_Req &Req, LivenessDetectionService_StartLivenessDetection_Ans &Ans, DWORD dwTimeout)
  68. {
  69. CSmartPointer<IAsynWaitSp> spAsyncWait;
  70. ErrorCodeEnum Error = StartLivenessDetection(Req, spAsyncWait, dwTimeout);
  71. if (Error == Error_Succeed) {
  72. bool bEnd = false;
  73. Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
  74. LOG_ASSERT(Error || bEnd);
  75. }
  76. return Error;
  77. }
  78. ErrorCodeEnum StartLivenessDetection(LivenessDetectionService_StartLivenessDetection_Req &Req, LivenessDetectionService_StartLivenessDetection_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError, CSimpleString &str)
  79. {
  80. CSmartPointer<IAsynWaitSp> spAsyncWait;
  81. ErrorCodeEnum Error = StartLivenessDetection(Req, spAsyncWait, dwTimeout);
  82. if (Error == Error_Succeed) {
  83. bool bEnd = false;
  84. Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
  85. LOG_ASSERT(Error || bEnd);
  86. }
  87. return Error;
  88. }
  89. ErrorCodeEnum StartLivenessDetection(LivenessDetectionService_StartLivenessDetection_Req &Req, LivenessDetectionService_StartLivenessDetection_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
  90. {
  91. CSmartPointer<IAsynWaitSp> spAsyncWait;
  92. ErrorCodeEnum Error = StartLivenessDetection(Req, spAsyncWait, dwTimeout);
  93. if (Error == Error_Succeed) {
  94. bool bEnd = false;
  95. CSimpleString str;
  96. Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
  97. LOG_ASSERT(Error || bEnd);
  98. }
  99. return Error;
  100. }
  101. ErrorCodeEnum StopLivenessDetection(LivenessDetectionService_StopLivenessDetection_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
  102. {
  103. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  104. CAutoBuffer Buf = SpObject2Buffer(Req);
  105. if (m_context.checkEmpty())
  106. {
  107. m_context.AutoGenerate();
  108. DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
  109. m_context = m_context.upgradeLink();
  110. }
  111. auto ret = pFunc->AsyncRequest(LivenessDetectionService_Method_StopLivenessDetection, LivenessDetectionService_MethodSignature_StopLivenessDetection, Buf, spAsyncWait, m_context, dwTimeout);
  112. m_context.clear();
  113. return ret;
  114. }
  115. ErrorCodeEnum StopLivenessDetection(LivenessDetectionService_StopLivenessDetection_Req &Req, LivenessDetectionService_StopLivenessDetection_Ans &Ans, DWORD dwTimeout)
  116. {
  117. CSmartPointer<IAsynWaitSp> spAsyncWait;
  118. ErrorCodeEnum Error = StopLivenessDetection(Req, spAsyncWait, dwTimeout);
  119. if (Error == Error_Succeed) {
  120. bool bEnd = false;
  121. Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
  122. LOG_ASSERT(Error || bEnd);
  123. }
  124. return Error;
  125. }
  126. ErrorCodeEnum StopLivenessDetection(LivenessDetectionService_StopLivenessDetection_Req &Req, LivenessDetectionService_StopLivenessDetection_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError, CSimpleString &str)
  127. {
  128. CSmartPointer<IAsynWaitSp> spAsyncWait;
  129. ErrorCodeEnum Error = StopLivenessDetection(Req, spAsyncWait, dwTimeout);
  130. if (Error == Error_Succeed) {
  131. bool bEnd = false;
  132. Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
  133. LOG_ASSERT(Error || bEnd);
  134. }
  135. return Error;
  136. }
  137. ErrorCodeEnum StopLivenessDetection(LivenessDetectionService_StopLivenessDetection_Req &Req, LivenessDetectionService_StopLivenessDetection_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
  138. {
  139. CSmartPointer<IAsynWaitSp> spAsyncWait;
  140. ErrorCodeEnum Error = StopLivenessDetection(Req, spAsyncWait, dwTimeout);
  141. if (Error == Error_Succeed) {
  142. bool bEnd = false;
  143. CSimpleString str;
  144. Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, str, dwTimeout);
  145. LOG_ASSERT(Error || bEnd);
  146. }
  147. return Error;
  148. }
  149. bool SafeDelete()
  150. {
  151. if (!m_bSysManaged) {
  152. delete this;
  153. }
  154. return m_bSysManaged;
  155. }
  156. protected:
  157. bool m_bSysManaged;
  158. CEntityBase *m_pEntityBase;
  159. linkContext m_context;
  160. bool bSessionClosed;
  161. };
  162. ///////////////////////////
  163. } // namespace LivenessDetection
  164. #endif // __LIVENESSDETECTION_CLIENT_G_H