|
@@ -21,7 +21,7 @@ struct card_location_base
|
|
|
{
|
|
|
std::shared_ptr<select_tool> m_sel_tool=nullptr;
|
|
|
std::shared_ptr<smooth_tool> m_smo_tool=nullptr;
|
|
|
- card_message_handle *m_message_handle=nullptr;
|
|
|
+ std::unique_ptr<card_message_handle> m_message_handle=nullptr;
|
|
|
card_location_base()=default;
|
|
|
card_location_base(std::string type)
|
|
|
{
|
|
@@ -161,6 +161,14 @@ struct card_message_handle
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ ~card_message_handle()
|
|
|
+ {
|
|
|
+ for(auto&it:m_ct_list)
|
|
|
+ {
|
|
|
+ delete it;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
|
|
|
{
|
|
|
if(is_history)
|
|
@@ -193,7 +201,7 @@ struct person:card_location_base,card_area
|
|
|
person(std::string type)
|
|
|
:card_location_base(type)
|
|
|
{
|
|
|
- m_message_handle = new card_message_handle(this);
|
|
|
+ m_message_handle .reset(new card_message_handle(this));
|
|
|
}
|
|
|
|
|
|
void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
|
|
@@ -207,7 +215,7 @@ struct car:card_location_base,card_area
|
|
|
car(std::string type)
|
|
|
:card_location_base(type)
|
|
|
{
|
|
|
- m_message_handle = new card_message_handle(this);
|
|
|
+ m_message_handle .reset(new card_message_handle(this));
|
|
|
}
|
|
|
void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
|
|
|
{
|
|
@@ -217,33 +225,28 @@ struct car:card_location_base,card_area
|
|
|
|
|
|
loc_tool_main one_ct_message_handle::m_loc_tool;
|
|
|
|
|
|
-struct card_list_impl:card_list
|
|
|
+void card_list::init_card_from_db()
|
|
|
{
|
|
|
- card_list_impl()
|
|
|
- {
|
|
|
- }
|
|
|
+ card_list::
|
|
|
+ instance()->add(0,std::make_shared<car>(""));
|
|
|
+}
|
|
|
|
|
|
- void init_card_from_db()
|
|
|
- {
|
|
|
- }
|
|
|
+void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history)
|
|
|
+{
|
|
|
+ std::shared_ptr<card_location_base> c=get(loc.long_id());
|
|
|
|
|
|
- void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history)
|
|
|
+ if(c==nullptr)
|
|
|
{
|
|
|
- std::shared_ptr<card_location_base> c=get(loc.long_id());
|
|
|
-
|
|
|
- if(c==nullptr)
|
|
|
- {
|
|
|
- log_warn("数据库中未定义该卡的信息,type=%d,card_id=%d", loc.m_card_type, loc.m_card_id);
|
|
|
- return;
|
|
|
- }
|
|
|
+ log_warn("数据库中未定义该卡的信息,type=%d,card_id=%d", loc.m_card_type, loc.m_card_id);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d,stamp=%llu",
|
|
|
- loc.m_site_id,loc.m_ant_id,loc.m_card_id,loc.m_tof,loc.m_rav,loc.m_acc,loc.m_rssi,loc.m_time_stamp);
|
|
|
+ log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d,stamp=%llu",
|
|
|
+ loc.m_site_id,loc.m_ant_id,loc.m_card_id,loc.m_tof,loc.m_rav,loc.m_acc,loc.m_rssi,loc.m_time_stamp);
|
|
|
|
|
|
- c->on_message(loop,loc,is_history);
|
|
|
- }
|
|
|
-};
|
|
|
+ c->on_message(loop,loc,is_history);
|
|
|
+}
|
|
|
|
|
|
template<> std::shared_ptr<card_list>
|
|
|
-single_base<card_list, int64_t, std::shared_ptr<card_location_base>>::m_instance=std::make_shared<card_list_impl>();
|
|
|
+single_base<card_list, int64_t, std::shared_ptr<card_location_base>>::m_instance=std::make_shared<card_list>();
|
|
|
|