more cleanup

pull/3109/head
Yang Gao 10 years ago
parent 178fdf82e1
commit dbc06dd84c
  1. 1
      cpp/route_guide/helper.cc
  2. 17
      cpp/route_guide/route_guide_client.cc
  3. 2
      cpp/route_guide/route_guide_server.cc

@ -65,6 +65,7 @@ std::string GetDbFileContent(int argc, char** argv) {
}
void ParseDb(const std::string& db, std::vector<Feature>* feature_list) {
feature_list->clear();
}

@ -87,8 +87,11 @@ RouteNote MakeRouteNote(const std::string& message,
class RouteGuideClient {
public:
RouteGuideClient(std::shared_ptr<ChannelInterface> channel)
: stub_(RouteGuide::NewStub(channel)) {}
RouteGuideClient(std::shared_ptr<ChannelInterface> channel,
const std::string& db)
: stub_(RouteGuide::NewStub(channel)) {
examples::ParseDb(db, &feature_list_);
}
void GetFeature() {
Point point;
@ -201,10 +204,6 @@ class RouteGuideClient {
void Shutdown() { stub_.reset(); }
void FillFeatureList(const std::string& db) {
examples::ParseDb(db, &feature_list_);
}
private:
bool GetOneFeature(const Point& point, Feature* feature) {
@ -238,10 +237,10 @@ class RouteGuideClient {
int main(int argc, char** argv) {
grpc_init();
RouteGuideClient guide(
grpc::CreateChannel("localhost:50051", ChannelArguments()));
std::string db = examples::GetDbFileContent(argc, argv);
guide.FillFeatureList(db);
RouteGuideClient guide(
grpc::CreateChannel("localhost:50051", ChannelArguments()),
db);
guide.GetFeature();
guide.ListFeatures();

@ -100,7 +100,7 @@ std::string GetFeatureName(const Point& point,
class RouteGuideImpl final : public RouteGuide::Service {
public:
RouteGuideImpl(const std::string& db) {
explicit RouteGuideImpl(const std::string& db) {
examples::ParseDb(db, &feature_list_);
}

Loading…
Cancel
Save