32namespace external_command {
49 const T*
GetMessage(
const std::string& channel_name)
const;
52 std::map<std::string, std::shared_ptr<cyber::ReaderBase>> reader_map_;
53 std::shared_ptr<cyber::Node> node_;
61 if (reader_map_.find(channel_name) == reader_map_.end()) {
62 auto reader = node_->CreateReader<T>(channel_name);
63 reader_map_[channel_name] = reader;
69 if (reader_map_.find(channel_name) == reader_map_.end()) {
72 auto* base_reader = reader_map_.at(channel_name).get();
74 if (
nullptr == message_reader) {
78 if (message_reader->Empty()) {
79 AERROR <<
"Failed to get message of " << channel_name;
82 const auto* message = message_reader->GetLatestObserved().get();
Reader subscribes a channel, it has two main functions:
void Observe() override
Get All data that Blocker stores
void RegisterMessage(const std::string &channel_name)
Register the message reader with the given channel name.
const T * GetMessage(const std::string &channel_name) const
Get the message with the channel name.
#define DECLARE_SINGLETON(classname)