28 std::vector<std::string> *channels,
const std::string &filter_message_type,
29 const std::string &filter_channel,
bool reverse_filter_channel) {
31 apollo::cyber::service_discovery::TopologyManager::Instance()
33 std::vector<apollo::cyber::proto::RoleAttributes> role_attr_vec;
34 channelManager->GetWriters(&role_attr_vec);
35 std::vector<std::string> records;
36 std::vector<std::string> other_record_node_name;
37 auto *record_player_factory = RecordPlayerFactory::Instance();
38 record_player_factory->GetAllRecords(&records);
39 const std::string current_record = record_player_factory->GetCurrentRecord();
40 for (
auto iter = records.begin(); iter != records.end(); iter++) {
41 if (current_record.empty() || *iter != current_record) {
42 std::string other_node_name =
"record_player_factory_" + *iter;
43 other_record_node_name.push_back(other_node_name);
46 std::vector<std::string> tmp_channels;
47 for (
auto &role_attr : role_attr_vec) {
48 std::string messageType;
49 std::string node_name;
50 messageType = role_attr.message_type();
51 node_name = role_attr.node_name();
53 if (!filter_message_type.empty()) {
54 index = messageType.rfind(filter_message_type);
56 int index_channel = 0;
57 bool select_current_channel = filter_channel.empty();
58 if (!filter_channel.empty()) {
59 index_channel = role_attr.channel_name().rfind(filter_channel);
60 select_current_channel = reverse_filter_channel ? (index_channel == -1)
61 : (index_channel != -1);
63 if (index != -1 && select_current_channel) {
64 if (current_record.empty() ||
65 std::find(other_record_node_name.begin(),
66 other_record_node_name.end(),
67 node_name) == other_record_node_name.end()) {
68 tmp_channels.push_back(role_attr.channel_name());
72 std::set<std::string> s(tmp_channels.begin(), tmp_channels.end());
73 channels->assign(tmp_channels.begin(), tmp_channels.end());
void GetChannelMsgWithFilter(std::vector< std::string > *channels, const std::string &filter_message_type, const std::string &filter_channel, bool reverse_filter_channel=false)
GetChannelMsgWithFilter:by msg type and channel filter field to filter channels for DataUpdater