From ac85c41fdaf238fa5d8acde4897d31c192227d74 Mon Sep 17 00:00:00 2001 From: wangguibao Date: Thu, 28 Mar 2019 20:11:15 +0800 Subject: [PATCH] Fix pdcodegen --- pdcodegen/src/pdcodegen.cpp | 62 +++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/pdcodegen/src/pdcodegen.cpp b/pdcodegen/src/pdcodegen.cpp index ba22738a..5d16c0e9 100644 --- a/pdcodegen/src/pdcodegen.cpp +++ b/pdcodegen/src/pdcodegen.cpp @@ -95,38 +95,40 @@ class PdsCodeGenerator : public CodeGenerator { const string body = strip_proto(file->name()) + ".pb.cc"; bool include_inserted = false; for (int i = 0; i < file->service_count(); ++i) { - const ServiceDescriptor* descriptor = file->service(i); - if (!descriptor) { - *error = "get descriptor failed"; - return false; - } - pds::PaddleServiceOption options = - descriptor->options().GetExtension(pds::options); - bool generate_impl = options.generate_impl(); - bool generate_stub = options.generate_stub(); - if (!generate_impl && !generate_stub) { - return true; - } - if (!include_inserted) { - boost::scoped_ptr output( - context->OpenForInsert(header, "includes")); - google::protobuf::io::Printer printer(output.get(), '$'); - if (generate_impl) { - printer.Print("#include \"predictor/common/inner_common.h\"\n"); - printer.Print("#include \"predictor/framework/service.h\"\n"); - printer.Print("#include \"predictor/framework/manager.h\"\n"); - printer.Print("#include \"predictor/framework/service_manager.h\"\n"); + const ServiceDescriptor* descriptor = file->service(i); + if (!descriptor) { + *error = "get descriptor failed"; + return false; } - if (generate_stub) { - printer.Print("#include \n"); - printer.Print("#include \"sdk-cpp/include/factory.h\"\n"); - printer.Print("#include \"sdk-cpp/include/stub.h\"\n"); - printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n"); + pds::PaddleServiceOption options = + descriptor->options().GetExtension(pds::options); + bool generate_impl = options.generate_impl(); + bool generate_stub = options.generate_stub(); + if (!generate_impl && !generate_stub) { + return true; } - include_inserted = true; - } - const std::string& class_name = descriptor->name(); - const std::string& service_name = descriptor->name(); + + if (!include_inserted) { + boost::scoped_ptr output( + context->OpenForInsert(header, "includes")); + google::protobuf::io::Printer printer(output.get(), '$'); + if (generate_impl) { + printer.Print("#include \"predictor/common/inner_common.h\"\n"); + printer.Print("#include \"predictor/framework/service.h\"\n"); + printer.Print("#include \"predictor/framework/manager.h\"\n"); + printer.Print("#include \"predictor/framework/service_manager.h\"\n"); + } + if (generate_stub) { + printer.Print("#include \n"); + printer.Print("#include \"sdk-cpp/include/factory.h\"\n"); + printer.Print("#include \"sdk-cpp/include/stub.h\"\n"); + printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n"); + } + include_inserted = true; + } + + const std::string& class_name = descriptor->name(); + const std::string& service_name = descriptor->name(); // xxx.ph.h { if (generate_impl) { -- GitLab