CARLA
CarlaRecorderState.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017 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 #include "CarlaRecorder.h"
8 #include "CarlaRecorderState.h"
9 #include "CarlaRecorderHelpers.h"
10 
11 void CarlaRecorderStateTrafficLight::Write(std::ofstream &OutFile)
12 {
13  WriteValue<uint32_t>(OutFile, this->DatabaseId);
14  WriteValue<bool>(OutFile, this->IsFrozen);
15  WriteValue<float>(OutFile, this->ElapsedTime);
16  WriteValue<char>(OutFile, this->State);
17 }
18 
19 void CarlaRecorderStateTrafficLight::Read(std::ifstream &InFile)
20 {
21  ReadValue<uint32_t>(InFile, this->DatabaseId);
22  ReadValue<bool>(InFile, this->IsFrozen);
23  ReadValue<float>(InFile, this->ElapsedTime);
24  ReadValue<char>(InFile, this->State);
25 }
26 
27 // ---------------------------------------------
28 
30 {
31  StatesTrafficLights.clear();
32 }
33 
35 {
36  StatesTrafficLights.push_back(std::move(State));
37 }
38 
39 void CarlaRecorderStates::Write(std::ofstream &OutFile)
40 {
41  // write the packet id
42  WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::State));
43 
44  // write the packet size
45  uint32_t Total = 2 + StatesTrafficLights.size() * sizeof(CarlaRecorderStateTrafficLight);
46  WriteValue<uint32_t>(OutFile, Total);
47 
48  // write total records
49  Total = StatesTrafficLights.size();
50  WriteValue<uint16_t>(OutFile, Total);
51 
52  for (uint16_t i = 0; i < Total; ++i)
53  {
54  StatesTrafficLights[i].Write(OutFile);
55  }
56 }
void Write(std::ofstream &OutFile)
void Add(const CarlaRecorderStateTrafficLight &State)
void Write(std::ofstream &OutFile)
void Read(std::ifstream &InFile)