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::ostream &OutFile)
12 {
13  // database id
14  WriteValue<uint32_t>(OutFile, this->DatabaseId);
15  WriteValue<float>(OutFile, this->Speed);
16 }
17 void CarlaRecorderAnimWalker::Read(std::istream &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::ostream &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 }
56 
57 void CarlaRecorderAnimWalkers::Read(std::istream &InFile)
58 {
59  uint16_t i, Total;
61 
62  // read Total walkers
63  ReadValue<uint16_t>(InFile, Total);
64  for (i = 0; i < Total; ++i)
65  {
66  Walker.Read(InFile);
67  Add(Walker);
68  }
69 }
70 
71 const std::vector<CarlaRecorderAnimWalker>& CarlaRecorderAnimWalkers::GetWalkers()
72 {
73  return Walkers;
74 }
const std::vector< CarlaRecorderAnimWalker > & GetWalkers()
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderAnimWalker &InObj)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)