#include #include "card_base.h" #include "area_business.h" struct area_business_factory { area_business_factory() { } void regist(int type,std::shared_ptr ab) { if(type>=(int)m_check_list.size()) { m_check_list.resize(type+1); } assert(m_check_list[type]); m_check_list[type]=ab; } std::vector> get_check_list(int business_type) { std::vector> check_list; for(int i=0,B=1;i<32;i++) { if((B&business_type)==0) continue; check_list.push_back(m_check_list[i]); } return std::move(m_check_list); } std::vector> m_check_list; static area_business_factory& instance() { static area_business_factory _instance; return _instance; } }; /* 判断车辆超速,确定超速后记录日志、数据库并告警 每张卡在每个区域的超速相关的数据信息记录在 area_hover 对象 人员&车辆的代码重用,请自行设计 */ struct area_business_speed_checker:area_business { //在area_hover对象中初始化超速检测所需的对象 virtual void on_enter(std::shared_ptr&a,std::shared_ptr&c) { } //根据超速检测的策略,进行超速判断,超速时进行告警 //建议使用最近M秒内N秒超时进行判断,M=20,N=15,策略数据记录在area_hove中 virtual void on_hover(std::shared_ptr&a,std::shared_ptr&c) { } //清除超速检测所需的对象 virtual void on_leave(std::shared_ptr&a,std::shared_ptr&c) { } }; /* 判断当前区域a中的人数是否超过设定人数,超过后告警 区域内实时人数存储在area对象中,在当前类on_enter/on_leave中进行更新 */ struct area_business_person_count_checker:area_business { //增加计数,并进行判断 virtual void on_enter(std::shared_ptr&a,std::shared_ptr&c) { } //减少计数 virtual void on_leave(std::shared_ptr&a,std::shared_ptr&c) { } }; //同人员计数 struct area_business_car_count_checker:area_business { virtual void on_enter(std::shared_ptr&a,std::shared_ptr&c) { } virtual void on_hover(std::shared_ptr&a,std::shared_ptr&c) { } virtual void on_leave(std::shared_ptr&a,std::shared_ptr&c) { } }; /* 判断当前区域a中的人卡停留时间 人员进入区域时间存储在area_hover对象中,在当前类on_enter/on_leave中进行更新 人员&车辆的代码重用,请自行设计 */ struct area_business_person_dwell_checker:area_business { //初始化 area_hover 的相关数据项 virtual void on_enter(std::shared_ptr&a,std::shared_ptr&c) { } //更新 area_hover 的相关数据项,并进行超时判断 virtual void on_hover(std::shared_ptr&a,std::shared_ptr&c) { } }; /* 判断逻辑同人员超时 */ struct area_business_car_dwell_checker:area_business { //初始化 area_hover 的相关数据项 virtual void on_enter(std::shared_ptr&a,std::shared_ptr&c) { } //更新 area_hover 的相关数据项,并进行超时判断 virtual void on_hover(std::shared_ptr&a,std::shared_ptr&c) { } }; std::vector> area_business::get_instance_list(int business_type) { return area_business_factory::instance().get_check_list(business_type); }