CARLA
CarlaRecorderEventDel.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"
9 #include "CarlaRecorderHelpers.h"
10 
11 void CarlaRecorderEventDel::Read(std::ifstream &InFile)
12 {
13  // database id
14  ReadValue<uint32_t>(InFile, this->DatabaseId);
15 }
16 void CarlaRecorderEventDel::Write(std::ofstream &OutFile) const
17 {
18  // database id
19  WriteValue<uint32_t>(OutFile, this->DatabaseId);
20 }
21 
22 //---------------------------------------------
23 
25 {
26  Events.clear();
27 }
28 
30 {
31  Events.push_back(std::move(Event));
32 }
33 
34 void CarlaRecorderEventsDel::Write(std::ofstream &OutFile)
35 {
36  // write the packet id
37  WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::EventDel));
38 
39  std::streampos PosStart = OutFile.tellp();
40 
41  // write a dummy packet size
42  uint32_t Total = 0;
43  WriteValue<uint32_t>(OutFile, Total);
44 
45  // write total records
46  Total = Events.size();
47  WriteValue<uint16_t>(OutFile, Total);
48 
49  for (uint16_t i=0; i<Total; ++i)
50  {
51  Events[i].Write(OutFile);
52  }
53 
54  // write the real packet size
55  std::streampos PosEnd = OutFile.tellp();
56  Total = PosEnd - PosStart - sizeof(uint32_t);
57  OutFile.seekp(PosStart, std::ios::beg);
58  WriteValue<uint32_t>(OutFile, Total);
59  OutFile.seekp(PosEnd, std::ios::beg);
60 }
void Write(std::ofstream &OutFile)
void Write(std::ofstream &OutFile) const
void Add(const CarlaRecorderEventDel &Event)
void Read(std::ifstream &InFile)