CARLA
CarlaRecorderLightVehicle.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020 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 
8 #include "CarlaRecorder.h"
9 #include "CarlaRecorderHelpers.h"
10 
11 
12 void CarlaRecorderLightVehicle::Write(std::ofstream &OutFile)
13 {
14  // database id
15  WriteValue<uint32_t>(OutFile, this->DatabaseId);
16  WriteValue<VehicleLightStateType>(OutFile, this->State);
17 }
18 void CarlaRecorderLightVehicle::Read(std::ifstream &InFile)
19 {
20  // database id
21  ReadValue<uint32_t>(InFile, this->DatabaseId);
22  ReadValue<VehicleLightStateType>(InFile, this->State);
23 }
24 
25 // ---------------------------------------------
26 
28 {
29  Vehicles.clear();
30 }
31 
33 {
34  Vehicles.push_back(Vehicle);
35 }
36 
37 void CarlaRecorderLightVehicles::Write(std::ofstream &OutFile)
38 {
39  // write the packet id
40  WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::VehicleLight));
41 
42  // write a dummy packet size
43  uint32_t Total = 2 + Vehicles.size() * sizeof(CarlaRecorderLightVehicle);
44  WriteValue<uint32_t>(OutFile, Total);
45 
46  // write total records
47  Total = Vehicles.size();
48  WriteValue<uint16_t>(OutFile, Total);
49 
50  for (auto& Vehicle : Vehicles)
51  {
52  Vehicle.Write(OutFile);
53  }
54 }
void Read(std::ifstream &InFile)
void Add(const CarlaRecorderLightVehicle &InObj)
void Write(std::ofstream &OutFile)
void Write(std::ofstream &OutFile)