Apollo 10.0
自动驾驶开放平台
node.h
浏览该文件的文档.
1
7#pragma once
8
9#include <memory>
10#include <mutex>
11#include <string>
12#include <unordered_map>
13#include <unordered_set>
14
15namespace apollo {
16namespace cyber {
17class Node;
18template <class T>
19class Writer;
20template <class T>
21class Reader;
22
23namespace message {
24class PyMessageWrap;
25}
26} // namespace cyber
27} // namespace apollo
28
29class Client;
30
31class Node {
32 public:
33 Node();
34 ~Node();
35
36 void remove(std::shared_ptr<Client> client);
37
38 void add_reader(const std::string& channel, const std::string& type,
39 std::shared_ptr<Client> client);
40 void add_writer(const std::string& channel, const std::string& type,
41 std::shared_ptr<Client> client);
42
43 void publish(const std::string& channel, const std::string& data);
44
45 private:
46 std::unique_ptr<apollo::cyber::Node> node;
47 std::mutex mutex;
48
49 struct Writer {
50 std::string desc;
51 std::string type;
52 std::shared_ptr<
54 writer;
55 std::unordered_set<std::shared_ptr<Client>> clients;
56 };
57
58 struct Reader {
59 std::shared_ptr<
61 reader;
62 std::unordered_set<std::shared_ptr<Client>> clients;
63 };
64
65 typedef std::unordered_map<std::string, Writer> Writers;
66 typedef std::unordered_map<std::string, Reader> Readers;
67 Writers writers;
68 Readers readers;
69};
Definition node.h:31
void add_writer(const std::string &channel, const std::string &type, std::shared_ptr< Client > client)
Definition node.cc:93
void remove(std::shared_ptr< Client > client)
Definition node.cc:26
void add_reader(const std::string &channel, const std::string &type, std::shared_ptr< Client > client)
Definition node.cc:60
~Node()
Definition node.cc:24
Node()
Definition node.cc:22
void publish(const std::string &channel, const std::string &data)
Definition node.cc:124
Reader subscribes a channel, it has two main functions:
Definition reader.h:69
apollo::cyber::Writer< T > Writer
class register implement
Definition arena_queue.h:37