#include <message_reader.h>
|
| template<typename T > |
| void | RegisterMessage (const std::string &channel_name) |
| | Register the message reader with the given channel name.
|
| |
| template<typename T > |
| const T * | GetMessage (const std::string &channel_name) const |
| | Get the message with the channel name.
|
| |
◆ GetMessage()
template<typename T >
| const T * apollo::external_command::MessageReader::GetMessage |
( |
const std::string & |
channel_name | ) |
const |
Get the message with the channel name.
- 参数
-
| channel_name | Channel name of the message. |
- 返回
- Message with the channel name; return null if no message with the given type and channel name is registered.
在文件 message_reader.h 第 68 行定义.
68 {
69 if (reader_map_.find(channel_name) == reader_map_.end()) {
70 return nullptr;
71 }
72 auto* base_reader = reader_map_.at(channel_name).get();
73 auto* message_reader = dynamic_cast<cyber::Reader<T>*>(base_reader);
74 if (nullptr == message_reader) {
75 return nullptr;
76 }
77 message_reader->Observe();
78 if (message_reader->Empty()) {
79 AERROR <<
"Failed to get message of " << channel_name;
80 return nullptr;
81 }
82 const auto* message = message_reader->GetLatestObserved().get();
83 return message;
84}
◆ RegisterMessage()
template<typename T >
| void apollo::external_command::MessageReader::RegisterMessage |
( |
const std::string & |
channel_name | ) |
|
Register the message reader with the given channel name.
- 参数
-
| channel_name | Channel name of the message. |
在文件 message_reader.h 第 59 行定义.
59 {
60
61 if (reader_map_.find(channel_name) == reader_map_.end()) {
62 auto reader = node_->CreateReader<T>(channel_name);
63 reader_map_[channel_name] = reader;
64 }
65}
该类的文档由以下文件生成:
- modules/external_command/command_processor/command_processor_base/util/message_reader.h