#ifndef __BASE_CARD__
#define __BASE_CARD__

#include "base_data.h"
#include "classdef.h"
class Card;


struct  position_interface
{
	virtual point_2 get_position()=0;
	virtual bool save_point() = 0;
};


struct card:position_interface
{
	const static int MAX_HIS_LOCATION=100;

	std::weak_ptr<position_interface> m_pi;

	std::shared_ptr<Card> m_card;
	//
	area * m_area;
	//
	deque<st_coord> ori_list_;
	//
	//fixed_deque<point_2> view_list_;
	/********************************/
	//get point.
	/********************************/
	st_coord  pin_point(uint16_t &ct)
	{
		st_coord stc;
		stc.m_ct = m_card->time_center_stamp;//ct
		if (ct == stc.m_ct)
		{
			//
			return stc;
		}
		stc.x_ = m_card->origin_locate.x ;
		stc.y_ = m_card->origin_locate.y ;
		stc.gen_time_ = m_card->m_ct_time - m_Start_time; //时间精确到ms
		//debug_print_syslog(0,"[framework pin_point_1]cardId:%s,x:%.2f,y:%.2f,t:%ld",m_card->card_id.c_str(),stc.x_,stc.y_,stc.gen_time_);
		//判断来的数据是否有效。
	
		ct = stc.m_ct;
		ori_list_.push_back(stc);

		if(ori_list_.size()>MAX_HIS_LOCATION)
		{
			ori_list_.pop_front();
		}

		return stc;
	}

	void set_position_interface(std::shared_ptr<position_interface>  ptr)
	{
		m_pi=ptr;
	}

	virtual point_2 get_position()
	{
		point_2 p;
		if (auto mp = m_pi.lock())
		{
			p = mp->get_position();
		}
		return p;
	}

	virtual bool save_point()
	{
		bool b = false;
		if (auto mp = m_pi.lock())
		{
			b = mp->save_point();
		}
		return b;
		//return (m_pi.lock())->save_point();
	}

};


struct person : card
{
	time_t enter_time_;
};

#endif