more cleanup
This commit is contained in:
parent
178fdf82e1
commit
dbc06dd84c
|
|
@ -65,6 +65,7 @@ std::string GetDbFileContent(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseDb(const std::string& db, std::vector<Feature>* feature_list) {
|
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 {
|
class RouteGuideClient {
|
||||||
public:
|
public:
|
||||||
RouteGuideClient(std::shared_ptr<ChannelInterface> channel)
|
RouteGuideClient(std::shared_ptr<ChannelInterface> channel,
|
||||||
: stub_(RouteGuide::NewStub(channel)) {}
|
const std::string& db)
|
||||||
|
: stub_(RouteGuide::NewStub(channel)) {
|
||||||
|
examples::ParseDb(db, &feature_list_);
|
||||||
|
}
|
||||||
|
|
||||||
void GetFeature() {
|
void GetFeature() {
|
||||||
Point point;
|
Point point;
|
||||||
|
|
@ -201,10 +204,6 @@ class RouteGuideClient {
|
||||||
|
|
||||||
void Shutdown() { stub_.reset(); }
|
void Shutdown() { stub_.reset(); }
|
||||||
|
|
||||||
void FillFeatureList(const std::string& db) {
|
|
||||||
examples::ParseDb(db, &feature_list_);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool GetOneFeature(const Point& point, Feature* feature) {
|
bool GetOneFeature(const Point& point, Feature* feature) {
|
||||||
|
|
@ -238,10 +237,10 @@ class RouteGuideClient {
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
grpc_init();
|
grpc_init();
|
||||||
|
|
||||||
RouteGuideClient guide(
|
|
||||||
grpc::CreateChannel("localhost:50051", ChannelArguments()));
|
|
||||||
std::string db = examples::GetDbFileContent(argc, argv);
|
std::string db = examples::GetDbFileContent(argc, argv);
|
||||||
guide.FillFeatureList(db);
|
RouteGuideClient guide(
|
||||||
|
grpc::CreateChannel("localhost:50051", ChannelArguments()),
|
||||||
|
db);
|
||||||
|
|
||||||
guide.GetFeature();
|
guide.GetFeature();
|
||||||
guide.ListFeatures();
|
guide.ListFeatures();
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ std::string GetFeatureName(const Point& point,
|
||||||
|
|
||||||
class RouteGuideImpl final : public RouteGuide::Service {
|
class RouteGuideImpl final : public RouteGuide::Service {
|
||||||
public:
|
public:
|
||||||
RouteGuideImpl(const std::string& db) {
|
explicit RouteGuideImpl(const std::string& db) {
|
||||||
examples::ParseDb(db, &feature_list_);
|
examples::ParseDb(db, &feature_list_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue