Apollo 10.0
自动驾驶开放平台
channel_manager.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef CYBER_SERVICE_DISCOVERY_SPECIFIC_MANAGER_CHANNEL_MANAGER_H_
18#define CYBER_SERVICE_DISCOVERY_SPECIFIC_MANAGER_CHANNEL_MANAGER_H_
19
20#include <memory>
21#include <string>
22#include <unordered_map>
23#include <unordered_set>
24#include <vector>
25
26#include "cyber/proto/role_attributes.pb.h"
32
33namespace apollo {
34namespace cyber {
35namespace service_discovery {
36
37class TopologyManager;
38
43class ChannelManager : public Manager {
44 friend class TopologyManager;
45
46 public:
47 using RoleAttrVec = std::vector<proto::RoleAttributes>;
50 using ExemptedMessageTypes = std::unordered_set<std::string>;
51
56
60 virtual ~ChannelManager();
61
67 void GetChannelNames(std::vector<std::string>* channels);
68
75 void GetProtoDesc(const std::string& channel_name, std::string* proto_desc);
76
83 void GetMsgType(const std::string& channel_name, std::string* msg_type);
84
93 bool HasWriter(const std::string& channel_name);
94
100 void GetWriters(RoleAttrVec* writers);
101
108 void GetWritersOfNode(const std::string& node_name, RoleAttrVec* writers);
109
116 void GetWritersOfChannel(const std::string& channel_name,
117 RoleAttrVec* writers);
118
127 bool HasReader(const std::string& channel_name);
128
134 void GetReaders(RoleAttrVec* readers);
135
142 void GetReadersOfNode(const std::string& node_name, RoleAttrVec* readers);
143
150 void GetReadersOfChannel(const std::string& channel_name,
151 RoleAttrVec* readers);
152
162 void GetUpstreamOfNode(const std::string& node_name,
163 RoleAttrVec* upstream_nodes);
164
174 void GetDownstreamOfNode(const std::string& node_name,
175 RoleAttrVec* downstream_nodes);
176
182 FlowDirection GetFlowDirection(const std::string& lhs_node_name,
183 const std::string& rhs_node_name);
184
193 bool IsMessageTypeMatching(const std::string& lhs, const std::string& rhs);
194
195 private:
196 bool Check(const RoleAttributes& attr) override;
197 void Dispose(const ChangeMsg& msg) override;
198 void OnTopoModuleLeave(const std::string& host_name, int process_id) override;
199
200 void DisposeJoin(const ChangeMsg& msg);
201 void DisposeLeave(const ChangeMsg& msg);
202
203 void ScanMessageType(const ChangeMsg& msg);
204
205 ExemptedMessageTypes exempted_msg_types_;
206
207 Graph node_graph_;
208 // key: node_id
209 WriterWarehouse node_writers_;
210 ReaderWarehouse node_readers_;
211
212 // key: channel_id
213 WriterWarehouse channel_writers_;
214 ReaderWarehouse channel_readers_;
215};
216
217} // namespace service_discovery
218} // namespace cyber
219} // namespace apollo
220
221#endif // CYBER_SERVICE_DISCOVERY_SPECIFIC_MANAGER_CHANNEL_MANAGER_H_
Topology Manager of Service related
void GetMsgType(const std::string &channel_name, std::string *msg_type)
Get the Msg Type of channel_name
void GetProtoDesc(const std::string &channel_name, std::string *proto_desc)
Get the Protocol Desc of channel_name
void GetReadersOfNode(const std::string &node_name, RoleAttrVec *readers)
Get the Readers Of Node object
bool HasWriter(const std::string &channel_name)
Inquire if there is at least one Writer that publishes channel_name
void GetWritersOfChannel(const std::string &channel_name, RoleAttrVec *writers)
Get the Writers Of Channel object
std::vector< proto::RoleAttributes > RoleAttrVec
void GetUpstreamOfNode(const std::string &node_name, RoleAttrVec *upstream_nodes)
Get the Upstream Of Node object.
std::unordered_set< std::string > ExemptedMessageTypes
void GetWritersOfNode(const std::string &node_name, RoleAttrVec *writers)
Get the Writers Of Node object
bool HasReader(const std::string &channel_name)
Inquire if there is at least one Reader that publishes channel_name
void GetReadersOfChannel(const std::string &channel_name, RoleAttrVec *readers)
Get the Readers Of Channel object
bool IsMessageTypeMatching(const std::string &lhs, const std::string &rhs)
Is lhs and rhs have same MessageType
void GetWriters(RoleAttrVec *writers)
Get All Writers object
void GetReaders(RoleAttrVec *readers)
Get All Readers object
void GetChannelNames(std::vector< std::string > *channels)
Get all channel names in the topology
FlowDirection GetFlowDirection(const std::string &lhs_node_name, const std::string &rhs_node_name)
Get the Flow Direction from lhs_node_node to rhs_node_name You can see FlowDirection's description fo...
ChannelManager()
Construct a new Channel Manager object
virtual ~ChannelManager()
Destroy the Channel Manager object
void GetDownstreamOfNode(const std::string &node_name, RoleAttrVec *downstream_nodes)
Get the Downstream Of Node object.
Base class for management of Topology elements.
Definition manager.h:54
elements in Cyber – Node, Channel, Service, Writer, Reader, Client and Server's relationship is prese...
FlowDirection
describe the flow direction between nodes As the DAG below A-—>B--—>C<--—D GetDirectionOf(A,...
Definition graph.h:39
class register implement
Definition arena_queue.h:37