Gpio_server_g.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #ifndef __GPIO_SERVER_G_H
  2. #define __GPIO_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "Gpio_def_g.h"
  6. namespace Gpio {
  7. class GpioService_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. GpioService_ServerSessionBase()
  11. {
  12. /// override by user
  13. }
  14. virtual ~GpioService_ServerSessionBase()
  15. {
  16. /// override by user
  17. }
  18. virtual bool IsExclusive() { return false; }
  19. virtual bool IsSessionOverlap() { return true; }
  20. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
  21. {
  22. ErrorCodeEnum Error = Error_Succeed;
  23. switch (dwMessageID) {
  24. case GpioService_Method_Set:
  25. if (dwSignature == GpioService_MethodSignature_Set) {
  26. bOverlap = true;
  27. } else {
  28. Error = Error_MethodSignatureFailed;
  29. }
  30. break;
  31. case GpioService_Method_GetStatus:
  32. if (dwSignature == GpioService_MethodSignature_GetStatus) {
  33. bOverlap = true;
  34. } else {
  35. Error = Error_MethodSignatureFailed;
  36. }
  37. break;
  38. case GpioService_Method_QueryCurrSet:
  39. if (dwSignature == GpioService_MethodSignature_QueryCurrSet) {
  40. bOverlap = true;
  41. } else {
  42. Error = Error_MethodSignatureFailed;
  43. }
  44. break;
  45. default:
  46. Error = Error_MethodNotFound;
  47. break;
  48. }
  49. return Error;
  50. }
  51. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  52. {
  53. ErrorCodeEnum Error = Error_Succeed;
  54. switch (dwMessageID) {
  55. case GpioService_Method_Set:
  56. if (dwSignature != GpioService_MethodSignature_Set) {
  57. Error = Error_MethodSignatureFailed;
  58. }
  59. break;
  60. case GpioService_Method_GetStatus:
  61. if (dwSignature != GpioService_MethodSignature_GetStatus) {
  62. Error = Error_MethodSignatureFailed;
  63. }
  64. break;
  65. case GpioService_Method_QueryCurrSet:
  66. if (dwSignature != GpioService_MethodSignature_QueryCurrSet) {
  67. Error = Error_MethodSignatureFailed;
  68. }
  69. break;
  70. default:
  71. Error = Error_MethodNotFound;
  72. break;
  73. }
  74. return Error;
  75. }
  76. virtual void Handle_Set(SpOnewayCallContext<GpioService_Set_Info>::Pointer ctx)
  77. {
  78. /// override by user
  79. }
  80. virtual void Handle_GetStatus(SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
  81. {
  82. /// override by user
  83. }
  84. virtual void Handle_QueryCurrSet(SpReqAnsContext<GpioService_QueryCurrSet_Req, GpioService_QueryCurrSet_Ans>::Pointer ctx)
  85. {
  86. /// override by user
  87. }
  88. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  89. {
  90. CAutoBuffer Buf;
  91. DWORD dwMessageID;
  92. DWORD dwMessageSignature;
  93. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  94. if (Error == Error_Succeed) {
  95. #ifdef DEBUG
  96. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  97. #else
  98. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  99. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  100. return;
  101. }
  102. #endif
  103. switch (dwMessageID) {
  104. case GpioService_Method_Set:
  105. {
  106. SpOnewayCallContext<GpioService_Set_Info>::Pointer ctx;
  107. ctx.Attach(new SpOnewayCallContext<GpioService_Set_Info>());
  108. SpBuffer2Object(Buf, ctx->Info);
  109. pTransactionContext->GetLinkContext(ctx->link);
  110. EntityResource::setLink(ctx->link);
  111. Handle_Set(ctx);
  112. }
  113. break;
  114. case GpioService_Method_GetStatus:
  115. {
  116. SpReqAnsContext<GpioService_GetStatus_Req,GpioService_GetStatus_Ans>::Pointer ctx;
  117. ctx.Attach(new SpReqAnsContext<GpioService_GetStatus_Req,GpioService_GetStatus_Ans>(pTransactionContext));
  118. SpBuffer2Object(Buf, ctx->Req);
  119. pTransactionContext->GetLinkContext(ctx->link);
  120. EntityResource::setLink(ctx->link);
  121. Handle_GetStatus(ctx);
  122. }
  123. break;
  124. case GpioService_Method_QueryCurrSet:
  125. {
  126. SpReqAnsContext<GpioService_QueryCurrSet_Req,GpioService_QueryCurrSet_Ans>::Pointer ctx;
  127. ctx.Attach(new SpReqAnsContext<GpioService_QueryCurrSet_Req,GpioService_QueryCurrSet_Ans>(pTransactionContext));
  128. SpBuffer2Object(Buf, ctx->Req);
  129. pTransactionContext->GetLinkContext(ctx->link);
  130. EntityResource::setLink(ctx->link);
  131. Handle_QueryCurrSet(ctx);
  132. }
  133. break;
  134. default:
  135. assert(0);
  136. break;
  137. }
  138. } else {
  139. pTransactionContext->SendAnswer(Error);
  140. }
  141. }
  142. };
  143. ///////////////////////////
  144. } // namespace Gpio
  145. #endif // __GPIO_SERVER_G_H