nshead_message.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Licensed to the Apache Software Foundation (ASF) under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. The ASF licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing,
  12. // software distributed under the License is distributed on an
  13. // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. // KIND, either express or implied. See the License for the
  15. // specific language governing permissions and limitations
  16. // under the License.
  17. #ifndef BRPC_NSHEAD_MESSAGE_H
  18. #define BRPC_NSHEAD_MESSAGE_H
  19. #include <google/protobuf/message.h>
  20. #include "brpc/nshead.h" // nshead_t
  21. #include "butil/iobuf.h" // IOBuf
  22. #include "brpc/proto_base.pb.h"
  23. namespace brpc {
  24. // Representing a nshead request or response.
  25. class NsheadMessage : public ::google::protobuf::Message {
  26. public:
  27. nshead_t head;
  28. butil::IOBuf body;
  29. public:
  30. NsheadMessage();
  31. virtual ~NsheadMessage();
  32. NsheadMessage(const NsheadMessage& from);
  33. inline NsheadMessage& operator=(const NsheadMessage& from) {
  34. CopyFrom(from);
  35. return *this;
  36. }
  37. static const ::google::protobuf::Descriptor* descriptor();
  38. void Swap(NsheadMessage* other);
  39. // implements Message ----------------------------------------------
  40. NsheadMessage* New() const;
  41. void CopyFrom(const ::google::protobuf::Message& from);
  42. void MergeFrom(const ::google::protobuf::Message& from);
  43. void CopyFrom(const NsheadMessage& from);
  44. void MergeFrom(const NsheadMessage& from);
  45. void Clear();
  46. bool IsInitialized() const;
  47. int ByteSize() const;
  48. bool MergePartialFromCodedStream(
  49. ::google::protobuf::io::CodedInputStream* input);
  50. void SerializeWithCachedSizes(
  51. ::google::protobuf::io::CodedOutputStream* output) const;
  52. ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
  53. int GetCachedSize() const { return ByteSize(); }
  54. protected:
  55. ::google::protobuf::Metadata GetMetadata() const override;
  56. private:
  57. void SharedCtor();
  58. void SharedDtor();
  59. };
  60. } // namespace brpc
  61. #endif // BRPC_NSHEAD_MESSAGE_H