#ifndef MODULE_OVER_SPEED_VEHICLE_H #define MODULE_OVER_SPEED_VEHICLE_H /** *@brief 车卡超速模块 * @author 戴月腾 * @date 2018-08-08 */ #include #include "module_singleton_base.h" #include "card.h" /** * @brief 区域超速类。当某张车卡速度超过某个区域的最大速度时,发出告警, 单例 */ class module_over_speed_vehicle:public singleton_base { private: friend class singleton_base; module_over_speed_vehicle() { } public: void on_hover(std::shared_ptr card_ptr, int vehicle_category_id); void init_vehicle_category_from_db(); private: bool is_over_speed(int category_id, double speed) { auto serch = _vehicle_category_map.find(category_id); if(serch == _vehicle_category_map.end()) { return false; } return serch->second <= speed; } double limit_speed(int category_id) const { auto serch = _vehicle_category_map.find(category_id); if(serch == _vehicle_category_map.end()) { return 0; } return serch->second; } private: std::unordered_map _vehicle_category_map; }; #endif // MODULE_OVER_SPEED_VEHICLE_H