blob: 6e8c4f1a53e91504e306029beb0585e3731d9fc1 [file] [log] [blame]
Brad Bishop26b815f2017-01-04 13:32:47 -05001#pragma once
Patrick Williams3667cf32015-10-20 22:39:11 -05002
3#include <map>
4
5class SensorCache
6{
7 public:
8 typedef std::map<std::pair<std::string, std::string>,
Brad Bishop6bb97a92016-12-19 13:06:40 -05009 int> container_t;
Patrick Williams3667cf32015-10-20 22:39:11 -050010
11 bool update(const container_t::key_type& k,
12 const container_t::mapped_type& v)
13 {
14 auto& i = container[k];
Brad Bishop6bb97a92016-12-19 13:06:40 -050015 if (v == i)
16 {
17 return false;
18 }
Patrick Williams3667cf32015-10-20 22:39:11 -050019 else
20 {
21 i = v;
22 return true;
23 }
24 }
25 private:
26 container_t container;
27};
28
Brad Bishop03476f12016-12-19 13:09:12 -050029// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4