face-map.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_FACE_MAP_HPP
23 #define NLSR_FACE_MAP_HPP
24 
25 #include "common.hpp"
26 
27 #include <map>
28 
29 namespace nlsr {
30 
32 {
33 
34 public:
35  FaceMapEntry(const std::string& faceUri, uint32_t faceId)
36  : m_faceUri(faceUri)
37  , m_faceId(faceId)
38  {
39  }
40 
41  void
42  setFaceUri(const std::string& faceUri)
43  {
44  m_faceUri = faceUri;
45  }
46 
47  const std::string&
48  getFaceUri() const
49  {
50  return m_faceUri;
51  }
52 
53  void
54  setFaceId(uint32_t faceId)
55  {
56  m_faceId = faceId;
57  }
58 
59  uint32_t
60  getFaceId() const
61  {
62  return m_faceId;
63  }
64 
65  bool
66  compare(const FaceMapEntry& fme)
67  {
68  return m_faceUri == fme.getFaceUri();
69  }
70 
71 private:
72  std::string m_faceUri;
73  uint32_t m_faceId;
74 };
75 
76 class FaceMap
77 {
78 
79 public:
81  {
82  }
83 
85  {
86  }
87 
88  inline void
89  update(const std::string& faceUri, uint32_t faceId)
90  {
91  FaceMapEntry fme(faceUri, faceId);
92  std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
93  if (it == m_table.end()) {
94  m_table.emplace(faceUri, fme);
95  }
96  else {
97  (it->second).setFaceId(fme.getFaceId());
98  }
99  }
100 
101  inline uint32_t
102  getFaceId(const std::string& faceUri)
103  {
104  FaceMapEntry fme(faceUri, 0);
105  std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
106  if (it != m_table.end()) {
107  return (it->second).getFaceId();
108  }
109  return 0;
110  }
111 
112  void
113  writeLog();
114 
115 private:
116  std::map<std::string, FaceMapEntry> m_table;
117 };
118 
119 } // namespace nlsr
120 
121 #endif // NLSR_FACE_MAP_HPP
FaceMapEntry(const std::string &faceUri, uint32_t faceId)
Definition: face-map.hpp:35
bool compare(const FaceMapEntry &fme)
Definition: face-map.hpp:66
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California.
void setFaceUri(const std::string &faceUri)
Definition: face-map.hpp:42
const std::string & getFaceUri() const
Definition: face-map.hpp:48
void setFaceId(uint32_t faceId)
Definition: face-map.hpp:54
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
uint32_t getFaceId() const
Definition: face-map.hpp:60
void update(const std::string &faceUri, uint32_t faceId)
Definition: face-map.hpp:89
uint32_t getFaceId(const std::string &faceUri)
Definition: face-map.hpp:102