CARLA
CachedSimpleWaypoint.h
Go to the documentation of this file.
1 // Copyright (c) 2021 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #include <fstream>
10 
12 
13 namespace carla {
14 namespace traffic_manager {
15 
16  using SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>;
17 
19  public:
20  uint64_t waypoint_id;
21  uint32_t road_id;
22  uint32_t section_id;
23  int32_t lane_id;
24  float s;
25  std::vector<uint64_t> next_waypoints;
26  std::vector<uint64_t> previous_waypoints;
27  uint64_t next_left_waypoint = 0;
28  uint64_t next_right_waypoint = 0;
31  uint8_t road_option;
32 
33  CachedSimpleWaypoint() = default;
34  CachedSimpleWaypoint(const SimpleWaypointPtr& simple_waypoint);
35 
36  void Read(const std::vector<uint8_t>& content, unsigned long& start);
37 
38  void Read(std::ifstream &in_file);
39  void Write(std::ofstream &out_file);
40 
41  private:
42  template <typename T>
43  void WriteValue(std::ofstream &out_file, const T &in_obj) {
44  out_file.write(reinterpret_cast<const char *>(&in_obj), sizeof(T));
45  }
46  template <typename T>
47  void ReadValue(std::ifstream &in_file, T &out_obj) {
48  in_file.read(reinterpret_cast<char *>(&out_obj), sizeof(T));
49  }
50  template <typename T>
51  void ReadValue(const std::vector<uint8_t>& content, unsigned long& start, T &out_obj) {
52  memcpy(&out_obj, &content[start], sizeof(T));
53  start += sizeof(T);
54  }
55  };
56 
57 } // namespace traffic_manager
58 } // namespace carla
void ReadValue(const std::vector< uint8_t > &content, unsigned long &start, T &out_obj)
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
void WriteValue(std::ofstream &out_file, const T &in_obj)
void Read(const std::vector< uint8_t > &content, unsigned long &start)
void ReadValue(std::ifstream &in_file, T &out_obj)
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr