00001 00002 class completion_notify : public service_base { 00003 public: 00007 virtual void on_completion(unsigned p_code) = 0; 00008 00010 void on_completion_async(unsigned p_code); 00011 00013 static void g_signal_completion_async(service_ptr_t<completion_notify> p_notify,unsigned p_code); 00014 00015 FB2K_MAKE_SERVICE_INTERFACE(completion_notify,service_base); 00016 }; 00017 00019 class completion_notify_orphanable : public completion_notify { 00020 public: 00021 virtual void orphan() = 0; 00022 }; 00023 00026 template<typename t_receiver> 00027 class completion_notify_impl : public completion_notify_orphanable { 00028 public: 00029 void on_completion(unsigned p_code) { 00030 if (m_receiver != NULL) { 00031 m_receiver->on_task_completion(m_taskid,p_code); 00032 } 00033 } 00034 void setup(t_receiver * p_receiver, unsigned p_task_id) {m_receiver = p_receiver; m_taskid = p_task_id;} 00035 void orphan() {m_receiver = NULL; m_taskid = 0;} 00036 private: 00037 t_receiver * m_receiver; 00038 unsigned m_taskid; 00039 }; 00040 00041 template<typename t_receiver> 00042 service_ptr_t<completion_notify_orphanable> completion_notify_create(t_receiver * p_receiver,unsigned p_taskid) { 00043 service_ptr_t<completion_notify_impl<t_receiver> > instance = new service_impl_t<completion_notify_impl<t_receiver> >(); 00044 instance->setup(p_receiver,p_taskid); 00045 return instance; 00046 } 00047 00048 typedef service_ptr_t<completion_notify> completion_notify_ptr;
1.5.5