17 #ifndef CYBER_MESSAGE_PROTOBUF_FACTORY_H_ 18 #define CYBER_MESSAGE_PROTOBUF_FACTORY_H_ 25 #include "google/protobuf/compiler/parser.h" 26 #include "google/protobuf/descriptor.h" 27 #include "google/protobuf/dynamic_message.h" 28 #include "google/protobuf/io/tokenizer.h" 30 #include "cyber/proto/proto_desc.pb.h" 38 using apollo::cyber::proto::ProtoDesc;
39 using google::protobuf::Descriptor;
40 using google::protobuf::DescriptorPool;
41 using google::protobuf::DynamicMessageFactory;
42 using google::protobuf::FileDescriptor;
43 using google::protobuf::FileDescriptorProto;
45 class ErrorCollector :
public google::protobuf::DescriptorPool::ErrorCollector {
47 google::protobuf::DescriptorPool::ErrorCollector::ErrorLocation;
48 void AddError(
const std::string& filename,
const std::string& element_name,
49 const google::protobuf::Message* descriptor,
50 ErrorLocation location,
const std::string& message)
override;
52 void AddWarning(
const std::string& filename,
const std::string& element_name,
53 const google::protobuf::Message* descriptor,
54 ErrorLocation location,
const std::string& message)
override;
64 bool RegisterPythonMessage(
const std::string& proto_str);
76 std::string* desc_str);
80 std::string* desc_str);
87 google::protobuf::Message* GenerateMessageByType(
88 const std::string& type)
const;
91 const Descriptor* FindMessageTypeByName(
const std::string& type)
const;
94 const google::protobuf::ServiceDescriptor* FindServiceByName(
95 const std::string& name)
const;
97 void GetPythonDesc(
const std::string& type, std::string* desc_str);
101 google::protobuf::Message* GetMessageByGeneratedType(
102 const std::string& type)
const;
103 static bool GetProtoDesc(
const FileDescriptor* file_desc,
104 ProtoDesc* proto_desc);
106 std::mutex register_mutex_;
107 std::unique_ptr<DescriptorPool> pool_ =
nullptr;
108 std::unique_ptr<DynamicMessageFactory> factory_ =
nullptr;
117 #endif // CYBER_MESSAGE_PROTOBUF_FACTORY_H_ PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool RegisterMessage(const MessageT &message)
Definition: protobuf_traits.h:68
#define DECLARE_SINGLETON(classname)
Definition: macros.h:52
void GetDescriptorString(const std::string &type, std::string *desc_str)
Definition: message_traits.h:237
Definition: protobuf_factory.h:57
Definition: protobuf_factory.h:45