Apollo  6.0
Open source self driving car software
node.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <memory>
10 #include <mutex>
11 #include <string>
12 #include <unordered_map>
13 #include <unordered_set>
14 
15 namespace apollo {
16 namespace cyber {
17 class Node;
18 template <class T>
19 class Writer;
20 template <class T>
21 class Reader;
22 
23 namespace message {
24 class PyMessageWrap;
25 }
26 } // namespace cyber
27 } // namespace apollo
28 
29 class Client;
30 
31 class 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
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Reader subscribes a channel, it has two main functions:
Definition: reader.h:68
Definition: writer.h:42
Definition: client.h:18
apollo::cyber::Writer< T > Writer
Definition: sensor_canbus.h:67