grpc实例(1)

官方文档](http://doc.oschina.net/grpc?t=57966)

官网

https://github.com/grpc/grpc

下载源码

以官方示例route_guide为例

syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.routeguide";
option java_outer_classname = "RouteGuideProto";
option objc_class_prefix = "RTG";

package routeguide;

// Interface exported by the server.定义一个服务
service RouteGuide {

  // 一个 简单 RPC , 客户端使用存根发送请求到服务器并等待响应返回,就像平常的函数调用一样。
  rpc GetFeature(Point) returns (Feature) {}

  // 一个 服务器端流式 RPC , 客户端发送请求到服务器,拿到一个流去读取返回的消息序列。 客户端读取返回的	流,直到里面没有任何消息。从例子中可以看出,通过在响应类型前插入 stream 关键字,可以指定一个服务器     端的流方法
  rpc ListFeatures(Rectangle) returns (stream Feature) {}

  //一个 客户端流式 RPC , 客户端写入一个消息序列并将其发送到服务器,同样也是使用流。一旦客户端完成写入消息,它等待服务器完成读取返回它的响应。通过在 请求 类型前指定 stream 关键字来指定一个客户端的流方法
  rpc RecordRoute(stream Point) returns (RouteSummary) {}

  // 一个 双向流式 RPC 是双方使用读写流去发送一个消息序列。两个流独立操作,因此客户端和服务器可以以任意喜欢的顺序读写:比如, 服务器可以在写入响应前等待接收所有的客户端消息,或者可以交替的读取和写入消息,或者其他读写的组合。 每个流中的消息顺序被预留。你可以通过在请求和响应前加 stream 关键字去制定方法的类型
  rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
}

//下面是消息类型定义以及在服务方法中使用的响应类型

// Points are represented as latitude-longitude pairs in the E7 representation
// (degrees multiplied by 10**7 and rounded to the nearest integer).
// Latitudes should be in the range +/- 90 degrees and longitude should be in
// the range +/- 180 degrees (inclusive).
message Point {
  int32 latitude = 1;
  int32 longitude = 2;
}

// A latitude-longitude rectangle, represented as two diagonally opposite
// points "lo" and "hi".
message Rectangle {
  // One corner of the rectangle.
  Point lo = 1;

  // The other corner of the rectangle.
  Point hi = 2;
}

// A feature names something at a given point.
//
// If a feature could not be named, the name is empty.
message Feature {
  // The name of the feature.
  string name = 1;

  // The point where the feature is detected.
  Point location = 2;
}

// A RouteNote is a message sent while at a given point.
message RouteNote {
  // The location from which the message is sent.
  Point location = 1;

  // The message to be sent.
  string message = 2;
}

// A RouteSummary is received in response to a RecordRoute rpc.
//
// It contains the number of individual points received, the number of
// detected features, and the total distance covered as the cumulative sum of
// the distance between each point.
message RouteSummary {
  // The number of points received.
  int32 point_count = 1;

  // The number of known features passed while traversing the route.
  int32 feature_count = 2;

  // The distance covered in metres.
  int32 distance = 3;

  // The duration of the traversal in seconds.
  int32 elapsed_time = 4;
}

C++

生成代码

安装protoc grpc

  • sudo apt install protobuf-compiler
  • apt install protobuf-compiler-grpc

生成代码:

protoc -I . --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` route_guide.proto

protoc -I . --cpp_out=. route_guide.proto

生成如下四个文件:

  • route_guide.pb.h, 声明生成的消息类的头文件
  • route_guide.pb.cc, 包含消息类的实现
  • route_guide.grpc.pb.h, 声明你生成的服务类的头文件
  • route_guide.grpc.pb.cc, 包含服务类的实现
route_guide.pb.h
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: route_guide.proto

#ifndef PROTOBUF_route_5fguide_2eproto__INCLUDED
#define PROTOBUF_route_5fguide_2eproto__INCLUDED

#include 

#include 

#if GOOGLE_PROTOBUF_VERSION < 3000000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please update
#error your headers.
#endif
#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.
#endif

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
// @@protoc_insertion_point(includes)

namespace routeguide {

// Internal implementation detail -- do not call these.
void protobuf_AddDesc_route_5fguide_2eproto();
void protobuf_AssignDesc_route_5fguide_2eproto();
void protobuf_ShutdownFile_route_5fguide_2eproto();

class Feature;
class Point;
class Rectangle;
class RouteNote;
class RouteSummary;

// ===================================================================

class Point : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:routeguide.Point) */ {
 public:
  Point();
  virtual ~Point();

  Point(const Point& from);

  inline Point& operator=(const Point& from) {
    CopyFrom(from);
    return *this;
  }

  static const ::google::protobuf::Descriptor* descriptor();
  static const Point& default_instance();

  void Swap(Point* other);

  // implements Message ----------------------------------------------

  inline Point* New() const { return New(NULL); }

  Point* New(::google::protobuf::Arena* arena) const;
  void CopyFrom(const ::google::protobuf::Message& from);
  void MergeFrom(const ::google::protobuf::Message& from);
  void CopyFrom(const Point& from);
  void MergeFrom(const Point& from);
  void Clear();
  bool IsInitialized() const;

  int ByteSize() const;
  bool MergePartialFromCodedStream(
      ::google::protobuf::io::CodedInputStream* input);
  void SerializeWithCachedSizes(
      ::google::protobuf::io::CodedOutputStream* output) const;
  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
      bool deterministic, ::google::protobuf::uint8* output) const;
  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
    return InternalSerializeWithCachedSizesToArray(false, output);
  }
  int GetCachedSize() const { return _cached_size_; }
  private:
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize(int size) const;
  void InternalSwap(Point* other);
  private:
  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
    return _internal_metadata_.arena();
  }
  inline void* MaybeArenaPtr() const {
    return _internal_metadata_.raw_arena_ptr();
  }
  public:

  ::google::protobuf::Metadata GetMetadata() const;

  // nested types ----------------------------------------------------

  // accessors -------------------------------------------------------

  // optional int32 latitude = 1;
  void clear_latitude();
  static const int kLatitudeFieldNumber = 1;
  ::google::protobuf::int32 latitude() const;
  void set_latitude(::google::protobuf::int32 value);

  // optional int32 longitude = 2;
  void clear_longitude();
  static const int kLongitudeFieldNumber = 2;
  ::google::protobuf::int32 longitude() const;
  void set_longitude(::google::protobuf::int32 value);

  // @@protoc_insertion_point(class_scope:routeguide.Point)
 private:

  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  bool _is_default_instance_;
  ::google::protobuf::int32 latitude_;
  ::google::protobuf::int32 longitude_;
  mutable int _cached_size_;
  friend void  protobuf_AddDesc_route_5fguide_2eproto();
  friend void protobuf_AssignDesc_route_5fguide_2eproto();
  friend void protobuf_ShutdownFile_route_5fguide_2eproto();

  void InitAsDefaultInstance();
  static Point* default_instance_;
};
// -------------------------------------------------------------------

class Rectangle : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:routeguide.Rectangle) */ {
 public:
  Rectangle();
  virtual ~Rectangle();

  Rectangle(const Rectangle& from);

  inline Rectangle& operator=(const Rectangle& from) {
    CopyFrom(from);
    return *this;
  }

  static const ::google::protobuf::Descriptor* descriptor();
  static const Rectangle& default_instance();

  void Swap(Rectangle* other);

  // implements Message ----------------------------------------------

  inline Rectangle* New() const { return New(NULL); }

  Rectangle* New(::google::protobuf::Arena* arena) const;
  void CopyFrom(const ::google::protobuf::Message& from);
  void MergeFrom(const ::google::protobuf::Message& from);
  void CopyFrom(const Rectangle& from);
  void MergeFrom(const Rectangle& from);
  void Clear();
  bool IsInitialized() const;

  int ByteSize() const;
  bool MergePartialFromCodedStream(
      ::google::protobuf::io::CodedInputStream* input);
  void SerializeWithCachedSizes(
      ::google::protobuf::io::CodedOutputStream* output) const;
  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
      bool deterministic, ::google::protobuf::uint8* output) const;
  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
    return InternalSerializeWithCachedSizesToArray(false, output);
  }
  int GetCachedSize() const { return _cached_size_; }
  private:
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize(int size) const;
  void InternalSwap(Rectangle* other);
  private:
  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
    return _internal_metadata_.arena();
  }
  inline void* MaybeArenaPtr() const {
    return _internal_metadata_.raw_arena_ptr();
  }
  public:

  ::google::protobuf::Metadata GetMetadata() const;

  // nested types ----------------------------------------------------

  // accessors -------------------------------------------------------

  // optional .routeguide.Point lo = 1;
  bool has_lo() const;
  void clear_lo();
  static const int kLoFieldNumber = 1;
  const ::routeguide::Point& lo() const;
  ::routeguide::Point* mutable_lo();
  ::routeguide::Point* release_lo();
  void set_allocated_lo(::routeguide::Point* lo);

  // optional .routeguide.Point hi = 2;
  bool has_hi() const;
  void clear_hi();
  static const int kHiFieldNumber = 2;
  const ::routeguide::Point& hi() const;
  ::routeguide::Point* mutable_hi();
  ::routeguide::Point* release_hi();
  void set_allocated_hi(::routeguide::Point* hi);

  // @@protoc_insertion_point(class_scope:routeguide.Rectangle)
 private:

  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  bool _is_default_instance_;
  ::routeguide::Point* lo_;
  ::routeguide::Point* hi_;
  mutable int _cached_size_;
  friend void  protobuf_AddDesc_route_5fguide_2eproto();
  friend void protobuf_AssignDesc_route_5fguide_2eproto();
  friend void protobuf_ShutdownFile_route_5fguide_2eproto();

  void InitAsDefaultInstance();
  static Rectangle* default_instance_;
};
// -------------------------------------------------------------------

class Feature : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:routeguide.Feature) */ {
 public:
  Feature();
  virtual ~Feature();

  Feature(const Feature& from);

  inline Feature& operator=(const Feature& from) {
    CopyFrom(from);
    return *this;
  }

  static const ::google::protobuf::Descriptor* descriptor();
  static const Feature& default_instance();

  void Swap(Feature* other);

  // implements Message ----------------------------------------------

  inline Feature* New() const { return New(NULL); }

  Feature* New(::google::protobuf::Arena* arena) const;
  void CopyFrom(const ::google::protobuf::Message& from);
  void MergeFrom(const ::google::protobuf::Message& from);
  void CopyFrom(const Feature& from);
  void MergeFrom(const Feature& from);
  void Clear();
  bool IsInitialized() const;

  int ByteSize() const;
  bool MergePartialFromCodedStream(
      ::google::protobuf::io::CodedInputStream* input);
  void SerializeWithCachedSizes(
      ::google::protobuf::io::CodedOutputStream* output) const;
  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
      bool deterministic, ::google::protobuf::uint8* output) const;
  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
    return InternalSerializeWithCachedSizesToArray(false, output);
  }
  int GetCachedSize() const { return _cached_size_; }
  private:
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize(int size) const;
  void InternalSwap(Feature* other);
  private:
  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
    return _internal_metadata_.arena();
  }
  inline void* MaybeArenaPtr() const {
    return _internal_metadata_.raw_arena_ptr();
  }
  public:

  ::google::protobuf::Metadata GetMetadata() const;

  // nested types ----------------------------------------------------

  // accessors -------------------------------------------------------

  // optional string name = 1;
  void clear_name();
  static const int kNameFieldNumber = 1;
  const ::std::string& name() const;
  void set_name(const ::std::string& value);
  void set_name(const char* value);
  void set_name(const char* value, size_t size);
  ::std::string* mutable_name();
  ::std::string* release_name();
  void set_allocated_name(::std::string* name);

  // optional .routeguide.Point location = 2;
  bool has_location() const;
  void clear_location();
  static const int kLocationFieldNumber = 2;
  const ::routeguide::Point& location() const;
  ::routeguide::Point* mutable_location();
  ::routeguide::Point* release_location();
  void set_allocated_location(::routeguide::Point* location);

  // @@protoc_insertion_point(class_scope:routeguide.Feature)
 private:

  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  bool _is_default_instance_;
  ::google::protobuf::internal::ArenaStringPtr name_;
  ::routeguide::Point* location_;
  mutable int _cached_size_;
  friend void  protobuf_AddDesc_route_5fguide_2eproto();
  friend void protobuf_AssignDesc_route_5fguide_2eproto();
  friend void protobuf_ShutdownFile_route_5fguide_2eproto();

  void InitAsDefaultInstance();
  static Feature* default_instance_;
};
// -------------------------------------------------------------------

class RouteNote : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:routeguide.RouteNote) */ {
 public:
  RouteNote();
  virtual ~RouteNote();

  RouteNote(const RouteNote& from);

  inline RouteNote& operator=(const RouteNote& from) {
    CopyFrom(from);
    return *this;
  }

  static const ::google::protobuf::Descriptor* descriptor();
  static const RouteNote& default_instance();

  void Swap(RouteNote* other);

  // implements Message ----------------------------------------------

  inline RouteNote* New() const { return New(NULL); }

  RouteNote* New(::google::protobuf::Arena* arena) const;
  void CopyFrom(const ::google::protobuf::Message& from);
  void MergeFrom(const ::google::protobuf::Message& from);
  void CopyFrom(const RouteNote& from);
  void MergeFrom(const RouteNote& from);
  void Clear();
  bool IsInitialized() const;

  int ByteSize() const;
  bool MergePartialFromCodedStream(
      ::google::protobuf::io::CodedInputStream* input);
  void SerializeWithCachedSizes(
      ::google::protobuf::io::CodedOutputStream* output) const;
  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
      bool deterministic, ::google::protobuf::uint8* output) const;
  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
    return InternalSerializeWithCachedSizesToArray(false, output);
  }
  int GetCachedSize() const { return _cached_size_; }
  private:
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize(int size) const;
  void InternalSwap(RouteNote* other);
  private:
  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
    return _internal_metadata_.arena();
  }
  inline void* MaybeArenaPtr() const {
    return _internal_metadata_.raw_arena_ptr();
  }
  public:

  ::google::protobuf::Metadata GetMetadata() const;

  // nested types ----------------------------------------------------

  // accessors -------------------------------------------------------

  // optional .routeguide.Point location = 1;
  bool has_location() const;
  void clear_location();
  static const int kLocationFieldNumber = 1;
  const ::routeguide::Point& location() const;
  ::routeguide::Point* mutable_location();
  ::routeguide::Point* release_location();
  void set_allocated_location(::routeguide::Point* location);

  // optional string message = 2;
  void clear_message();
  static const int kMessageFieldNumber = 2;
  const ::std::string& message() const;
  void set_message(const ::std::string& value);
  void set_message(const char* value);
  void set_message(const char* value, size_t size);
  ::std::string* mutable_message();
  ::std::string* release_message();
  void set_allocated_message(::std::string* message);

  // @@protoc_insertion_point(class_scope:routeguide.RouteNote)
 private:

  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  bool _is_default_instance_;
  ::routeguide::Point* location_;
  ::google::protobuf::internal::ArenaStringPtr message_;
  mutable int _cached_size_;
  friend void  protobuf_AddDesc_route_5fguide_2eproto();
  friend void protobuf_AssignDesc_route_5fguide_2eproto();
  friend void protobuf_ShutdownFile_route_5fguide_2eproto();

  void InitAsDefaultInstance();
  static RouteNote* default_instance_;
};
// -------------------------------------------------------------------

class RouteSummary : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:routeguide.RouteSummary) */ {
 public:
  RouteSummary();
  virtual ~RouteSummary();

  RouteSummary(const RouteSummary& from);

  inline RouteSummary& operator=(const RouteSummary& from) {
    CopyFrom(from);
    return *this;
  }

  static const ::google::protobuf::Descriptor* descriptor();
  static const RouteSummary& default_instance();

  void Swap(RouteSummary* other);

  // implements Message ----------------------------------------------

  inline RouteSummary* New() const { return New(NULL); }

  RouteSummary* New(::google::protobuf::Arena* arena) const;
  void CopyFrom(const ::google::protobuf::Message& from);
  void MergeFrom(const ::google::protobuf::Message& from);
  void CopyFrom(const RouteSummary& from);
  void MergeFrom(const RouteSummary& from);
  void Clear();
  bool IsInitialized() const;

  int ByteSize() const;
  bool MergePartialFromCodedStream(
      ::google::protobuf::io::CodedInputStream* input);
  void SerializeWithCachedSizes(
      ::google::protobuf::io::CodedOutputStream* output) const;
  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
      bool deterministic, ::google::protobuf::uint8* output) const;
  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
    return InternalSerializeWithCachedSizesToArray(false, output);
  }
  int GetCachedSize() const { return _cached_size_; }
  private:
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize(int size) const;
  void InternalSwap(RouteSummary* other);
  private:
  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
    return _internal_metadata_.arena();
  }
  inline void* MaybeArenaPtr() const {
    return _internal_metadata_.raw_arena_ptr();
  }
  public:

  ::google::protobuf::Metadata GetMetadata() const;

  // nested types ----------------------------------------------------

  // accessors -------------------------------------------------------

  // optional int32 point_count = 1;
  void clear_point_count();
  static const int kPointCountFieldNumber = 1;
  ::google::protobuf::int32 point_count() const;
  void set_point_count(::google::protobuf::int32 value);

  // optional int32 feature_count = 2;
  void clear_feature_count();
  static const int kFeatureCountFieldNumber = 2;
  ::google::protobuf::int32 feature_count() const;
  void set_feature_count(::google::protobuf::int32 value);

  // optional int32 distance = 3;
  void clear_distance();
  static const int kDistanceFieldNumber = 3;
  ::google::protobuf::int32 distance() const;
  void set_distance(::google::protobuf::int32 value);

  // optional int32 elapsed_time = 4;
  void clear_elapsed_time();
  static const int kElapsedTimeFieldNumber = 4;
  ::google::protobuf::int32 elapsed_time() const;
  void set_elapsed_time(::google::protobuf::int32 value);

  // @@protoc_insertion_point(class_scope:routeguide.RouteSummary)
 private:

  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  bool _is_default_instance_;
  ::google::protobuf::int32 point_count_;
  ::google::protobuf::int32 feature_count_;
  ::google::protobuf::int32 distance_;
  ::google::protobuf::int32 elapsed_time_;
  mutable int _cached_size_;
  friend void  protobuf_AddDesc_route_5fguide_2eproto();
  friend void protobuf_AssignDesc_route_5fguide_2eproto();
  friend void protobuf_ShutdownFile_route_5fguide_2eproto();

  void InitAsDefaultInstance();
  static RouteSummary* default_instance_;
};
// ===================================================================


// ===================================================================

#if !PROTOBUF_INLINE_NOT_IN_HEADERS
// Point

// optional int32 latitude = 1;
inline void Point::clear_latitude() {
  latitude_ = 0;
}
inline ::google::protobuf::int32 Point::latitude() const {
  // @@protoc_insertion_point(field_get:routeguide.Point.latitude)
  return latitude_;
}
inline void Point::set_latitude(::google::protobuf::int32 value) {
  
  latitude_ = value;
  // @@protoc_insertion_point(field_set:routeguide.Point.latitude)
}

// optional int32 longitude = 2;
inline void Point::clear_longitude() {
  longitude_ = 0;
}
inline ::google::protobuf::int32 Point::longitude() const {
  // @@protoc_insertion_point(field_get:routeguide.Point.longitude)
  return longitude_;
}
inline void Point::set_longitude(::google::protobuf::int32 value) {
  
  longitude_ = value;
  // @@protoc_insertion_point(field_set:routeguide.Point.longitude)
}

// -------------------------------------------------------------------

// Rectangle

// optional .routeguide.Point lo = 1;
inline bool Rectangle::has_lo() const {
  return !_is_default_instance_ && lo_ != NULL;
}
inline void Rectangle::clear_lo() {
  if (GetArenaNoVirtual() == NULL && lo_ != NULL) delete lo_;
  lo_ = NULL;
}
inline const ::routeguide::Point& Rectangle::lo() const {
  // @@protoc_insertion_point(field_get:routeguide.Rectangle.lo)
  return lo_ != NULL ? *lo_ : *default_instance_->lo_;
}
inline ::routeguide::Point* Rectangle::mutable_lo() {
  
  if (lo_ == NULL) {
    lo_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.Rectangle.lo)
  return lo_;
}
inline ::routeguide::Point* Rectangle::release_lo() {
  // @@protoc_insertion_point(field_release:routeguide.Rectangle.lo)
  
  ::routeguide::Point* temp = lo_;
  lo_ = NULL;
  return temp;
}
inline void Rectangle::set_allocated_lo(::routeguide::Point* lo) {
  delete lo_;
  lo_ = lo;
  if (lo) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.Rectangle.lo)
}

// optional .routeguide.Point hi = 2;
inline bool Rectangle::has_hi() const {
  return !_is_default_instance_ && hi_ != NULL;
}
inline void Rectangle::clear_hi() {
  if (GetArenaNoVirtual() == NULL && hi_ != NULL) delete hi_;
  hi_ = NULL;
}
inline const ::routeguide::Point& Rectangle::hi() const {
  // @@protoc_insertion_point(field_get:routeguide.Rectangle.hi)
  return hi_ != NULL ? *hi_ : *default_instance_->hi_;
}
inline ::routeguide::Point* Rectangle::mutable_hi() {
  
  if (hi_ == NULL) {
    hi_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.Rectangle.hi)
  return hi_;
}
inline ::routeguide::Point* Rectangle::release_hi() {
  // @@protoc_insertion_point(field_release:routeguide.Rectangle.hi)
  
  ::routeguide::Point* temp = hi_;
  hi_ = NULL;
  return temp;
}
inline void Rectangle::set_allocated_hi(::routeguide::Point* hi) {
  delete hi_;
  hi_ = hi;
  if (hi) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.Rectangle.hi)
}

// -------------------------------------------------------------------

// Feature

// optional string name = 1;
inline void Feature::clear_name() {
  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& Feature::name() const {
  // @@protoc_insertion_point(field_get:routeguide.Feature.name)
  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Feature::set_name(const ::std::string& value) {
  
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
  // @@protoc_insertion_point(field_set:routeguide.Feature.name)
}
inline void Feature::set_name(const char* value) {
  
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
  // @@protoc_insertion_point(field_set_char:routeguide.Feature.name)
}
inline void Feature::set_name(const char* value, size_t size) {
  
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
      ::std::string(reinterpret_cast(value), size));
  // @@protoc_insertion_point(field_set_pointer:routeguide.Feature.name)
}
inline ::std::string* Feature::mutable_name() {
  
  // @@protoc_insertion_point(field_mutable:routeguide.Feature.name)
  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* Feature::release_name() {
  // @@protoc_insertion_point(field_release:routeguide.Feature.name)
  
  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void Feature::set_allocated_name(::std::string* name) {
  if (name != NULL) {
    
  } else {
    
  }
  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
  // @@protoc_insertion_point(field_set_allocated:routeguide.Feature.name)
}

// optional .routeguide.Point location = 2;
inline bool Feature::has_location() const {
  return !_is_default_instance_ && location_ != NULL;
}
inline void Feature::clear_location() {
  if (GetArenaNoVirtual() == NULL && location_ != NULL) delete location_;
  location_ = NULL;
}
inline const ::routeguide::Point& Feature::location() const {
  // @@protoc_insertion_point(field_get:routeguide.Feature.location)
  return location_ != NULL ? *location_ : *default_instance_->location_;
}
inline ::routeguide::Point* Feature::mutable_location() {
  
  if (location_ == NULL) {
    location_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.Feature.location)
  return location_;
}
inline ::routeguide::Point* Feature::release_location() {
  // @@protoc_insertion_point(field_release:routeguide.Feature.location)
  
  ::routeguide::Point* temp = location_;
  location_ = NULL;
  return temp;
}
inline void Feature::set_allocated_location(::routeguide::Point* location) {
  delete location_;
  location_ = location;
  if (location) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.Feature.location)
}

// -------------------------------------------------------------------

// RouteNote

// optional .routeguide.Point location = 1;
inline bool RouteNote::has_location() const {
  return !_is_default_instance_ && location_ != NULL;
}
inline void RouteNote::clear_location() {
  if (GetArenaNoVirtual() == NULL && location_ != NULL) delete location_;
  location_ = NULL;
}
inline const ::routeguide::Point& RouteNote::location() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteNote.location)
  return location_ != NULL ? *location_ : *default_instance_->location_;
}
inline ::routeguide::Point* RouteNote::mutable_location() {
  
  if (location_ == NULL) {
    location_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.RouteNote.location)
  return location_;
}
inline ::routeguide::Point* RouteNote::release_location() {
  // @@protoc_insertion_point(field_release:routeguide.RouteNote.location)
  
  ::routeguide::Point* temp = location_;
  location_ = NULL;
  return temp;
}
inline void RouteNote::set_allocated_location(::routeguide::Point* location) {
  delete location_;
  location_ = location;
  if (location) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.RouteNote.location)
}

// optional string message = 2;
inline void RouteNote::clear_message() {
  message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& RouteNote::message() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteNote.message)
  return message_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void RouteNote::set_message(const ::std::string& value) {
  
  message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
  // @@protoc_insertion_point(field_set:routeguide.RouteNote.message)
}
inline void RouteNote::set_message(const char* value) {
  
  message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
  // @@protoc_insertion_point(field_set_char:routeguide.RouteNote.message)
}
inline void RouteNote::set_message(const char* value, size_t size) {
  
  message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
      ::std::string(reinterpret_cast(value), size));
  // @@protoc_insertion_point(field_set_pointer:routeguide.RouteNote.message)
}
inline ::std::string* RouteNote::mutable_message() {
  
  // @@protoc_insertion_point(field_mutable:routeguide.RouteNote.message)
  return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* RouteNote::release_message() {
  // @@protoc_insertion_point(field_release:routeguide.RouteNote.message)
  
  return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void RouteNote::set_allocated_message(::std::string* message) {
  if (message != NULL) {
    
  } else {
    
  }
  message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message);
  // @@protoc_insertion_point(field_set_allocated:routeguide.RouteNote.message)
}

// -------------------------------------------------------------------

// RouteSummary

// optional int32 point_count = 1;
inline void RouteSummary::clear_point_count() {
  point_count_ = 0;
}
inline ::google::protobuf::int32 RouteSummary::point_count() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.point_count)
  return point_count_;
}
inline void RouteSummary::set_point_count(::google::protobuf::int32 value) {
  
  point_count_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.point_count)
}

// optional int32 feature_count = 2;
inline void RouteSummary::clear_feature_count() {
  feature_count_ = 0;
}
inline ::google::protobuf::int32 RouteSummary::feature_count() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.feature_count)
  return feature_count_;
}
inline void RouteSummary::set_feature_count(::google::protobuf::int32 value) {
  
  feature_count_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.feature_count)
}

// optional int32 distance = 3;
inline void RouteSummary::clear_distance() {
  distance_ = 0;
}
inline ::google::protobuf::int32 RouteSummary::distance() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.distance)
  return distance_;
}
inline void RouteSummary::set_distance(::google::protobuf::int32 value) {
  
  distance_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.distance)
}

// optional int32 elapsed_time = 4;
inline void RouteSummary::clear_elapsed_time() {
  elapsed_time_ = 0;
}
inline ::google::protobuf::int32 RouteSummary::elapsed_time() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.elapsed_time)
  return elapsed_time_;
}
inline void RouteSummary::set_elapsed_time(::google::protobuf::int32 value) {
  
  elapsed_time_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.elapsed_time)
}

#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS
// -------------------------------------------------------------------

// -------------------------------------------------------------------

// -------------------------------------------------------------------

// -------------------------------------------------------------------


// @@protoc_insertion_point(namespace_scope)

}  // namespace routeguide

// @@protoc_insertion_point(global_scope)

#endif  // PROTOBUF_route_5fguide_2eproto__INCLUDED

route_guide.pb.cc
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: route_guide.proto

#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include "route_guide.pb.h"

#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
// @@protoc_insertion_point(includes)

namespace routeguide {

namespace {

const ::google::protobuf::Descriptor* Point_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  Point_reflection_ = NULL;
const ::google::protobuf::Descriptor* Rectangle_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  Rectangle_reflection_ = NULL;
const ::google::protobuf::Descriptor* Feature_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  Feature_reflection_ = NULL;
const ::google::protobuf::Descriptor* RouteNote_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  RouteNote_reflection_ = NULL;
const ::google::protobuf::Descriptor* RouteSummary_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  RouteSummary_reflection_ = NULL;

}  // namespace


void protobuf_AssignDesc_route_5fguide_2eproto() GOOGLE_ATTRIBUTE_COLD;
void protobuf_AssignDesc_route_5fguide_2eproto() {
  protobuf_AddDesc_route_5fguide_2eproto();
  const ::google::protobuf::FileDescriptor* file =
    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
      "route_guide.proto");
  GOOGLE_CHECK(file != NULL);
  Point_descriptor_ = file->message_type(0);
  static const int Point_offsets_[2] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, latitude_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, longitude_),
  };
  Point_reflection_ =
    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
      Point_descriptor_,
      Point::default_instance_,
      Point_offsets_,
      -1,
      -1,
      -1,
      sizeof(Point),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, _internal_metadata_),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, _is_default_instance_));
  Rectangle_descriptor_ = file->message_type(1);
  static const int Rectangle_offsets_[2] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, lo_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, hi_),
  };
  Rectangle_reflection_ =
    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
      Rectangle_descriptor_,
      Rectangle::default_instance_,
      Rectangle_offsets_,
      -1,
      -1,
      -1,
      sizeof(Rectangle),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, _internal_metadata_),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, _is_default_instance_));
  Feature_descriptor_ = file->message_type(2);
  static const int Feature_offsets_[2] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, name_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, location_),
  };
  Feature_reflection_ =
    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
      Feature_descriptor_,
      Feature::default_instance_,
      Feature_offsets_,
      -1,
      -1,
      -1,
      sizeof(Feature),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, _internal_metadata_),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, _is_default_instance_));
  RouteNote_descriptor_ = file->message_type(3);
  static const int RouteNote_offsets_[2] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, location_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, message_),
  };
  RouteNote_reflection_ =
    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
      RouteNote_descriptor_,
      RouteNote::default_instance_,
      RouteNote_offsets_,
      -1,
      -1,
      -1,
      sizeof(RouteNote),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, _internal_metadata_),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, _is_default_instance_));
  RouteSummary_descriptor_ = file->message_type(4);
  static const int RouteSummary_offsets_[4] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, point_count_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, feature_count_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, distance_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, elapsed_time_),
  };
  RouteSummary_reflection_ =
    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
      RouteSummary_descriptor_,
      RouteSummary::default_instance_,
      RouteSummary_offsets_,
      -1,
      -1,
      -1,
      sizeof(RouteSummary),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, _internal_metadata_),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, _is_default_instance_));
}

namespace {

GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
inline void protobuf_AssignDescriptorsOnce() {
  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
                 &protobuf_AssignDesc_route_5fguide_2eproto);
}

void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
      Point_descriptor_, &Point::default_instance());
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
      Rectangle_descriptor_, &Rectangle::default_instance());
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
      Feature_descriptor_, &Feature::default_instance());
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
      RouteNote_descriptor_, &RouteNote::default_instance());
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
      RouteSummary_descriptor_, &RouteSummary::default_instance());
}

}  // namespace

void protobuf_ShutdownFile_route_5fguide_2eproto() {
  delete Point::default_instance_;
  delete Point_reflection_;
  delete Rectangle::default_instance_;
  delete Rectangle_reflection_;
  delete Feature::default_instance_;
  delete Feature_reflection_;
  delete RouteNote::default_instance_;
  delete RouteNote_reflection_;
  delete RouteSummary::default_instance_;
  delete RouteSummary_reflection_;
}

void protobuf_AddDesc_route_5fguide_2eproto() GOOGLE_ATTRIBUTE_COLD;
void protobuf_AddDesc_route_5fguide_2eproto() {
  static bool already_here = false;
  if (already_here) return;
  already_here = true;
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
    "\n\021route_guide.proto\022\nrouteguide\",\n\005Point"
    "\022\020\n\010latitude\030\001 \001(\005\022\021\n\tlongitude\030\002 \001(\005\"I\n"
    "\tRectangle\022\035\n\002lo\030\001 \001(\0132\021.routeguide.Poin"
    "t\022\035\n\002hi\030\002 \001(\0132\021.routeguide.Point\"<\n\007Feat"
    "ure\022\014\n\004name\030\001 \001(\t\022#\n\010location\030\002 \001(\0132\021.ro"
    "uteguide.Point\"A\n\tRouteNote\022#\n\010location\030"
    "\001 \001(\0132\021.routeguide.Point\022\017\n\007message\030\002 \001("
    "\t\"b\n\014RouteSummary\022\023\n\013point_count\030\001 \001(\005\022\025"
    "\n\rfeature_count\030\002 \001(\005\022\020\n\010distance\030\003 \001(\005\022"
    "\024\n\014elapsed_time\030\004 \001(\0052\205\002\n\nRouteGuide\0226\n\n"
    "GetFeature\022\021.routeguide.Point\032\023.routegui"
    "de.Feature\"\000\022>\n\014ListFeatures\022\025.routeguid"
    "e.Rectangle\032\023.routeguide.Feature\"\0000\001\022>\n\013"
    "RecordRoute\022\021.routeguide.Point\032\030.routegu"
    "ide.RouteSummary\"\000(\001\022\?\n\tRouteChat\022\025.rout"
    "eguide.RouteNote\032\025.routeguide.RouteNote\""
    "\000(\0010\001B6\n\033io.grpc.examples.routeguideB\017Ro"
    "uteGuideProtoP\001\242\002\003RTGb\006proto3", 709);
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
    "route_guide.proto", &protobuf_RegisterTypes);
  Point::default_instance_ = new Point();
  Rectangle::default_instance_ = new Rectangle();
  Feature::default_instance_ = new Feature();
  RouteNote::default_instance_ = new RouteNote();
  RouteSummary::default_instance_ = new RouteSummary();
  Point::default_instance_->InitAsDefaultInstance();
  Rectangle::default_instance_->InitAsDefaultInstance();
  Feature::default_instance_->InitAsDefaultInstance();
  RouteNote::default_instance_->InitAsDefaultInstance();
  RouteSummary::default_instance_->InitAsDefaultInstance();
  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_route_5fguide_2eproto);
}

// Force AddDescriptors() to be called at static initialization time.
struct StaticDescriptorInitializer_route_5fguide_2eproto {
  StaticDescriptorInitializer_route_5fguide_2eproto() {
    protobuf_AddDesc_route_5fguide_2eproto();
  }
} static_descriptor_initializer_route_5fguide_2eproto_;

// ===================================================================

#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Point::kLatitudeFieldNumber;
const int Point::kLongitudeFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

Point::Point()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  SharedCtor();
  // @@protoc_insertion_point(constructor:routeguide.Point)
}

void Point::InitAsDefaultInstance() {
  _is_default_instance_ = true;
}

Point::Point(const Point& from)
  : ::google::protobuf::Message(),
    _internal_metadata_(NULL) {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:routeguide.Point)
}

void Point::SharedCtor() {
    _is_default_instance_ = false;
  _cached_size_ = 0;
  latitude_ = 0;
  longitude_ = 0;
}

Point::~Point() {
  // @@protoc_insertion_point(destructor:routeguide.Point)
  SharedDtor();
}

void Point::SharedDtor() {
  if (this != default_instance_) {
  }
}

void Point::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Point::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return Point_descriptor_;
}

const Point& Point::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto();
  return *default_instance_;
}

Point* Point::default_instance_ = NULL;

Point* Point::New(::google::protobuf::Arena* arena) const {
  Point* n = new Point;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void Point::Clear() {
// @@protoc_insertion_point(message_clear_start:routeguide.Point)
#if defined(__clang__)
#define ZR_HELPER_(f) \
  _Pragma("clang diagnostic push") \
  _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
  __builtin_offsetof(Point, f) \
  _Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast(\
  &reinterpret_cast(16)->f)
#endif

#define ZR_(first, last) do {\
  ::memset(&first, 0,\
           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
} while (0)

  ZR_(latitude_, longitude_);

#undef ZR_HELPER_
#undef ZR_

}

bool Point::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:routeguide.Point)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // optional int32 latitude = 1;
      case 1: {
        if (tag == 8) {
          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &latitude_)));

        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(16)) goto parse_longitude;
        break;
      }

      // optional int32 longitude = 2;
      case 2: {
        if (tag == 16) {
         parse_longitude:
          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &longitude_)));

        } else {
          goto handle_unusual;
        }
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:routeguide.Point)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:routeguide.Point)
  return false;
#undef DO_
}

void Point::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:routeguide.Point)
  // optional int32 latitude = 1;
  if (this->latitude() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->latitude(), output);
  }

  // optional int32 longitude = 2;
  if (this->longitude() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->longitude(), output);
  }

  // @@protoc_insertion_point(serialize_end:routeguide.Point)
}

::google::protobuf::uint8* Point::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:routeguide.Point)
  // optional int32 latitude = 1;
  if (this->latitude() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->latitude(), target);
  }

  // optional int32 longitude = 2;
  if (this->longitude() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->longitude(), target);
  }

  // @@protoc_insertion_point(serialize_to_array_end:routeguide.Point)
  return target;
}

int Point::ByteSize() const {
// @@protoc_insertion_point(message_byte_size_start:routeguide.Point)
  int total_size = 0;

  // optional int32 latitude = 1;
  if (this->latitude() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->latitude());
  }

  // optional int32 longitude = 2;
  if (this->longitude() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->longitude());
  }

  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void Point::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:routeguide.Point)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  const Point* source = 
      ::google::protobuf::internal::DynamicCastToGenerated(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:routeguide.Point)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:routeguide.Point)
    MergeFrom(*source);
  }
}

void Point::MergeFrom(const Point& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:routeguide.Point)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  if (from.latitude() != 0) {
    set_latitude(from.latitude());
  }
  if (from.longitude() != 0) {
    set_longitude(from.longitude());
  }
}

void Point::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:routeguide.Point)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Point::CopyFrom(const Point& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:routeguide.Point)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Point::IsInitialized() const {

  return true;
}

void Point::Swap(Point* other) {
  if (other == this) return;
  InternalSwap(other);
}
void Point::InternalSwap(Point* other) {
  std::swap(latitude_, other->latitude_);
  std::swap(longitude_, other->longitude_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  std::swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata Point::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = Point_descriptor_;
  metadata.reflection = Point_reflection_;
  return metadata;
}

#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Point

// optional int32 latitude = 1;
void Point::clear_latitude() {
  latitude_ = 0;
}
 ::google::protobuf::int32 Point::latitude() const {
  // @@protoc_insertion_point(field_get:routeguide.Point.latitude)
  return latitude_;
}
 void Point::set_latitude(::google::protobuf::int32 value) {
  
  latitude_ = value;
  // @@protoc_insertion_point(field_set:routeguide.Point.latitude)
}

// optional int32 longitude = 2;
void Point::clear_longitude() {
  longitude_ = 0;
}
 ::google::protobuf::int32 Point::longitude() const {
  // @@protoc_insertion_point(field_get:routeguide.Point.longitude)
  return longitude_;
}
 void Point::set_longitude(::google::protobuf::int32 value) {
  
  longitude_ = value;
  // @@protoc_insertion_point(field_set:routeguide.Point.longitude)
}

#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS

// ===================================================================

#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Rectangle::kLoFieldNumber;
const int Rectangle::kHiFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

Rectangle::Rectangle()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  SharedCtor();
  // @@protoc_insertion_point(constructor:routeguide.Rectangle)
}

void Rectangle::InitAsDefaultInstance() {
  _is_default_instance_ = true;
  lo_ = const_cast< ::routeguide::Point*>(&::routeguide::Point::default_instance());
  hi_ = const_cast< ::routeguide::Point*>(&::routeguide::Point::default_instance());
}

Rectangle::Rectangle(const Rectangle& from)
  : ::google::protobuf::Message(),
    _internal_metadata_(NULL) {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:routeguide.Rectangle)
}

void Rectangle::SharedCtor() {
    _is_default_instance_ = false;
  _cached_size_ = 0;
  lo_ = NULL;
  hi_ = NULL;
}

Rectangle::~Rectangle() {
  // @@protoc_insertion_point(destructor:routeguide.Rectangle)
  SharedDtor();
}

void Rectangle::SharedDtor() {
  if (this != default_instance_) {
    delete lo_;
    delete hi_;
  }
}

void Rectangle::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Rectangle::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return Rectangle_descriptor_;
}

const Rectangle& Rectangle::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto();
  return *default_instance_;
}

Rectangle* Rectangle::default_instance_ = NULL;

Rectangle* Rectangle::New(::google::protobuf::Arena* arena) const {
  Rectangle* n = new Rectangle;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void Rectangle::Clear() {
// @@protoc_insertion_point(message_clear_start:routeguide.Rectangle)
  if (GetArenaNoVirtual() == NULL && lo_ != NULL) delete lo_;
  lo_ = NULL;
  if (GetArenaNoVirtual() == NULL && hi_ != NULL) delete hi_;
  hi_ = NULL;
}

bool Rectangle::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:routeguide.Rectangle)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // optional .routeguide.Point lo = 1;
      case 1: {
        if (tag == 10) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
               input, mutable_lo()));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(18)) goto parse_hi;
        break;
      }

      // optional .routeguide.Point hi = 2;
      case 2: {
        if (tag == 18) {
         parse_hi:
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
               input, mutable_hi()));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:routeguide.Rectangle)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:routeguide.Rectangle)
  return false;
#undef DO_
}

void Rectangle::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:routeguide.Rectangle)
  // optional .routeguide.Point lo = 1;
  if (this->has_lo()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      1, *this->lo_, output);
  }

  // optional .routeguide.Point hi = 2;
  if (this->has_hi()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      2, *this->hi_, output);
  }

  // @@protoc_insertion_point(serialize_end:routeguide.Rectangle)
}

::google::protobuf::uint8* Rectangle::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:routeguide.Rectangle)
  // optional .routeguide.Point lo = 1;
  if (this->has_lo()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageNoVirtualToArray(
        1, *this->lo_, false, target);
  }

  // optional .routeguide.Point hi = 2;
  if (this->has_hi()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageNoVirtualToArray(
        2, *this->hi_, false, target);
  }

  // @@protoc_insertion_point(serialize_to_array_end:routeguide.Rectangle)
  return target;
}

int Rectangle::ByteSize() const {
// @@protoc_insertion_point(message_byte_size_start:routeguide.Rectangle)
  int total_size = 0;

  // optional .routeguide.Point lo = 1;
  if (this->has_lo()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
        *this->lo_);
  }

  // optional .routeguide.Point hi = 2;
  if (this->has_hi()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
        *this->hi_);
  }

  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void Rectangle::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:routeguide.Rectangle)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  const Rectangle* source = 
      ::google::protobuf::internal::DynamicCastToGenerated(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:routeguide.Rectangle)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:routeguide.Rectangle)
    MergeFrom(*source);
  }
}

void Rectangle::MergeFrom(const Rectangle& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:routeguide.Rectangle)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  if (from.has_lo()) {
    mutable_lo()->::routeguide::Point::MergeFrom(from.lo());
  }
  if (from.has_hi()) {
    mutable_hi()->::routeguide::Point::MergeFrom(from.hi());
  }
}

void Rectangle::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:routeguide.Rectangle)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Rectangle::CopyFrom(const Rectangle& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:routeguide.Rectangle)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Rectangle::IsInitialized() const {

  return true;
}

void Rectangle::Swap(Rectangle* other) {
  if (other == this) return;
  InternalSwap(other);
}
void Rectangle::InternalSwap(Rectangle* other) {
  std::swap(lo_, other->lo_);
  std::swap(hi_, other->hi_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  std::swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata Rectangle::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = Rectangle_descriptor_;
  metadata.reflection = Rectangle_reflection_;
  return metadata;
}

#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Rectangle

// optional .routeguide.Point lo = 1;
bool Rectangle::has_lo() const {
  return !_is_default_instance_ && lo_ != NULL;
}
void Rectangle::clear_lo() {
  if (GetArenaNoVirtual() == NULL && lo_ != NULL) delete lo_;
  lo_ = NULL;
}
const ::routeguide::Point& Rectangle::lo() const {
  // @@protoc_insertion_point(field_get:routeguide.Rectangle.lo)
  return lo_ != NULL ? *lo_ : *default_instance_->lo_;
}
::routeguide::Point* Rectangle::mutable_lo() {
  
  if (lo_ == NULL) {
    lo_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.Rectangle.lo)
  return lo_;
}
::routeguide::Point* Rectangle::release_lo() {
  // @@protoc_insertion_point(field_release:routeguide.Rectangle.lo)
  
  ::routeguide::Point* temp = lo_;
  lo_ = NULL;
  return temp;
}
void Rectangle::set_allocated_lo(::routeguide::Point* lo) {
  delete lo_;
  lo_ = lo;
  if (lo) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.Rectangle.lo)
}

// optional .routeguide.Point hi = 2;
bool Rectangle::has_hi() const {
  return !_is_default_instance_ && hi_ != NULL;
}
void Rectangle::clear_hi() {
  if (GetArenaNoVirtual() == NULL && hi_ != NULL) delete hi_;
  hi_ = NULL;
}
const ::routeguide::Point& Rectangle::hi() const {
  // @@protoc_insertion_point(field_get:routeguide.Rectangle.hi)
  return hi_ != NULL ? *hi_ : *default_instance_->hi_;
}
::routeguide::Point* Rectangle::mutable_hi() {
  
  if (hi_ == NULL) {
    hi_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.Rectangle.hi)
  return hi_;
}
::routeguide::Point* Rectangle::release_hi() {
  // @@protoc_insertion_point(field_release:routeguide.Rectangle.hi)
  
  ::routeguide::Point* temp = hi_;
  hi_ = NULL;
  return temp;
}
void Rectangle::set_allocated_hi(::routeguide::Point* hi) {
  delete hi_;
  hi_ = hi;
  if (hi) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.Rectangle.hi)
}

#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS

// ===================================================================

#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Feature::kNameFieldNumber;
const int Feature::kLocationFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

Feature::Feature()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  SharedCtor();
  // @@protoc_insertion_point(constructor:routeguide.Feature)
}

void Feature::InitAsDefaultInstance() {
  _is_default_instance_ = true;
  location_ = const_cast< ::routeguide::Point*>(&::routeguide::Point::default_instance());
}

Feature::Feature(const Feature& from)
  : ::google::protobuf::Message(),
    _internal_metadata_(NULL) {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:routeguide.Feature)
}

void Feature::SharedCtor() {
    _is_default_instance_ = false;
  ::google::protobuf::internal::GetEmptyString();
  _cached_size_ = 0;
  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  location_ = NULL;
}

Feature::~Feature() {
  // @@protoc_insertion_point(destructor:routeguide.Feature)
  SharedDtor();
}

void Feature::SharedDtor() {
  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (this != default_instance_) {
    delete location_;
  }
}

void Feature::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Feature::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return Feature_descriptor_;
}

const Feature& Feature::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto();
  return *default_instance_;
}

Feature* Feature::default_instance_ = NULL;

Feature* Feature::New(::google::protobuf::Arena* arena) const {
  Feature* n = new Feature;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void Feature::Clear() {
// @@protoc_insertion_point(message_clear_start:routeguide.Feature)
  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (GetArenaNoVirtual() == NULL && location_ != NULL) delete location_;
  location_ = NULL;
}

bool Feature::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:routeguide.Feature)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // optional string name = 1;
      case 1: {
        if (tag == 10) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
                input, this->mutable_name()));
          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
            this->name().data(), this->name().length(),
            ::google::protobuf::internal::WireFormatLite::PARSE,
            "routeguide.Feature.name"));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(18)) goto parse_location;
        break;
      }

      // optional .routeguide.Point location = 2;
      case 2: {
        if (tag == 18) {
         parse_location:
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
               input, mutable_location()));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:routeguide.Feature)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:routeguide.Feature)
  return false;
#undef DO_
}

void Feature::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:routeguide.Feature)
  // optional string name = 1;
  if (this->name().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->name().data(), this->name().length(),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "routeguide.Feature.name");
    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
      1, this->name(), output);
  }

  // optional .routeguide.Point location = 2;
  if (this->has_location()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      2, *this->location_, output);
  }

  // @@protoc_insertion_point(serialize_end:routeguide.Feature)
}

::google::protobuf::uint8* Feature::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:routeguide.Feature)
  // optional string name = 1;
  if (this->name().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->name().data(), this->name().length(),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "routeguide.Feature.name");
    target =
      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
        1, this->name(), target);
  }

  // optional .routeguide.Point location = 2;
  if (this->has_location()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageNoVirtualToArray(
        2, *this->location_, false, target);
  }

  // @@protoc_insertion_point(serialize_to_array_end:routeguide.Feature)
  return target;
}

int Feature::ByteSize() const {
// @@protoc_insertion_point(message_byte_size_start:routeguide.Feature)
  int total_size = 0;

  // optional string name = 1;
  if (this->name().size() > 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::StringSize(
        this->name());
  }

  // optional .routeguide.Point location = 2;
  if (this->has_location()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
        *this->location_);
  }

  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void Feature::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:routeguide.Feature)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  const Feature* source = 
      ::google::protobuf::internal::DynamicCastToGenerated(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:routeguide.Feature)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:routeguide.Feature)
    MergeFrom(*source);
  }
}

void Feature::MergeFrom(const Feature& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:routeguide.Feature)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  if (from.name().size() > 0) {

    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
  }
  if (from.has_location()) {
    mutable_location()->::routeguide::Point::MergeFrom(from.location());
  }
}

void Feature::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:routeguide.Feature)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Feature::CopyFrom(const Feature& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:routeguide.Feature)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Feature::IsInitialized() const {

  return true;
}

void Feature::Swap(Feature* other) {
  if (other == this) return;
  InternalSwap(other);
}
void Feature::InternalSwap(Feature* other) {
  name_.Swap(&other->name_);
  std::swap(location_, other->location_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  std::swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata Feature::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = Feature_descriptor_;
  metadata.reflection = Feature_reflection_;
  return metadata;
}

#if PROTOBUF_INLINE_NOT_IN_HEADERS
// Feature

// optional string name = 1;
void Feature::clear_name() {
  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 const ::std::string& Feature::name() const {
  // @@protoc_insertion_point(field_get:routeguide.Feature.name)
  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 void Feature::set_name(const ::std::string& value) {
  
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
  // @@protoc_insertion_point(field_set:routeguide.Feature.name)
}
 void Feature::set_name(const char* value) {
  
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
  // @@protoc_insertion_point(field_set_char:routeguide.Feature.name)
}
 void Feature::set_name(const char* value, size_t size) {
  
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
      ::std::string(reinterpret_cast(value), size));
  // @@protoc_insertion_point(field_set_pointer:routeguide.Feature.name)
}
 ::std::string* Feature::mutable_name() {
  
  // @@protoc_insertion_point(field_mutable:routeguide.Feature.name)
  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 ::std::string* Feature::release_name() {
  // @@protoc_insertion_point(field_release:routeguide.Feature.name)
  
  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 void Feature::set_allocated_name(::std::string* name) {
  if (name != NULL) {
    
  } else {
    
  }
  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
  // @@protoc_insertion_point(field_set_allocated:routeguide.Feature.name)
}

// optional .routeguide.Point location = 2;
bool Feature::has_location() const {
  return !_is_default_instance_ && location_ != NULL;
}
void Feature::clear_location() {
  if (GetArenaNoVirtual() == NULL && location_ != NULL) delete location_;
  location_ = NULL;
}
const ::routeguide::Point& Feature::location() const {
  // @@protoc_insertion_point(field_get:routeguide.Feature.location)
  return location_ != NULL ? *location_ : *default_instance_->location_;
}
::routeguide::Point* Feature::mutable_location() {
  
  if (location_ == NULL) {
    location_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.Feature.location)
  return location_;
}
::routeguide::Point* Feature::release_location() {
  // @@protoc_insertion_point(field_release:routeguide.Feature.location)
  
  ::routeguide::Point* temp = location_;
  location_ = NULL;
  return temp;
}
void Feature::set_allocated_location(::routeguide::Point* location) {
  delete location_;
  location_ = location;
  if (location) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.Feature.location)
}

#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS

// ===================================================================

#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int RouteNote::kLocationFieldNumber;
const int RouteNote::kMessageFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

RouteNote::RouteNote()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  SharedCtor();
  // @@protoc_insertion_point(constructor:routeguide.RouteNote)
}

void RouteNote::InitAsDefaultInstance() {
  _is_default_instance_ = true;
  location_ = const_cast< ::routeguide::Point*>(&::routeguide::Point::default_instance());
}

RouteNote::RouteNote(const RouteNote& from)
  : ::google::protobuf::Message(),
    _internal_metadata_(NULL) {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:routeguide.RouteNote)
}

void RouteNote::SharedCtor() {
    _is_default_instance_ = false;
  ::google::protobuf::internal::GetEmptyString();
  _cached_size_ = 0;
  location_ = NULL;
  message_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}

RouteNote::~RouteNote() {
  // @@protoc_insertion_point(destructor:routeguide.RouteNote)
  SharedDtor();
}

void RouteNote::SharedDtor() {
  message_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (this != default_instance_) {
    delete location_;
  }
}

void RouteNote::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* RouteNote::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return RouteNote_descriptor_;
}

const RouteNote& RouteNote::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto();
  return *default_instance_;
}

RouteNote* RouteNote::default_instance_ = NULL;

RouteNote* RouteNote::New(::google::protobuf::Arena* arena) const {
  RouteNote* n = new RouteNote;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void RouteNote::Clear() {
// @@protoc_insertion_point(message_clear_start:routeguide.RouteNote)
  if (GetArenaNoVirtual() == NULL && location_ != NULL) delete location_;
  location_ = NULL;
  message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}

bool RouteNote::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:routeguide.RouteNote)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // optional .routeguide.Point location = 1;
      case 1: {
        if (tag == 10) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
               input, mutable_location()));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(18)) goto parse_message;
        break;
      }

      // optional string message = 2;
      case 2: {
        if (tag == 18) {
         parse_message:
          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
                input, this->mutable_message()));
          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
            this->message().data(), this->message().length(),
            ::google::protobuf::internal::WireFormatLite::PARSE,
            "routeguide.RouteNote.message"));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:routeguide.RouteNote)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:routeguide.RouteNote)
  return false;
#undef DO_
}

void RouteNote::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:routeguide.RouteNote)
  // optional .routeguide.Point location = 1;
  if (this->has_location()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      1, *this->location_, output);
  }

  // optional string message = 2;
  if (this->message().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->message().data(), this->message().length(),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "routeguide.RouteNote.message");
    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
      2, this->message(), output);
  }

  // @@protoc_insertion_point(serialize_end:routeguide.RouteNote)
}

::google::protobuf::uint8* RouteNote::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:routeguide.RouteNote)
  // optional .routeguide.Point location = 1;
  if (this->has_location()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageNoVirtualToArray(
        1, *this->location_, false, target);
  }

  // optional string message = 2;
  if (this->message().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->message().data(), this->message().length(),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "routeguide.RouteNote.message");
    target =
      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
        2, this->message(), target);
  }

  // @@protoc_insertion_point(serialize_to_array_end:routeguide.RouteNote)
  return target;
}

int RouteNote::ByteSize() const {
// @@protoc_insertion_point(message_byte_size_start:routeguide.RouteNote)
  int total_size = 0;

  // optional .routeguide.Point location = 1;
  if (this->has_location()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
        *this->location_);
  }

  // optional string message = 2;
  if (this->message().size() > 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::StringSize(
        this->message());
  }

  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void RouteNote::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:routeguide.RouteNote)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  const RouteNote* source = 
      ::google::protobuf::internal::DynamicCastToGenerated(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:routeguide.RouteNote)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:routeguide.RouteNote)
    MergeFrom(*source);
  }
}

void RouteNote::MergeFrom(const RouteNote& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:routeguide.RouteNote)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  if (from.has_location()) {
    mutable_location()->::routeguide::Point::MergeFrom(from.location());
  }
  if (from.message().size() > 0) {

    message_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.message_);
  }
}

void RouteNote::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:routeguide.RouteNote)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void RouteNote::CopyFrom(const RouteNote& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:routeguide.RouteNote)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool RouteNote::IsInitialized() const {

  return true;
}

void RouteNote::Swap(RouteNote* other) {
  if (other == this) return;
  InternalSwap(other);
}
void RouteNote::InternalSwap(RouteNote* other) {
  std::swap(location_, other->location_);
  message_.Swap(&other->message_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  std::swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata RouteNote::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = RouteNote_descriptor_;
  metadata.reflection = RouteNote_reflection_;
  return metadata;
}

#if PROTOBUF_INLINE_NOT_IN_HEADERS
// RouteNote

// optional .routeguide.Point location = 1;
bool RouteNote::has_location() const {
  return !_is_default_instance_ && location_ != NULL;
}
void RouteNote::clear_location() {
  if (GetArenaNoVirtual() == NULL && location_ != NULL) delete location_;
  location_ = NULL;
}
const ::routeguide::Point& RouteNote::location() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteNote.location)
  return location_ != NULL ? *location_ : *default_instance_->location_;
}
::routeguide::Point* RouteNote::mutable_location() {
  
  if (location_ == NULL) {
    location_ = new ::routeguide::Point;
  }
  // @@protoc_insertion_point(field_mutable:routeguide.RouteNote.location)
  return location_;
}
::routeguide::Point* RouteNote::release_location() {
  // @@protoc_insertion_point(field_release:routeguide.RouteNote.location)
  
  ::routeguide::Point* temp = location_;
  location_ = NULL;
  return temp;
}
void RouteNote::set_allocated_location(::routeguide::Point* location) {
  delete location_;
  location_ = location;
  if (location) {
    
  } else {
    
  }
  // @@protoc_insertion_point(field_set_allocated:routeguide.RouteNote.location)
}

// optional string message = 2;
void RouteNote::clear_message() {
  message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 const ::std::string& RouteNote::message() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteNote.message)
  return message_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 void RouteNote::set_message(const ::std::string& value) {
  
  message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
  // @@protoc_insertion_point(field_set:routeguide.RouteNote.message)
}
 void RouteNote::set_message(const char* value) {
  
  message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
  // @@protoc_insertion_point(field_set_char:routeguide.RouteNote.message)
}
 void RouteNote::set_message(const char* value, size_t size) {
  
  message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
      ::std::string(reinterpret_cast(value), size));
  // @@protoc_insertion_point(field_set_pointer:routeguide.RouteNote.message)
}
 ::std::string* RouteNote::mutable_message() {
  
  // @@protoc_insertion_point(field_mutable:routeguide.RouteNote.message)
  return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 ::std::string* RouteNote::release_message() {
  // @@protoc_insertion_point(field_release:routeguide.RouteNote.message)
  
  return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
 void RouteNote::set_allocated_message(::std::string* message) {
  if (message != NULL) {
    
  } else {
    
  }
  message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message);
  // @@protoc_insertion_point(field_set_allocated:routeguide.RouteNote.message)
}

#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS

// ===================================================================

#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int RouteSummary::kPointCountFieldNumber;
const int RouteSummary::kFeatureCountFieldNumber;
const int RouteSummary::kDistanceFieldNumber;
const int RouteSummary::kElapsedTimeFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

RouteSummary::RouteSummary()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  SharedCtor();
  // @@protoc_insertion_point(constructor:routeguide.RouteSummary)
}

void RouteSummary::InitAsDefaultInstance() {
  _is_default_instance_ = true;
}

RouteSummary::RouteSummary(const RouteSummary& from)
  : ::google::protobuf::Message(),
    _internal_metadata_(NULL) {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:routeguide.RouteSummary)
}

void RouteSummary::SharedCtor() {
    _is_default_instance_ = false;
  _cached_size_ = 0;
  point_count_ = 0;
  feature_count_ = 0;
  distance_ = 0;
  elapsed_time_ = 0;
}

RouteSummary::~RouteSummary() {
  // @@protoc_insertion_point(destructor:routeguide.RouteSummary)
  SharedDtor();
}

void RouteSummary::SharedDtor() {
  if (this != default_instance_) {
  }
}

void RouteSummary::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* RouteSummary::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return RouteSummary_descriptor_;
}

const RouteSummary& RouteSummary::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto();
  return *default_instance_;
}

RouteSummary* RouteSummary::default_instance_ = NULL;

RouteSummary* RouteSummary::New(::google::protobuf::Arena* arena) const {
  RouteSummary* n = new RouteSummary;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void RouteSummary::Clear() {
// @@protoc_insertion_point(message_clear_start:routeguide.RouteSummary)
#if defined(__clang__)
#define ZR_HELPER_(f) \
  _Pragma("clang diagnostic push") \
  _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
  __builtin_offsetof(RouteSummary, f) \
  _Pragma("clang diagnostic pop")
#else
#define ZR_HELPER_(f) reinterpret_cast(\
  &reinterpret_cast(16)->f)
#endif

#define ZR_(first, last) do {\
  ::memset(&first, 0,\
           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
} while (0)

  ZR_(point_count_, elapsed_time_);

#undef ZR_HELPER_
#undef ZR_

}

bool RouteSummary::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:routeguide.RouteSummary)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // optional int32 point_count = 1;
      case 1: {
        if (tag == 8) {
          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &point_count_)));

        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(16)) goto parse_feature_count;
        break;
      }

      // optional int32 feature_count = 2;
      case 2: {
        if (tag == 16) {
         parse_feature_count:
          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &feature_count_)));

        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(24)) goto parse_distance;
        break;
      }

      // optional int32 distance = 3;
      case 3: {
        if (tag == 24) {
         parse_distance:
          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &distance_)));

        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(32)) goto parse_elapsed_time;
        break;
      }

      // optional int32 elapsed_time = 4;
      case 4: {
        if (tag == 32) {
         parse_elapsed_time:
          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &elapsed_time_)));

        } else {
          goto handle_unusual;
        }
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:routeguide.RouteSummary)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:routeguide.RouteSummary)
  return false;
#undef DO_
}

void RouteSummary::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:routeguide.RouteSummary)
  // optional int32 point_count = 1;
  if (this->point_count() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->point_count(), output);
  }

  // optional int32 feature_count = 2;
  if (this->feature_count() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->feature_count(), output);
  }

  // optional int32 distance = 3;
  if (this->distance() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->distance(), output);
  }

  // optional int32 elapsed_time = 4;
  if (this->elapsed_time() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->elapsed_time(), output);
  }

  // @@protoc_insertion_point(serialize_end:routeguide.RouteSummary)
}

::google::protobuf::uint8* RouteSummary::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:routeguide.RouteSummary)
  // optional int32 point_count = 1;
  if (this->point_count() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->point_count(), target);
  }

  // optional int32 feature_count = 2;
  if (this->feature_count() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->feature_count(), target);
  }

  // optional int32 distance = 3;
  if (this->distance() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->distance(), target);
  }

  // optional int32 elapsed_time = 4;
  if (this->elapsed_time() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->elapsed_time(), target);
  }

  // @@protoc_insertion_point(serialize_to_array_end:routeguide.RouteSummary)
  return target;
}

int RouteSummary::ByteSize() const {
// @@protoc_insertion_point(message_byte_size_start:routeguide.RouteSummary)
  int total_size = 0;

  // optional int32 point_count = 1;
  if (this->point_count() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->point_count());
  }

  // optional int32 feature_count = 2;
  if (this->feature_count() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->feature_count());
  }

  // optional int32 distance = 3;
  if (this->distance() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->distance());
  }

  // optional int32 elapsed_time = 4;
  if (this->elapsed_time() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->elapsed_time());
  }

  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void RouteSummary::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:routeguide.RouteSummary)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  const RouteSummary* source = 
      ::google::protobuf::internal::DynamicCastToGenerated(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:routeguide.RouteSummary)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:routeguide.RouteSummary)
    MergeFrom(*source);
  }
}

void RouteSummary::MergeFrom(const RouteSummary& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:routeguide.RouteSummary)
  if (GOOGLE_PREDICT_FALSE(&from == this)) {
    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);
  }
  if (from.point_count() != 0) {
    set_point_count(from.point_count());
  }
  if (from.feature_count() != 0) {
    set_feature_count(from.feature_count());
  }
  if (from.distance() != 0) {
    set_distance(from.distance());
  }
  if (from.elapsed_time() != 0) {
    set_elapsed_time(from.elapsed_time());
  }
}

void RouteSummary::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:routeguide.RouteSummary)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void RouteSummary::CopyFrom(const RouteSummary& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:routeguide.RouteSummary)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool RouteSummary::IsInitialized() const {

  return true;
}

void RouteSummary::Swap(RouteSummary* other) {
  if (other == this) return;
  InternalSwap(other);
}
void RouteSummary::InternalSwap(RouteSummary* other) {
  std::swap(point_count_, other->point_count_);
  std::swap(feature_count_, other->feature_count_);
  std::swap(distance_, other->distance_);
  std::swap(elapsed_time_, other->elapsed_time_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  std::swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata RouteSummary::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = RouteSummary_descriptor_;
  metadata.reflection = RouteSummary_reflection_;
  return metadata;
}

#if PROTOBUF_INLINE_NOT_IN_HEADERS
// RouteSummary

// optional int32 point_count = 1;
void RouteSummary::clear_point_count() {
  point_count_ = 0;
}
 ::google::protobuf::int32 RouteSummary::point_count() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.point_count)
  return point_count_;
}
 void RouteSummary::set_point_count(::google::protobuf::int32 value) {
  
  point_count_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.point_count)
}

// optional int32 feature_count = 2;
void RouteSummary::clear_feature_count() {
  feature_count_ = 0;
}
 ::google::protobuf::int32 RouteSummary::feature_count() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.feature_count)
  return feature_count_;
}
 void RouteSummary::set_feature_count(::google::protobuf::int32 value) {
  
  feature_count_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.feature_count)
}

// optional int32 distance = 3;
void RouteSummary::clear_distance() {
  distance_ = 0;
}
 ::google::protobuf::int32 RouteSummary::distance() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.distance)
  return distance_;
}
 void RouteSummary::set_distance(::google::protobuf::int32 value) {
  
  distance_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.distance)
}

// optional int32 elapsed_time = 4;
void RouteSummary::clear_elapsed_time() {
  elapsed_time_ = 0;
}
 ::google::protobuf::int32 RouteSummary::elapsed_time() const {
  // @@protoc_insertion_point(field_get:routeguide.RouteSummary.elapsed_time)
  return elapsed_time_;
}
 void RouteSummary::set_elapsed_time(::google::protobuf::int32 value) {
  
  elapsed_time_ = value;
  // @@protoc_insertion_point(field_set:routeguide.RouteSummary.elapsed_time)
}

#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS

// @@protoc_insertion_point(namespace_scope)

}  // namespace routeguide

// @@protoc_insertion_point(global_scope)

route_guide.grpc.pb.h
// Generated by the gRPC C++ plugin.
// If you make any local change, they will be lost.
// source: route_guide.proto
// Original file comments:
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef GRPC_route_5fguide_2eproto__INCLUDED
#define GRPC_route_5fguide_2eproto__INCLUDED

#include "route_guide.pb.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

namespace grpc {
class CompletionQueue;
class Channel;
class RpcService;
class ServerCompletionQueue;
class ServerContext;
}  // namespace grpc

namespace routeguide {

// Interface exported by the server.
class RouteGuide final {
 public:
  class StubInterface {
   public:
    virtual ~StubInterface() {}
    // A simple RPC.
    //
    // Obtains the feature at a given position.
    //
    // A feature with an empty name is returned if there's no feature at the given
    // position.
    virtual ::grpc::Status GetFeature(::grpc::ClientContext* context, const ::routeguide::Point& request, ::routeguide::Feature* response) = 0;
    std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::routeguide::Feature>> AsyncGetFeature(::grpc::ClientContext* context, const ::routeguide::Point& request, ::grpc::CompletionQueue* cq) {
      return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::routeguide::Feature>>(AsyncGetFeatureRaw(context, request, cq));
    }
    // A server-to-client streaming RPC.
    //
    // Obtains the Features available within the given Rectangle.  Results are
    // streamed rather than returned at once (e.g. in a response message with a
    // repeated field), as the rectangle may cover a large area and contain a
    // huge number of features.
    std::unique_ptr< ::grpc::ClientReaderInterface< ::routeguide::Feature>> ListFeatures(::grpc::ClientContext* context, const ::routeguide::Rectangle& request) {
      return std::unique_ptr< ::grpc::ClientReaderInterface< ::routeguide::Feature>>(ListFeaturesRaw(context, request));
    }
    std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::routeguide::Feature>> AsyncListFeatures(::grpc::ClientContext* context, const ::routeguide::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag) {
      return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::routeguide::Feature>>(AsyncListFeaturesRaw(context, request, cq, tag));
    }
    // A client-to-server streaming RPC.
    //
    // Accepts a stream of Points on a route being traversed, returning a
    // RouteSummary when traversal is completed.
    std::unique_ptr< ::grpc::ClientWriterInterface< ::routeguide::Point>> RecordRoute(::grpc::ClientContext* context, ::routeguide::RouteSummary* response) {
      return std::unique_ptr< ::grpc::ClientWriterInterface< ::routeguide::Point>>(RecordRouteRaw(context, response));
    }
    std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::routeguide::Point>> AsyncRecordRoute(::grpc::ClientContext* context, ::routeguide::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag) {
      return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::routeguide::Point>>(AsyncRecordRouteRaw(context, response, cq, tag));
    }
    // A Bidirectional streaming RPC.
    //
    // Accepts a stream of RouteNotes sent while a route is being traversed,
    // while receiving other RouteNotes (e.g. from other users).
    std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::routeguide::RouteNote, ::routeguide::RouteNote>> RouteChat(::grpc::ClientContext* context) {
      return std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::routeguide::RouteNote, ::routeguide::RouteNote>>(RouteChatRaw(context));
    }
    std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::routeguide::RouteNote, ::routeguide::RouteNote>> AsyncRouteChat(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
      return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::routeguide::RouteNote, ::routeguide::RouteNote>>(AsyncRouteChatRaw(context, cq, tag));
    }
  private:
    virtual ::grpc::ClientAsyncResponseReaderInterface< ::routeguide::Feature>* AsyncGetFeatureRaw(::grpc::ClientContext* context, const ::routeguide::Point& request, ::grpc::CompletionQueue* cq) = 0;
    virtual ::grpc::ClientReaderInterface< ::routeguide::Feature>* ListFeaturesRaw(::grpc::ClientContext* context, const ::routeguide::Rectangle& request) = 0;
    virtual ::grpc::ClientAsyncReaderInterface< ::routeguide::Feature>* AsyncListFeaturesRaw(::grpc::ClientContext* context, const ::routeguide::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag) = 0;
    virtual ::grpc::ClientWriterInterface< ::routeguide::Point>* RecordRouteRaw(::grpc::ClientContext* context, ::routeguide::RouteSummary* response) = 0;
    virtual ::grpc::ClientAsyncWriterInterface< ::routeguide::Point>* AsyncRecordRouteRaw(::grpc::ClientContext* context, ::routeguide::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag) = 0;
    virtual ::grpc::ClientReaderWriterInterface< ::routeguide::RouteNote, ::routeguide::RouteNote>* RouteChatRaw(::grpc::ClientContext* context) = 0;
    virtual ::grpc::ClientAsyncReaderWriterInterface< ::routeguide::RouteNote, ::routeguide::RouteNote>* AsyncRouteChatRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0;
  };
  class Stub final : public StubInterface {
   public:
    Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
    ::grpc::Status GetFeature(::grpc::ClientContext* context, const ::routeguide::Point& request, ::routeguide::Feature* response) override;
    std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::routeguide::Feature>> AsyncGetFeature(::grpc::ClientContext* context, const ::routeguide::Point& request, ::grpc::CompletionQueue* cq) {
      return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::routeguide::Feature>>(AsyncGetFeatureRaw(context, request, cq));
    }
    std::unique_ptr< ::grpc::ClientReader< ::routeguide::Feature>> ListFeatures(::grpc::ClientContext* context, const ::routeguide::Rectangle& request) {
      return std::unique_ptr< ::grpc::ClientReader< ::routeguide::Feature>>(ListFeaturesRaw(context, request));
    }
    std::unique_ptr< ::grpc::ClientAsyncReader< ::routeguide::Feature>> AsyncListFeatures(::grpc::ClientContext* context, const ::routeguide::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag) {
      return std::unique_ptr< ::grpc::ClientAsyncReader< ::routeguide::Feature>>(AsyncListFeaturesRaw(context, request, cq, tag));
    }
    std::unique_ptr< ::grpc::ClientWriter< ::routeguide::Point>> RecordRoute(::grpc::ClientContext* context, ::routeguide::RouteSummary* response) {
      return std::unique_ptr< ::grpc::ClientWriter< ::routeguide::Point>>(RecordRouteRaw(context, response));
    }
    std::unique_ptr< ::grpc::ClientAsyncWriter< ::routeguide::Point>> AsyncRecordRoute(::grpc::ClientContext* context, ::routeguide::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag) {
      return std::unique_ptr< ::grpc::ClientAsyncWriter< ::routeguide::Point>>(AsyncRecordRouteRaw(context, response, cq, tag));
    }
    std::unique_ptr< ::grpc::ClientReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>> RouteChat(::grpc::ClientContext* context) {
      return std::unique_ptr< ::grpc::ClientReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>>(RouteChatRaw(context));
    }
    std::unique_ptr<  ::grpc::ClientAsyncReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>> AsyncRouteChat(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
      return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>>(AsyncRouteChatRaw(context, cq, tag));
    }

   private:
    std::shared_ptr< ::grpc::ChannelInterface> channel_;
    ::grpc::ClientAsyncResponseReader< ::routeguide::Feature>* AsyncGetFeatureRaw(::grpc::ClientContext* context, const ::routeguide::Point& request, ::grpc::CompletionQueue* cq) override;
    ::grpc::ClientReader< ::routeguide::Feature>* ListFeaturesRaw(::grpc::ClientContext* context, const ::routeguide::Rectangle& request) override;
    ::grpc::ClientAsyncReader< ::routeguide::Feature>* AsyncListFeaturesRaw(::grpc::ClientContext* context, const ::routeguide::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag) override;
    ::grpc::ClientWriter< ::routeguide::Point>* RecordRouteRaw(::grpc::ClientContext* context, ::routeguide::RouteSummary* response) override;
    ::grpc::ClientAsyncWriter< ::routeguide::Point>* AsyncRecordRouteRaw(::grpc::ClientContext* context, ::routeguide::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag) override;
    ::grpc::ClientReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* RouteChatRaw(::grpc::ClientContext* context) override;
    ::grpc::ClientAsyncReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* AsyncRouteChatRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) override;
    const ::grpc::RpcMethod rpcmethod_GetFeature_;
    const ::grpc::RpcMethod rpcmethod_ListFeatures_;
    const ::grpc::RpcMethod rpcmethod_RecordRoute_;
    const ::grpc::RpcMethod rpcmethod_RouteChat_;
  };
  static std::unique_ptr NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());

  class Service : public ::grpc::Service {
   public:
    Service();
    virtual ~Service();
    // A simple RPC.
    //
    // Obtains the feature at a given position.
    //
    // A feature with an empty name is returned if there's no feature at the given
    // position.
    virtual ::grpc::Status GetFeature(::grpc::ServerContext* context, const ::routeguide::Point* request, ::routeguide::Feature* response);
    // A server-to-client streaming RPC.
    //
    // Obtains the Features available within the given Rectangle.  Results are
    // streamed rather than returned at once (e.g. in a response message with a
    // repeated field), as the rectangle may cover a large area and contain a
    // huge number of features.
    virtual ::grpc::Status ListFeatures(::grpc::ServerContext* context, const ::routeguide::Rectangle* request, ::grpc::ServerWriter< ::routeguide::Feature>* writer);
    // A client-to-server streaming RPC.
    //
    // Accepts a stream of Points on a route being traversed, returning a
    // RouteSummary when traversal is completed.
    virtual ::grpc::Status RecordRoute(::grpc::ServerContext* context, ::grpc::ServerReader< ::routeguide::Point>* reader, ::routeguide::RouteSummary* response);
    // A Bidirectional streaming RPC.
    //
    // Accepts a stream of RouteNotes sent while a route is being traversed,
    // while receiving other RouteNotes (e.g. from other users).
    virtual ::grpc::Status RouteChat(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* stream);
  };
  template 
  class WithAsyncMethod_GetFeature : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithAsyncMethod_GetFeature() {
      ::grpc::Service::MarkMethodAsync(0);
    }
    ~WithAsyncMethod_GetFeature() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status GetFeature(::grpc::ServerContext* context, const ::routeguide::Point* request, ::routeguide::Feature* response) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
    void RequestGetFeature(::grpc::ServerContext* context, ::routeguide::Point* request, ::grpc::ServerAsyncResponseWriter< ::routeguide::Feature>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
      ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
    }
  };
  template 
  class WithAsyncMethod_ListFeatures : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithAsyncMethod_ListFeatures() {
      ::grpc::Service::MarkMethodAsync(1);
    }
    ~WithAsyncMethod_ListFeatures() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status ListFeatures(::grpc::ServerContext* context, const ::routeguide::Rectangle* request, ::grpc::ServerWriter< ::routeguide::Feature>* writer) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
    void RequestListFeatures(::grpc::ServerContext* context, ::routeguide::Rectangle* request, ::grpc::ServerAsyncWriter< ::routeguide::Feature>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
      ::grpc::Service::RequestAsyncServerStreaming(1, context, request, writer, new_call_cq, notification_cq, tag);
    }
  };
  template 
  class WithAsyncMethod_RecordRoute : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithAsyncMethod_RecordRoute() {
      ::grpc::Service::MarkMethodAsync(2);
    }
    ~WithAsyncMethod_RecordRoute() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status RecordRoute(::grpc::ServerContext* context, ::grpc::ServerReader< ::routeguide::Point>* reader, ::routeguide::RouteSummary* response) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
    void RequestRecordRoute(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::routeguide::RouteSummary, ::routeguide::Point>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
      ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag);
    }
  };
  template 
  class WithAsyncMethod_RouteChat : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithAsyncMethod_RouteChat() {
      ::grpc::Service::MarkMethodAsync(3);
    }
    ~WithAsyncMethod_RouteChat() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status RouteChat(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* stream) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
    void RequestRouteChat(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
      ::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag);
    }
  };
  typedef WithAsyncMethod_GetFeature > > > AsyncService;
  template 
  class WithGenericMethod_GetFeature : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithGenericMethod_GetFeature() {
      ::grpc::Service::MarkMethodGeneric(0);
    }
    ~WithGenericMethod_GetFeature() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status GetFeature(::grpc::ServerContext* context, const ::routeguide::Point* request, ::routeguide::Feature* response) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
  };
  template 
  class WithGenericMethod_ListFeatures : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithGenericMethod_ListFeatures() {
      ::grpc::Service::MarkMethodGeneric(1);
    }
    ~WithGenericMethod_ListFeatures() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status ListFeatures(::grpc::ServerContext* context, const ::routeguide::Rectangle* request, ::grpc::ServerWriter< ::routeguide::Feature>* writer) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
  };
  template 
  class WithGenericMethod_RecordRoute : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithGenericMethod_RecordRoute() {
      ::grpc::Service::MarkMethodGeneric(2);
    }
    ~WithGenericMethod_RecordRoute() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status RecordRoute(::grpc::ServerContext* context, ::grpc::ServerReader< ::routeguide::Point>* reader, ::routeguide::RouteSummary* response) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
  };
  template 
  class WithGenericMethod_RouteChat : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithGenericMethod_RouteChat() {
      ::grpc::Service::MarkMethodGeneric(3);
    }
    ~WithGenericMethod_RouteChat() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable synchronous version of this method
    ::grpc::Status RouteChat(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* stream) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
  };
  template 
  class WithStreamedUnaryMethod_GetFeature : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithStreamedUnaryMethod_GetFeature() {
      ::grpc::Service::MarkMethodStreamed(0,
        new ::grpc::StreamedUnaryHandler< ::routeguide::Point, ::routeguide::Feature>(std::bind(&WithStreamedUnaryMethod_GetFeature::StreamedGetFeature, this, std::placeholders::_1, std::placeholders::_2)));
    }
    ~WithStreamedUnaryMethod_GetFeature() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable regular version of this method
    ::grpc::Status GetFeature(::grpc::ServerContext* context, const ::routeguide::Point* request, ::routeguide::Feature* response) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
    // replace default version of method with streamed unary
    virtual ::grpc::Status StreamedGetFeature(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::routeguide::Point,::routeguide::Feature>* server_unary_streamer) = 0;
  };
  typedef WithStreamedUnaryMethod_GetFeature StreamedUnaryService;
  template 
  class WithSplitStreamingMethod_ListFeatures : public BaseClass {
   private:
    void BaseClassMustBeDerivedFromService(const Service *service) {}
   public:
    WithSplitStreamingMethod_ListFeatures() {
      ::grpc::Service::MarkMethodStreamed(1,
        new ::grpc::SplitServerStreamingHandler< ::routeguide::Rectangle, ::routeguide::Feature>(std::bind(&WithSplitStreamingMethod_ListFeatures::StreamedListFeatures, this, std::placeholders::_1, std::placeholders::_2)));
    }
    ~WithSplitStreamingMethod_ListFeatures() override {
      BaseClassMustBeDerivedFromService(this);
    }
    // disable regular version of this method
    ::grpc::Status ListFeatures(::grpc::ServerContext* context, const ::routeguide::Rectangle* request, ::grpc::ServerWriter< ::routeguide::Feature>* writer) final override {
      abort();
      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
    }
    // replace default version of method with split streamed
    virtual ::grpc::Status StreamedListFeatures(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< ::routeguide::Rectangle,::routeguide::Feature>* server_split_streamer) = 0;
  };
  typedef WithSplitStreamingMethod_ListFeatures SplitStreamedService;
  typedef WithStreamedUnaryMethod_GetFeature > StreamedService;
};

}  // namespace routeguide


#endif  // GRPC_route_5fguide_2eproto__INCLUDED

route_guide.grpc.pb.cc
// Generated by the gRPC C++ plugin.
// If you make any local change, they will be lost.
// source: route_guide.proto

#include "route_guide.pb.h"
#include "route_guide.grpc.pb.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
namespace routeguide {

static const char* RouteGuide_method_names[] = {
  "/routeguide.RouteGuide/GetFeature",
  "/routeguide.RouteGuide/ListFeatures",
  "/routeguide.RouteGuide/RecordRoute",
  "/routeguide.RouteGuide/RouteChat",
};

std::unique_ptr< RouteGuide::Stub> RouteGuide::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
  std::unique_ptr< RouteGuide::Stub> stub(new RouteGuide::Stub(channel));
  return stub;
}

RouteGuide::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
  : channel_(channel), rpcmethod_GetFeature_(RouteGuide_method_names[0], ::grpc::RpcMethod::NORMAL_RPC, channel)
  , rpcmethod_ListFeatures_(RouteGuide_method_names[1], ::grpc::RpcMethod::SERVER_STREAMING, channel)
  , rpcmethod_RecordRoute_(RouteGuide_method_names[2], ::grpc::RpcMethod::CLIENT_STREAMING, channel)
  , rpcmethod_RouteChat_(RouteGuide_method_names[3], ::grpc::RpcMethod::BIDI_STREAMING, channel)
  {}

::grpc::Status RouteGuide::Stub::GetFeature(::grpc::ClientContext* context, const ::routeguide::Point& request, ::routeguide::Feature* response) {
  return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_GetFeature_, context, request, response);
}

::grpc::ClientAsyncResponseReader< ::routeguide::Feature>* RouteGuide::Stub::AsyncGetFeatureRaw(::grpc::ClientContext* context, const ::routeguide::Point& request, ::grpc::CompletionQueue* cq) {
  return new ::grpc::ClientAsyncResponseReader< ::routeguide::Feature>(channel_.get(), cq, rpcmethod_GetFeature_, context, request);
}

::grpc::ClientReader< ::routeguide::Feature>* RouteGuide::Stub::ListFeaturesRaw(::grpc::ClientContext* context, const ::routeguide::Rectangle& request) {
  return new ::grpc::ClientReader< ::routeguide::Feature>(channel_.get(), rpcmethod_ListFeatures_, context, request);
}

::grpc::ClientAsyncReader< ::routeguide::Feature>* RouteGuide::Stub::AsyncListFeaturesRaw(::grpc::ClientContext* context, const ::routeguide::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag) {
  return new ::grpc::ClientAsyncReader< ::routeguide::Feature>(channel_.get(), cq, rpcmethod_ListFeatures_, context, request, tag);
}

::grpc::ClientWriter< ::routeguide::Point>* RouteGuide::Stub::RecordRouteRaw(::grpc::ClientContext* context, ::routeguide::RouteSummary* response) {
  return new ::grpc::ClientWriter< ::routeguide::Point>(channel_.get(), rpcmethod_RecordRoute_, context, response);
}

::grpc::ClientAsyncWriter< ::routeguide::Point>* RouteGuide::Stub::AsyncRecordRouteRaw(::grpc::ClientContext* context, ::routeguide::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag) {
  return new ::grpc::ClientAsyncWriter< ::routeguide::Point>(channel_.get(), cq, rpcmethod_RecordRoute_, context, response, tag);
}

::grpc::ClientReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* RouteGuide::Stub::RouteChatRaw(::grpc::ClientContext* context) {
  return new ::grpc::ClientReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>(channel_.get(), rpcmethod_RouteChat_, context);
}

::grpc::ClientAsyncReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* RouteGuide::Stub::AsyncRouteChatRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) {
  return new ::grpc::ClientAsyncReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>(channel_.get(), cq, rpcmethod_RouteChat_, context, tag);
}

RouteGuide::Service::Service() {
  AddMethod(new ::grpc::RpcServiceMethod(
      RouteGuide_method_names[0],
      ::grpc::RpcMethod::NORMAL_RPC,
      new ::grpc::RpcMethodHandler< RouteGuide::Service, ::routeguide::Point, ::routeguide::Feature>(
          std::mem_fn(&RouteGuide::Service::GetFeature), this)));
  AddMethod(new ::grpc::RpcServiceMethod(
      RouteGuide_method_names[1],
      ::grpc::RpcMethod::SERVER_STREAMING,
      new ::grpc::ServerStreamingHandler< RouteGuide::Service, ::routeguide::Rectangle, ::routeguide::Feature>(
          std::mem_fn(&RouteGuide::Service::ListFeatures), this)));
  AddMethod(new ::grpc::RpcServiceMethod(
      RouteGuide_method_names[2],
      ::grpc::RpcMethod::CLIENT_STREAMING,
      new ::grpc::ClientStreamingHandler< RouteGuide::Service, ::routeguide::Point, ::routeguide::RouteSummary>(
          std::mem_fn(&RouteGuide::Service::RecordRoute), this)));
  AddMethod(new ::grpc::RpcServiceMethod(
      RouteGuide_method_names[3],
      ::grpc::RpcMethod::BIDI_STREAMING,
      new ::grpc::BidiStreamingHandler< RouteGuide::Service, ::routeguide::RouteNote, ::routeguide::RouteNote>(
          std::mem_fn(&RouteGuide::Service::RouteChat), this)));
}

RouteGuide::Service::~Service() {
}

::grpc::Status RouteGuide::Service::GetFeature(::grpc::ServerContext* context, const ::routeguide::Point* request, ::routeguide::Feature* response) {
  (void) context;
  (void) request;
  (void) response;
  return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}

::grpc::Status RouteGuide::Service::ListFeatures(::grpc::ServerContext* context, const ::routeguide::Rectangle* request, ::grpc::ServerWriter< ::routeguide::Feature>* writer) {
  (void) context;
  (void) request;
  (void) writer;
  return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}

::grpc::Status RouteGuide::Service::RecordRoute(::grpc::ServerContext* context, ::grpc::ServerReader< ::routeguide::Point>* reader, ::routeguide::RouteSummary* response) {
  (void) context;
  (void) reader;
  (void) response;
  return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}

::grpc::Status RouteGuide::Service::RouteChat(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::routeguide::RouteNote, ::routeguide::RouteNote>* stream) {
  (void) context;
  (void) stream;
  return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}


}  // namespace routeguide


创建服务器

  • 实现我们服务定义的生成的服务接口:做我们的服务的实际的“工作”。
  • 运行一个 gRPC 服务器,监听来自客户端的请求并返回服务的响应。
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include "helper.h"
#ifdef BAZEL_BUILD
#include "examples/protos/route_guide.grpc.pb.h"
#else
#include "route_guide.grpc.pb.h"
#endif

using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
using grpc::ServerReader;
using grpc::ServerReaderWriter;
using grpc::ServerWriter;
using grpc::Status;
using routeguide::Point;
using routeguide::Feature;
using routeguide::Rectangle;
using routeguide::RouteSummary;
using routeguide::RouteNote;
using routeguide::RouteGuide;
using std::chrono::system_clock;


float ConvertToRadians(float num) {
  return num * 3.1415926 /180;
}

// The formula is based on http://mathforum.org/library/drmath/view/51879.html
float GetDistance(const Point& start, const Point& end) {
  const float kCoordFactor = 10000000.0;
  float lat_1 = start.latitude() / kCoordFactor;
  float lat_2 = end.latitude() / kCoordFactor;
  float lon_1 = start.longitude() / kCoordFactor;
  float lon_2 = end.longitude() / kCoordFactor;
  float lat_rad_1 = ConvertToRadians(lat_1);
  float lat_rad_2 = ConvertToRadians(lat_2);
  float delta_lat_rad = ConvertToRadians(lat_2-lat_1);
  float delta_lon_rad = ConvertToRadians(lon_2-lon_1);

  float a = pow(sin(delta_lat_rad/2), 2) + cos(lat_rad_1) * cos(lat_rad_2) *
            pow(sin(delta_lon_rad/2), 2);
  float c = 2 * atan2(sqrt(a), sqrt(1-a));
  int R = 6371000; // metres

  return R * c;
}

std::string GetFeatureName(const Point& point,
                           const std::vector& feature_list) {
  for (const Feature& f : feature_list) {
    if (f.location().latitude() == point.latitude() &&
        f.location().longitude() == point.longitude()) {
      return f.name();
    }
  }
  return "";
}

/* RouteGuideImpl实现了生成的 RouteGuide::Service 接口的类 */
class RouteGuideImpl final : public RouteGuide::Service {
 public:
  explicit RouteGuideImpl(const std::string& db) {
    routeguide::ParseDb(db, &feature_list_);
  }

  /*从客户端拿到一个 Point 然后将对应的特性返回给数据库中的 Feature,
  在这个方法中,我们用适当的信息填充 Feature,然后返回OK的状态,告诉 gRPC 我们已经处理完 RPC,并且 	Feature 可以返回给客户端。*/
  Status GetFeature(ServerContext* context, const Point* point,
                    Feature* feature) override {
    feature->set_name(GetFeatureName(*point, feature_list_));
    feature->mutable_location()->CopyFrom(*point);
    return Status::OK;
  }

	/*ListFeatures 是一个服务器端的流式 RPC,因此我们需要给客户端返回多个 Feature*/
  Status ListFeatures(ServerContext* context,
                      const routeguide::Rectangle* rectangle,
                      ServerWriter* writer) override {
    auto lo = rectangle->lo();
    auto hi = rectangle->hi();
    long left = (std::min)(lo.longitude(), hi.longitude());
    long right = (std::max)(lo.longitude(), hi.longitude());
    long top = (std::max)(lo.latitude(), hi.latitude());
    long bottom = (std::min)(lo.latitude(), hi.latitude());
    for (const Feature& f : feature_list_) {
      if (f.location().longitude() >= left &&
          f.location().longitude() <= right &&
          f.location().latitude() >= bottom &&
          f.location().latitude() <= top) {
        writer->Write(f);
      }
    }
    return Status::OK;
  }

/*这次我们拿到的是一个ServerReader而不是请求对象和单一的响应。我们使用 ServerReader 的 Read() 方法去重复的往请求对象(在这个场景下是一个 Point)读取客户端的请求直到没有更多的消息:在每次调用后,服务器需要检查 Read() 的返回值。如果返回值为 true,流仍然存在,它就可以继续读取;如果返回值为 false,则表明消息流已经停止。*/
  Status RecordRoute(ServerContext* context, ServerReader* reader,
                     RouteSummary* summary) override {
    Point point;
    int point_count = 0;
    int feature_count = 0;
    float distance = 0.0;
    Point previous;

    system_clock::time_point start_time = system_clock::now();
    while (reader->Read(&point)) {
      point_count++;
      if (!GetFeatureName(point, feature_list_).empty()) {
        feature_count++;
      }
      if (point_count != 1) {
        distance += GetDistance(previous, point);
      }
      previous = point;
    }
    system_clock::time_point end_time = system_clock::now();
    summary->set_point_count(point_count);
    summary->set_feature_count(feature_count);
    summary->set_distance(static_cast(distance));
    auto secs = std::chrono::duration_cast(
        end_time - start_time);
    summary->set_elapsed_time(secs.count());

    return Status::OK;
  }

  Status RouteChat(ServerContext* context,
                   ServerReaderWriter* stream) override {
    RouteNote note;
    while (stream->Read(¬e)) {
      std::unique_lock lock(mu_);
      for (const RouteNote& n : received_notes_) {
        if (n.location().latitude() == note.location().latitude() &&
            n.location().longitude() == note.location().longitude()) {
          stream->Write(n);
        }
      }
      received_notes_.push_back(note);
    }

    return Status::OK;
  }

 private:
  std::vector feature_list_;
  std::mutex mu_;
  std::vector received_notes_;
};

void RunServer(const std::string& db_path) {
  std::string server_address("0.0.0.0:50051");
  RouteGuideImpl service(db_path);

  ServerBuilder builder;
  builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
  builder.RegisterService(&service);
  std::unique_ptr server(builder.BuildAndStart());
  std::cout << "Server listening on " << server_address << std::endl;
  server->Wait();
}

int main(int argc, char** argv) {
  // Expect only arg: --db_path=path/to/route_guide_db.json.
  std::string db = routeguide::GetDbFileContent(argc, argv);
  RunServer(db);

  return 0;
}

创建客户端

#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include "helper.h"
#ifdef BAZEL_BUILD
#include "examples/protos/route_guide.grpc.pb.h"
#else
#include "route_guide.grpc.pb.h"
#endif

using grpc::Channel;
using grpc::ClientContext;
using grpc::ClientReader;
using grpc::ClientReaderWriter;
using grpc::ClientWriter;
using grpc::Status;
using routeguide::Point;
using routeguide::Feature;
using routeguide::Rectangle;
using routeguide::RouteSummary;
using routeguide::RouteNote;
using routeguide::RouteGuide;

Point MakePoint(long latitude, long longitude) {
  Point p;
  p.set_latitude(latitude);
  p.set_longitude(longitude);
  return p;
}

Feature MakeFeature(const std::string& name,
                    long latitude, long longitude) {
  Feature f;
  f.set_name(name);
  f.mutable_location()->CopyFrom(MakePoint(latitude, longitude));
  return f;
}

RouteNote MakeRouteNote(const std::string& message,
                        long latitude, long longitude) {
  RouteNote n;
  n.set_message(message);
  n.mutable_location()->CopyFrom(MakePoint(latitude, longitude));
  return n;
}

class RouteGuideClient {
/*利用channel,使用从.proto中生成的RouteGuide类提供的NewStub方法去创建存根*/
 public:
  RouteGuideClient(std::shared_ptr channel, const std::string& db)
      : stub_(RouteGuide::NewStub(channel)) {
    routeguide::ParseDb(db, &feature_list_);
  }

  void GetFeature() {
    Point point;
    Feature feature;
    point = MakePoint(409146138, -746188906);
    GetOneFeature(point, &feature);
    point = MakePoint(0, 0);
    GetOneFeature(point, &feature);
  }

  void ListFeatures() {
    routeguide::Rectangle rect;
    Feature feature;
    ClientContext context;

    rect.mutable_lo()->set_latitude(400000000);
    rect.mutable_lo()->set_longitude(-750000000);
    rect.mutable_hi()->set_latitude(420000000);
    rect.mutable_hi()->set_longitude(-730000000);
    std::cout << "Looking for features between 40, -75 and 42, -73"
              << std::endl;

    std::unique_ptr > reader(
        stub_->ListFeatures(&context, rect));
    while (reader->Read(&feature)) {
      std::cout << "Found feature called "
                << feature.name() << " at "
                << feature.location().latitude()/kCoordFactor_ << ", "
                << feature.location().longitude()/kCoordFactor_ << std::endl;
    }
    Status status = reader->Finish();
    if (status.ok()) {
      std::cout << "ListFeatures rpc succeeded." << std::endl;
    } else {
      std::cout << "ListFeatures rpc failed." << std::endl;
    }
  }

  void RecordRoute() {
    Point point;
    RouteSummary stats;
    ClientContext context;
    const int kPoints = 10;
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();

    std::default_random_engine generator(seed);
    std::uniform_int_distribution feature_distribution(
        0, feature_list_.size() - 1);
    std::uniform_int_distribution delay_distribution(
        500, 1500);

    std::unique_ptr > writer(
        stub_->RecordRoute(&context, &stats));
    for (int i = 0; i < kPoints; i++) {
      const Feature& f = feature_list_[feature_distribution(generator)];
      std::cout << "Visiting point "
                << f.location().latitude()/kCoordFactor_ << ", "
                << f.location().longitude()/kCoordFactor_ << std::endl;
      if (!writer->Write(f.location())) {
        // Broken stream.
        break;
      }
      std::this_thread::sleep_for(std::chrono::milliseconds(
          delay_distribution(generator)));
    }
    writer->WritesDone();
    Status status = writer->Finish();
    if (status.ok()) {
      std::cout << "Finished trip with " << stats.point_count() << " points\n"
                << "Passed " << stats.feature_count() << " features\n"
                << "Travelled " << stats.distance() << " meters\n"
                << "It took " << stats.elapsed_time() << " seconds"
                << std::endl;
    } else {
      std::cout << "RecordRoute rpc failed." << std::endl;
    }
  }

  void RouteChat() {
    ClientContext context;

    std::shared_ptr > stream(
        stub_->RouteChat(&context));

    std::thread writer([stream]() {
      std::vector notes{
        MakeRouteNote("First message", 0, 0),
        MakeRouteNote("Second message", 0, 1),
        MakeRouteNote("Third message", 1, 0),
        MakeRouteNote("Fourth message", 0, 0)};
      for (const RouteNote& note : notes) {
        std::cout << "Sending message " << note.message()
                  << " at " << note.location().latitude() << ", "
                  << note.location().longitude() << std::endl;
        stream->Write(note);
      }
      stream->WritesDone();
    });

    RouteNote server_note;
    while (stream->Read(&server_note)) {
      std::cout << "Got message " << server_note.message()
                << " at " << server_note.location().latitude() << ", "
                << server_note.location().longitude() << std::endl;
    }
    writer.join();
    Status status = stream->Finish();
    if (!status.ok()) {
      std::cout << "RouteChat rpc failed." << std::endl;
    }
  }

 private:

  bool GetOneFeature(const Point& point, Feature* feature) {
    ClientContext context;
    Status status = stub_->GetFeature(&context, point, feature);
    if (!status.ok()) {
      std::cout << "GetFeature rpc failed." << std::endl;
      return false;
    }
    if (!feature->has_location()) {
      std::cout << "Server returns incomplete feature." << std::endl;
      return false;
    }
    if (feature->name().empty()) {
      std::cout << "Found no feature at "
                << feature->location().latitude()/kCoordFactor_ << ", "
                << feature->location().longitude()/kCoordFactor_ << std::endl;
    } else {
      std::cout << "Found feature called " << feature->name()  << " at "
                << feature->location().latitude()/kCoordFactor_ << ", "
                << feature->location().longitude()/kCoordFactor_ << std::endl;
    }
    return true;
  }

  const float kCoordFactor_ = 10000000.0;
  std::unique_ptr stub_;
  std::vector feature_list_;
};

int main(int argc, char** argv) {
  // Expect only arg: --db_path=path/to/route_guide_db.json.
  std::string db = routeguide::GetDbFileContent(argc, argv);
  /*为我们的存根创建一个gRPC channel,指定我们想连接的服务器地址和端口,以及 channel 相关的参数*/
  RouteGuideClient guide(
      grpc::CreateChannel("localhost:50051",
                          grpc::InsecureChannelCredentials()),
      db);

  std::cout << "-------------- GetFeature --------------" << std::endl;
  guide.GetFeature();
  std::cout << "-------------- ListFeatures --------------" << std::endl;
  guide.ListFeatures();
  std::cout << "-------------- RecordRoute --------------" << std::endl;
  guide.RecordRoute();
  std::cout << "-------------- RouteChat --------------" << std::endl;
  guide.RouteChat();

  return 0;
}

你可能感兴趣的:(服务器)