| 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>, | ||||
| 10 | int> container_t; | ||||
| 11 | |||||
| 12 | bool update(const container_t::key_type& k, | ||||
| 13 | const container_t::mapped_type& v) | ||||
| 14 | { | ||||
| 15 | auto& i = container[k]; | ||||
| 16 | if (v == i) return false; | ||||
| 17 | else | ||||
| 18 | { | ||||
| 19 | i = v; | ||||
| 20 | return true; | ||||
| 21 | } | ||||
| 22 | } | ||||
| 23 | private: | ||||
| 24 | container_t container; | ||||
| 25 | }; | ||||
| 26 | |||||
| 27 | #endif | ||||