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