Brad Bishop | 26b815f | 2017-01-04 13:32:47 -0500 | [diff] [blame] | 1 | #pragma once |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 2 | |
| 3 | #include <map> |
| 4 | |
| 5 | class SensorCache |
| 6 | { |
| 7 | public: |
| 8 | typedef std::map<std::pair<std::string, std::string>, |
Brad Bishop | 6bb97a9 | 2016-12-19 13:06:40 -0500 | [diff] [blame] | 9 | int> container_t; |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 10 | |
| 11 | bool update(const container_t::key_type& k, |
| 12 | const container_t::mapped_type& v) |
| 13 | { |
| 14 | auto& i = container[k]; |
Brad Bishop | 6bb97a9 | 2016-12-19 13:06:40 -0500 | [diff] [blame] | 15 | if (v == i) |
| 16 | { |
| 17 | return false; |
| 18 | } |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 19 | else |
| 20 | { |
| 21 | i = v; |
| 22 | return true; |
| 23 | } |
| 24 | } |
| 25 | private: |
| 26 | container_t container; |
| 27 | }; |
| 28 | |
Brad Bishop | 03476f1 | 2016-12-19 13:09:12 -0500 | [diff] [blame] | 29 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |