Apollo 10.0
自动驾驶开放平台
apollo::cyber::service_discovery::Graph类 参考

#include <graph.h>

apollo::cyber::service_discovery::Graph 的协作图:

Public 类型

using VerticeSet = std::unordered_map< std::string, Vertice >
 
using AdjacencyList = std::unordered_map< std::string, VerticeSet >
 

Public 成员函数

 Graph ()
 
virtual ~Graph ()
 
void Insert (const Edge &e)
 
void Delete (const Edge &e)
 
uint32_t GetNumOfEdge ()
 
FlowDirection GetDirectionOf (const Vertice &lhs, const Vertice &rhs)
 

详细描述

在文件 graph.h93 行定义.

成员类型定义说明

◆ AdjacencyList

using apollo::cyber::service_discovery::Graph::AdjacencyList = std::unordered_map<std::string, VerticeSet>

在文件 graph.h96 行定义.

◆ VerticeSet

using apollo::cyber::service_discovery::Graph::VerticeSet = std::unordered_map<std::string, Vertice>

在文件 graph.h95 行定义.

构造及析构函数说明

◆ Graph()

apollo::cyber::service_discovery::Graph::Graph ( )

在文件 graph.cc93 行定义.

93{}

◆ ~Graph()

apollo::cyber::service_discovery::Graph::~Graph ( )
virtual

在文件 graph.cc95 行定义.

95 {
96 edges_.clear();
97 list_.clear();
98}

成员函数说明

◆ Delete()

void apollo::cyber::service_discovery::Graph::Delete ( const Edge e)

在文件 graph.cc118 行定义.

118 {
119 if (!e.IsValid()) {
120 return;
121 }
122 WriteLockGuard<AtomicRWLock> lock(rw_lock_);
123 auto& e_v = e.value();
124 if (edges_.find(e_v) == edges_.end()) {
125 return;
126 }
127
128 if (!e.src().IsDummy()) {
129 DeleteOutgoingEdge(e);
130 }
131 if (!e.dst().IsDummy()) {
132 DeleteIncomingEdge(e);
133 }
134}

◆ GetDirectionOf()

FlowDirection apollo::cyber::service_discovery::Graph::GetDirectionOf ( const Vertice lhs,
const Vertice rhs 
)

在文件 graph.cc145 行定义.

145 {
146 if (lhs.IsDummy() || rhs.IsDummy()) {
147 return UNREACHABLE;
148 }
149 ReadLockGuard<AtomicRWLock> lock(rw_lock_);
150 if (list_.count(lhs.GetKey()) == 0 || list_.count(rhs.GetKey()) == 0) {
151 return UNREACHABLE;
152 }
153 if (LevelTraverse(lhs, rhs)) {
154 return UPSTREAM;
155 }
156 if (LevelTraverse(rhs, lhs)) {
157 return DOWNSTREAM;
158 }
159 return UNREACHABLE;
160}

◆ GetNumOfEdge()

uint32_t apollo::cyber::service_discovery::Graph::GetNumOfEdge ( )

在文件 graph.cc136 行定义.

136 {
137 ReadLockGuard<AtomicRWLock> lock(rw_lock_);
138 uint32_t num = 0;
139 for (auto& item : list_) {
140 num += static_cast<int>(item.second.size());
141 }
142 return num;
143}

◆ Insert()

void apollo::cyber::service_discovery::Graph::Insert ( const Edge e)

在文件 graph.cc100 行定义.

100 {
101 if (!e.IsValid()) {
102 return;
103 }
104 WriteLockGuard<AtomicRWLock> lock(rw_lock_);
105 auto& e_v = e.value();
106 if (edges_.find(e_v) == edges_.end()) {
107 edges_[e_v] = RelatedVertices();
108 }
109
110 if (!e.src().IsDummy()) {
111 InsertOutgoingEdge(e);
112 }
113 if (!e.dst().IsDummy()) {
114 InsertIncomingEdge(e);
115 }
116}

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