CARLA
CarlaRecorderCollision.h
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 #pragma once
8 
9 #include <fstream>
10 #include <vector>
11 #include <unordered_set>
12 
13 #pragma pack(push, 1)
15 {
16  uint32_t Id;
17  uint32_t DatabaseId1;
18  uint32_t DatabaseId2;
21 
22  void Read(std::ifstream &InFile);
23  void Write(std::ofstream &OutFile) const;
24  // define operator == needed for the 'unordered_set'
25  bool operator==(const CarlaRecorderCollision &Other) const;
26 };
27 #pragma pack(pop)
28 
29 // implement the hash function for the unordered_set of collisions
30 namespace std
31 {
32  template<>
34  {
35  std::size_t operator()(const CarlaRecorderCollision& P) const noexcept
36  {
37  std::size_t hash = P.DatabaseId1;
38  hash <<= 32;
39  hash += P.DatabaseId2;
40  return hash;
41  }
42  };
43 }
44 
46 
47  public:
48  void Add(const CarlaRecorderCollision &Collision);
49  void Clear(void);
50  void Write(std::ofstream &OutFile);
51 
52  private:
53  std::unordered_set<CarlaRecorderCollision> Collisions;
54 };
void Read(std::ifstream &InFile)
bool operator==(const CarlaRecorderCollision &Other) const
std::unordered_set< CarlaRecorderCollision > Collisions
std::size_t operator()(const CarlaRecorderCollision &P) const noexcept
void Write(std::ofstream &OutFile) const