CARLA
CarlaRecorderAnimWalker.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 CarlaRecorderAnimWalker::Write(std::ofstream &OutFile)
12 {
13  // database id
14  WriteValue<uint32_t>(OutFile, this->DatabaseId);
15  WriteValue<float>(OutFile, this->Speed);
16 }
17 void CarlaRecorderAnimWalker::Read(std::ifstream &InFile)
18 {
19  // database id
20  ReadValue<uint32_t>(InFile, this->DatabaseId);
21  ReadValue<float>(InFile, this->Speed);
22 }
23 
24 // ---------------------------------------------
25 
27 {
28  Walkers.clear();
29 }
30 
32 {
33  Walkers.push_back(Walker);
34 }
35 
36 void CarlaRecorderAnimWalkers::Write(std::ofstream &OutFile)
37 {
38  // write the packet id
39  WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::AnimWalker));
40 
41  // write the packet size
42  uint32_t Total = 2 + Walkers.size() * sizeof(CarlaRecorderAnimWalker);
43  WriteValue<uint32_t>(OutFile, Total);
44 
45  // write total records
46  Total = Walkers.size();
47  WriteValue<uint16_t>(OutFile, Total);
48 
49  // write records
50  if (Total > 0)
51  {
52  OutFile.write(reinterpret_cast<const char *>(Walkers.data()),
53  Walkers.size() * sizeof(CarlaRecorderAnimWalker));
54  }
55 }
void Write(std::ofstream &OutFile)
void Add(const CarlaRecorderAnimWalker &InObj)
void Read(std::ifstream &InFile)
void Write(std::ofstream &OutFile)