Apollo  6.0
Open source self driving car software
readable_info.h
Go to the documentation of this file.
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_TRANSPORT_SHM_READABLE_INFO_H_
18 #define CYBER_TRANSPORT_SHM_READABLE_INFO_H_
19 
20 #include <cstddef>
21 #include <cstdint>
22 #include <memory>
23 #include <string>
24 
25 namespace apollo {
26 namespace cyber {
27 namespace transport {
28 
29 class ReadableInfo;
30 using ReadableInfoPtr = std::shared_ptr<ReadableInfo>;
31 
32 class ReadableInfo {
33  public:
34  ReadableInfo();
35  ReadableInfo(uint64_t host_id, uint32_t block_index, uint64_t channel_id);
36  virtual ~ReadableInfo();
37 
38  ReadableInfo& operator=(const ReadableInfo& other);
39 
40  bool DeserializeFrom(const std::string& src);
41  bool DeserializeFrom(const char* src, std::size_t len);
42  bool SerializeTo(std::string* dst) const;
43 
44  uint64_t host_id() const { return host_id_; }
45  void set_host_id(uint64_t host_id) { host_id_ = host_id; }
46 
47  uint32_t block_index() const { return block_index_; }
48  void set_block_index(uint32_t block_index) { block_index_ = block_index; }
49 
50  uint64_t channel_id() const { return channel_id_; }
51  void set_channel_id(uint64_t channel_id) { channel_id_ = channel_id; }
52 
53  static const size_t kSize;
54 
55  private:
56  uint64_t host_id_;
57  uint32_t block_index_;
58  uint64_t channel_id_;
59 };
60 
61 } // namespace transport
62 } // namespace cyber
63 } // namespace apollo
64 
65 #endif // CYBER_TRANSPORT_SHM_READABLE_INFO_H_
std::shared_ptr< ReadableInfo > ReadableInfoPtr
Definition: readable_info.h:30
void set_channel_id(uint64_t channel_id)
Definition: readable_info.h:51
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: readable_info.h:32
bool SerializeTo(std::string *dst) const
void set_block_index(uint32_t block_index)
Definition: readable_info.h:48
uint64_t host_id() const
Definition: readable_info.h:44
uint32_t block_index() const
Definition: readable_info.h:47
void set_host_id(uint64_t host_id)
Definition: readable_info.h:45
ReadableInfo & operator=(const ReadableInfo &other)
uint64_t channel_id() const
Definition: readable_info.h:50
static const size_t kSize
Definition: readable_info.h:53
bool DeserializeFrom(const std::string &src)