Apollo 11.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
31
32namespace apollo {
33namespace cyber {
34namespace service_discovery {
35
36class TopologyManager;
37
42class ChannelManager : public Manager {
43 friend class TopologyManager;
44
45 public:
46 using RoleAttrVec = std::vector<proto::RoleAttributes>;
49 using ExemptedMessageTypes = std::unordered_set<std::string>;
50
55
59 virtual ~ChannelManager();
60
66 void GetChannelNames(std::vector<std::string>* channels);
67
74 void GetProtoDesc(const std::string& channel_name, std::string* proto_desc);
75
82 void GetMsgType(const std::string& channel_name, std::string* msg_type);
83
92 bool HasWriter(const std::string& channel_name);
93
99 void GetWriters(RoleAttrVec* writers);
100
107 void GetWritersOfNode(const std::string& node_name, RoleAttrVec* writers);
108
115 void GetWritersOfChannel(const std::string& channel_name,
116 RoleAttrVec* writers);
117
126 bool HasReader(const std::string& channel_name);
127
133 void GetReaders(RoleAttrVec* readers);
134
141 void GetReadersOfNode(const std::string& node_name, RoleAttrVec* readers);
142
149 void GetReadersOfChannel(const std::string& channel_name,
150 RoleAttrVec* readers);
151
161 void GetUpstreamOfNode(const std::string& node_name,
162 RoleAttrVec* upstream_nodes);
163
173 void GetDownstreamOfNode(const std::string& node_name,
174 RoleAttrVec* downstream_nodes);
175
181 FlowDirection GetFlowDirection(const std::string& lhs_node_name,
182 const std::string& rhs_node_name);
183
192 bool IsMessageTypeMatching(const std::string& lhs, const std::string& rhs);
193
194 private:
195 bool Check(const RoleAttributes& attr) override;
196 void Dispose(const ChangeMsg& msg) override;
197 void OnTopoModuleLeave(const std::string& host_name, int process_id) override;
198
199 void DisposeJoin(const ChangeMsg& msg);
200 void DisposeLeave(const ChangeMsg& msg);
201
202 void ScanMessageType(const ChangeMsg& msg);
203
204 ExemptedMessageTypes exempted_msg_types_;
205
206 Graph node_graph_;
207 // key: node_id
208 WriterWarehouse node_writers_;
209 ReaderWarehouse node_readers_;
210
211 // key: channel_id
212 WriterWarehouse channel_writers_;
213 ReaderWarehouse channel_readers_;
214};
215
216} // namespace service_discovery
217} // namespace cyber
218} // namespace apollo
219
220#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:51
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