Apollo 10.0
自动驾驶开放平台
apollo::dreamview::UpdaterWithChannelsBase类 参考abstract

Base Class for data updater with multiply channels. 更多...

#include <updater_with_channels_base.h>

类 apollo::dreamview::UpdaterWithChannelsBase 继承关系图:
apollo::dreamview::UpdaterWithChannelsBase 的协作图:

Public 成员函数

 UpdaterWithChannelsBase (const std::vector< std::string > &filter_message_types, const std::vector< std::string > &filter_channels)
 
virtual void GetChannelMsg (std::vector< std::string > *channels)=0
 GetChannelMsg
 
void GetChannelMsgWithFilter (std::vector< std::string > *channels)
 
bool IsChannelInUpdater (const std::string &message_type, const std::string &channel_name)
 Check if the channel belongs to current updater.
 
- Public 成员函数 继承自 apollo::dreamview::UpdaterBase
 UpdaterBase ()
 Updaterbase
 
virtual void StartStream (const double &time_interval_ms, const std::string &channel_name="", nlohmann::json *subscribe_param=nullptr)=0
 Start data flow.
 
virtual void StopStream (const std::string &channel_name="")=0
 Stop data flow.
 
virtual void PublishMessage (const std::string &channel_name="")=0
 Publish Message to dreamview frontend.
 
virtual ~UpdaterBase ()
 

Public 属性

std::vector< std::string > channels_
 
std::vector< std::string > filter_message_types_
 
std::vector< std::string > filter_channels_
 

详细描述

Base Class for data updater with multiply channels.

The updater is responsible for maintaining and updating a data type used by the dreamview module, such as simulation_world, pointcloud, camera, pointcloud etc. Each type of data is a data stream that supports front-end and back-end communication of dreamview.

在文件 updater_with_channels_base.h40 行定义.

构造及析构函数说明

◆ UpdaterWithChannelsBase()

apollo::dreamview::UpdaterWithChannelsBase::UpdaterWithChannelsBase ( const std::vector< std::string > &  filter_message_types,
const std::vector< std::string > &  filter_channels 
)

在文件 updater_with_channels_base.cc27 行定义.

30 : filter_message_types_(filter_message_types),
31 filter_channels_(filter_channels) {}

成员函数说明

◆ GetChannelMsg()

virtual void apollo::dreamview::UpdaterWithChannelsBase::GetChannelMsg ( std::vector< std::string > *  channels)
pure virtual

◆ GetChannelMsgWithFilter()

void apollo::dreamview::UpdaterWithChannelsBase::GetChannelMsgWithFilter ( std::vector< std::string > *  channels)

在文件 updater_with_channels_base.cc47 行定义.

48 {
49 auto channelManager =
50 apollo::cyber::service_discovery::TopologyManager::Instance()
51 ->channel_manager();
52 std::vector<apollo::cyber::proto::RoleAttributes> role_attr_vec;
53 channelManager->GetWriters(&role_attr_vec);
54 std::vector<std::string> records;
55 std::vector<std::string> other_record_node_name;
56 auto *record_player_factory = RecordPlayerFactory::Instance();
57 record_player_factory->GetAllRecords(&records);
58 const std::string current_record = record_player_factory->GetCurrentRecord();
59 for (auto iter = records.begin(); iter != records.end(); iter++) {
60 if (current_record.empty() || *iter != current_record) {
61 std::string other_node_name = "record_player_factory_" + *iter;
62 other_record_node_name.push_back(other_node_name);
63 }
64 }
65 std::vector<std::string> tmp_channels;
66 for (auto &role_attr : role_attr_vec) {
67 std::string messageType;
68 std::string node_name;
69 messageType = role_attr.message_type();
70 node_name = role_attr.node_name();
71 if (IsChannelInUpdater(messageType, role_attr.channel_name())) {
72 if (current_record.empty() ||
73 std::find(other_record_node_name.begin(),
74 other_record_node_name.end(),
75 node_name) == other_record_node_name.end()) {
76 tmp_channels.push_back(role_attr.channel_name());
77 }
78 }
79 }
80 std::set<std::string> s(tmp_channels.begin(), tmp_channels.end());
81 channels->assign(tmp_channels.begin(), tmp_channels.end());
82 channels_.clear();
83 channels_.assign(s.begin(), s.end());
84}
bool IsChannelInUpdater(const std::string &message_type, const std::string &channel_name)
Check if the channel belongs to current updater.

◆ IsChannelInUpdater()

bool apollo::dreamview::UpdaterWithChannelsBase::IsChannelInUpdater ( const std::string &  message_type,
const std::string &  channel_name 
)

Check if the channel belongs to current updater.

参数
message_typeThe type of message in channel.
channel_nameThe name of channel.

在文件 updater_with_channels_base.cc33 行定义.

34 {
35 if (filter_message_types_.size() == 0 && filter_channels_.size() == 0) {
36 return true;
37 }
38 for (size_t i = 0; i < filter_message_types_.size(); ++i) {
39 if (message_type.rfind(filter_message_types_[i]) != std::string::npos &&
40 channel_name.rfind(filter_channels_[i]) != std::string::npos) {
41 return true;
42 }
43 }
44 return false;
45}

类成员变量说明

◆ channels_

std::vector<std::string> apollo::dreamview::UpdaterWithChannelsBase::channels_

在文件 updater_with_channels_base.h58 行定义.

◆ filter_channels_

std::vector<std::string> apollo::dreamview::UpdaterWithChannelsBase::filter_channels_

在文件 updater_with_channels_base.h60 行定义.

◆ filter_message_types_

std::vector<std::string> apollo::dreamview::UpdaterWithChannelsBase::filter_message_types_

在文件 updater_with_channels_base.h59 行定义.


该类的文档由以下文件生成: