
#include <assert.h>

#include "area_business.h"
//#include "card_base.h"
//#include "area.h"
//#include "card.h"

#include "area_business_car_attendance.h"
#include "area_business_card_enter_or_leave.h"
#include "area_business_count_checker.h"
#include "area_business_forbid.h"
#include "area_business_person_dwell_checker.h"
#include "area_business_person_attendance.h"
#include "area_business_post_area.h"
#include "area_business_speed_checker.h"

/*
	猴车区域
*/
struct area_business_monkey_area:area_business
{
	virtual int area_business_type()
	{
		return 8;
	}
};


struct area_business_factory
{
	void regist(int type,area_business* ab)
	{
		if(type>=(int)m_check_list.size())
		{
			m_check_list.resize(type+1);
		}

		assert(!m_check_list[type]);

		m_check_list[type].reset(ab);
	}

	std::vector<area_business*> get_check_list(int business_type)
	{
		std::vector<area_business*> check_list;
		for(int i=0;i<32;i++)
		{
			if(business_type==0)
				break;

			if((business_type&1)==0)
				continue;

			check_list.push_back(m_check_list[i].get());
		}

		return std::move(check_list);
	}

	static area_business_factory& instance()
	{
		static area_business_factory _instance;
		return _instance;
	}
private:
	std::vector<std::unique_ptr<area_business>> m_check_list;
	area_business_factory()
	{
		regist(1,new area_business_post_area);
		regist(2,new area_business_person_dwell_checker);
		regist(3,new area_business_count_checker);
		regist(4,new area_business_speed_checker);
		regist(5,new area_business_person_attendance);
		regist(6,new area_business_car_attendance);
		regist(7,new area_business_forbid);
		//regist(8,new area_business_monkey_area);
		regist(9,new area_business_card_enter_or_leave);
	}

};

std::vector<area_business*> area_business::get_instance_list(int business_type)
{
	return area_business_factory::instance().get_check_list(business_type);
}

