blob: 15a1d7c1009221183632d695265347b8fa4753ed [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