ipc_constants.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (c) 2010 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef SIMPLE_IPC_CONSTANTS_H_
  15. #define SIMPLE_IPC_CONSTANTS_H_
  16. namespace ipc {
  17. // No error is always 0. Positive values are reserved for the application
  18. // while negative errors are reserved for the IPC library.
  19. const size_t RcOK = 0;
  20. const size_t RcErrEncoderClose = static_cast<size_t>(-1);
  21. const size_t RcErrEncoderBuffer = static_cast<size_t>(-2);
  22. const size_t RcErrEncoderType = static_cast<size_t>(-3);
  23. const size_t RcErrTransportWrite = static_cast<size_t>(-4);
  24. const size_t RcErrTransportRead = static_cast<size_t>(-5);
  25. const size_t RcErrTransportConnect = static_cast<size_t>(-6);
  26. const size_t RcErrDecoderFormat = static_cast<size_t>(-7);
  27. const size_t RcErrDecoderArgs = static_cast<size_t>(-8);
  28. const size_t RcErrNewTransport = static_cast<size_t>(-9);
  29. const size_t RcErrBadMessageId = static_cast<size_t>(-10);
  30. // For the return on obj.OnMsg() when calling Channel::Receive(obj) there
  31. // are two critical values:
  32. // - OnMsgLoopNext: typically always returned by the server OnMsg()
  33. // so it goes to process the next message
  34. // - OnMsgAppErrorBase: typically always returned by the client OnMsg()
  35. // so Receive() exits.
  36. //
  37. const size_t OnMsgLoopNext = 0; // Loop again and read another message.
  38. const size_t OnMsgReady = 1; // Done receiving.
  39. const size_t OnMsgAppErrorBase = 2; // Application specific errors start here.
  40. // It is important to note that OnMsgLoopNext is 0 which is also RcOK. This
  41. // enables the following server (broker) side pattern
  42. //
  43. // size_t OnMsg(ChannelT* ch, param1, param2,...) {
  44. // ... operation here
  45. // return SendMsg(kRepyId, ch, result1, ..);
  46. // }
  47. // Reserved messages ids. User messages should start at kMessagePrivLastId and
  48. // above.
  49. const int kMessagePrivNewTransport = 1;
  50. const int kMessagePrivControl = 2;
  51. const int kMessagePrivLastId = 3;
  52. } // namespace ipc.
  53. #endif // SIMPLE_IPC_CONSTANTS_H_