#include <protobuf_factory.h>
◆ ~ProtobufFactory()
apollo::cyber::message::ProtobufFactory::~ProtobufFactory |
( |
| ) |
|
◆ FindMessageTypeByFile()
const Descriptor * apollo::cyber::message::ProtobufFactory::FindMessageTypeByFile |
( |
const FileDescriptorProto & |
file_desc_proto | ) |
|
在文件 protobuf_factory.cc 第 239 行定义.
240 {
241 const std::string& scope = file_desc_proto.package();
242 std::string type;
243 if (file_desc_proto.message_type_size()) {
244 type = scope + "." + file_desc_proto.message_type(0).name();
245 }
246 const google::protobuf::Descriptor* descriptor =
247 pool_->FindMessageTypeByName(type);
248 return descriptor;
249}
◆ FindMessageTypeByName()
const Descriptor * apollo::cyber::message::ProtobufFactory::FindMessageTypeByName |
( |
const std::string & |
type | ) |
const |
◆ FindServiceByName()
const google::protobuf::ServiceDescriptor * apollo::cyber::message::ProtobufFactory::FindServiceByName |
( |
const std::string & |
name | ) |
const |
◆ GenerateMessageByType()
google::protobuf::Message * apollo::cyber::message::ProtobufFactory::GenerateMessageByType |
( |
const std::string & |
type | ) |
const |
在文件 protobuf_factory.cc 第 186 行定义.
187 {
188 google::protobuf::Message* message = GetMessageByGeneratedType(type);
189 if (message != nullptr) {
190 return message;
191 }
192
193 const google::protobuf::Descriptor* descriptor =
194 pool_->FindMessageTypeByName(type);
195 if (descriptor == nullptr) {
196 AERROR <<
"cannot find [" << type <<
"] descriptor";
197 return nullptr;
198 }
199
200 const google::protobuf::Message* prototype =
201 factory_->GetPrototype(descriptor);
202 if (prototype == nullptr) {
203 AERROR <<
"cannot find [" << type <<
"] prototype";
204 return nullptr;
205 }
206
207 return prototype->New();
208}
◆ GetDescriptorString() [1/3]
void apollo::cyber::message::ProtobufFactory::GetDescriptorString |
( |
const Descriptor * |
desc, |
|
|
std::string * |
desc_str |
|
) |
| |
|
static |
在文件 protobuf_factory.cc 第 125 行定义.
126 {
127 ProtoDesc proto_desc;
128 if (!GetProtoDesc(desc->file(), &proto_desc)) {
129 AERROR <<
"Failed to get descriptor from message";
130 return;
131 }
132
133 if (!proto_desc.SerializeToString(desc_str)) {
134 AERROR <<
"Failed to get descriptor from message";
135 }
136}
◆ GetDescriptorString() [2/3]
void apollo::cyber::message::ProtobufFactory::GetDescriptorString |
( |
const google::protobuf::Message & |
message, |
|
|
std::string * |
desc_str |
|
) |
| |
|
static |
在文件 protobuf_factory.cc 第 138 行定义.
139 {
140 const Descriptor* desc = message.GetDescriptor();
142}
static void GetDescriptorString(const google::protobuf::Message &message, std::string *desc_str)
◆ GetDescriptorString() [3/3]
void apollo::cyber::message::ProtobufFactory::GetDescriptorString |
( |
const std::string & |
type, |
|
|
std::string * |
desc_str |
|
) |
| |
在文件 protobuf_factory.cc 第 155 行定义.
156 {
157 auto desc = DescriptorPool::generated_pool()->FindMessageTypeByName(type);
158 if (desc != nullptr) {
160 }
161
162 desc = pool_->FindMessageTypeByName(type);
163 if (desc == nullptr) {
164 return;
165 }
167}
◆ GetProtoPath()
void apollo::cyber::message::ProtobufFactory::GetProtoPath |
( |
const std::string & |
type, |
|
|
std::string & |
location |
|
) |
| |
在文件 protobuf_factory.cc 第 169 行定义.
170 {
171 auto desc = DescriptorPool::generated_pool()->FindMessageTypeByName(type);
172 if (desc != nullptr) {
173 location = (desc->file())->name();
174 return;
175 }
176
177 desc = pool_->FindMessageTypeByName(type);
178 if (desc == nullptr) {
179 return;
180 }
181 location = (desc->file())->name();
182 return;
183}
◆ GetPythonDesc()
void apollo::cyber::message::ProtobufFactory::GetPythonDesc |
( |
const std::string & |
type, |
|
|
std::string * |
desc_str |
|
) |
| |
在文件 protobuf_factory.cc 第 144 行定义.
145 {
146 auto desc = pool_->FindMessageTypeByName(type);
147 if (desc == nullptr) {
148 return;
149 }
150 google::protobuf::DescriptorProto dp;
151 desc->CopyTo(&dp);
152 dp.SerializeToString(desc_str);
153}
◆ RegisterMessage() [1/4]
bool apollo::cyber::message::ProtobufFactory::RegisterMessage |
( |
const Descriptor & |
desc | ) |
|
在文件 protobuf_factory.cc 第 43 行定义.
43 {
44 FileDescriptorProto file_desc_proto;
45 desc.file()->CopyTo(&file_desc_proto);
47}
bool RegisterMessage(const std::string &proto_desc_str)
◆ RegisterMessage() [2/4]
bool apollo::cyber::message::ProtobufFactory::RegisterMessage |
( |
const FileDescriptorProto & |
file_desc_proto | ) |
|
在文件 protobuf_factory.cc 第 88 行定义.
89 {
90 ErrorCollector ec;
91 std::lock_guard<std::mutex> lg(register_mutex_);
92 auto file_desc = pool_->BuildFileCollectingErrors(file_desc_proto, &ec);
93 if (!file_desc) {
94
95
96
97
98 return false;
99 }
100 return true;
101}
◆ RegisterMessage() [3/4]
bool apollo::cyber::message::ProtobufFactory::RegisterMessage |
( |
const google::protobuf::Message & |
message | ) |
|
◆ RegisterMessage() [4/4]
bool apollo::cyber::message::ProtobufFactory::RegisterMessage |
( |
const std::string & |
proto_desc_str | ) |
|
在文件 protobuf_factory.cc 第 81 行定义.
81 {
82 ProtoDesc proto_desc;
83 proto_desc.ParseFromString(proto_desc_str);
85}
◆ RegisterPythonMessage()
bool apollo::cyber::message::ProtobufFactory::RegisterPythonMessage |
( |
const std::string & |
proto_str | ) |
|
在文件 protobuf_factory.cc 第 75 行定义.
75 {
76 FileDescriptorProto file_desc_proto;
77 file_desc_proto.ParseFromString(proto_str);
79}
该类的文档由以下文件生成: