blob: 02405ff55f0ecb4fc7f5ae9439b5dd3c62538361 [file] [log] [blame]
Patrick Williams3667cf32015-10-20 22:39:11 -05001#ifndef __SENSORCACHE_H
2#define __SENSORCACHE_H
3
4#include <map>
5
6class SensorCache
7{
8 public:
9 typedef std::map<std::pair<std::string, std::string>,
Brad Bishop6bb97a92016-12-19 13:06:40 -050010 int> container_t;
Patrick Williams3667cf32015-10-20 22:39:11 -050011
12 bool update(const container_t::key_type& k,
13 const container_t::mapped_type& v)
14 {
15 auto& i = container[k];
Brad Bishop6bb97a92016-12-19 13:06:40 -050016 if (v == i)
17 {
18 return false;
19 }
Patrick Williams3667cf32015-10-20 22:39:11 -050020 else
21 {
22 i = v;
23 return true;
24 }
25 }
26 private:
27 container_t container;
28};
29
30#endif
Brad Bishop03476f12016-12-19 13:09:12 -050031
32// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4