From dbc06dd84c80d0f2211f24d65d786367e140e1cb Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Mon, 23 Feb 2015 14:26:28 -0800 Subject: [PATCH] more cleanup --- cpp/route_guide/helper.cc | 1 + cpp/route_guide/route_guide_client.cc | 17 ++++++++--------- cpp/route_guide/route_guide_server.cc | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cpp/route_guide/helper.cc b/cpp/route_guide/helper.cc index a4be8bf..8c04489 100644 --- a/cpp/route_guide/helper.cc +++ b/cpp/route_guide/helper.cc @@ -65,6 +65,7 @@ std::string GetDbFileContent(int argc, char** argv) { } void ParseDb(const std::string& db, std::vector* feature_list) { + feature_list->clear(); } diff --git a/cpp/route_guide/route_guide_client.cc b/cpp/route_guide/route_guide_client.cc index fd3d98e..01c48c9 100644 --- a/cpp/route_guide/route_guide_client.cc +++ b/cpp/route_guide/route_guide_client.cc @@ -87,8 +87,11 @@ RouteNote MakeRouteNote(const std::string& message, class RouteGuideClient { public: - RouteGuideClient(std::shared_ptr channel) - : stub_(RouteGuide::NewStub(channel)) {} + RouteGuideClient(std::shared_ptr 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(); diff --git a/cpp/route_guide/route_guide_server.cc b/cpp/route_guide/route_guide_server.cc index 38cd64b..62fee24 100644 --- a/cpp/route_guide/route_guide_server.cc +++ b/cpp/route_guide/route_guide_server.cc @@ -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_); }