#ifndef __MONKEYCAR_AREA__
#define __MONKEYCAR_AREA__

#include "base_area.h"
#include "base_data.h"
#include "base_card.h"

#include "fp_path.h"
#include "monkeycar_person.h"
#include "monkeycar_bus.h"
#include "cacti/kernel/Mutex.h"



struct monkey_area : area
{
	typedef cacti::RecursiveMutex::ScopedLock ScopedLock;
public:
	monkey_area(std::shared_ptr<db_area> db_area_ptr);
	~monkey_area()
	{
		//debug_print_syslog(0,"[framework monkeycar_area] del");
	}
	std::shared_ptr<monkey_person> find(std::string cardid);

	virtual void updata_position()
	{
		for(auto bus:bus_)
			bus->updata_position();
	}

	virtual void on_card_leave(const std::string& cardid, int next_area);

	virtual void on_card_enter(std::shared_ptr<Card> &ccard, int prev_area);

	virtual void on_card_move(std::shared_ptr<Card> &card);

	
	inline  double map(double x, double y)
	{
		return m_path.map(x,y);
	}
	inline point_2 map(double d)
	{
		return m_path.map(d);
	}
	inline double get_total_length()
	{
		return m_path.get_total_length();
	}
private:

	std::map<std::string,std::shared_ptr<monkey_person>> card_map_;
	std::vector<std::shared_ptr<monkey_bus>> bus_;
	POS_21::fp_path m_path;
	cacti::RecursiveMutex m_monitor;
};


#endif