26 27namespace tlm 28{ 29 30template <class IF, class T> 31class tlm_event_finder_t : public sc_core::sc_event_finder 32{ 33 public: 34 tlm_event_finder_t(const sc_core::sc_port_base &port_, 35 const sc_core::sc_event &(IF::*event_method_)( 36 tlm_tag<T> *) const) : 37 sc_core::sc_event_finder(port_), m_event_method(event_method_) 38 {} 39 40 virtual ~tlm_event_finder_t() {} 41 42 virtual const sc_core::sc_event & 43 find_event(sc_core::sc_interface *if_p=nullptr) const; 44 45 private: 46 const sc_core::sc_event &(IF::*m_event_method)(tlm_tag<T> *) const; 47 48 private: 49 // disabled 50 tlm_event_finder_t(); 51 tlm_event_finder_t(const tlm_event_finder_t<IF, T> &); 52 tlm_event_finder_t<IF, T> &operator = (const tlm_event_finder_t<IF, T> &); 53}; 54 55template <class IF, class T> 56inline const sc_core::sc_event & 57tlm_event_finder_t<IF, T>::find_event(sc_core::sc_interface *if_p) const 58{ 59 const IF *iface = if_p ? dynamic_cast<const IF *>(if_p) : 60 dynamic_cast<const IF *>(port()->_gem5Interface(0)); 61 if (iface == nullptr) { 62 std::ostringstream out; 63 out << "port is not bound: port '" << port()->name() << 64 "' (" << port()->kind() << ")"; 65 SC_REPORT_ERROR(sc_core::SC_ID_FIND_EVENT_, out.str().c_str()); 66 static sc_core::sc_event none; 67 return none; 68 } 69 return (const_cast<IF *>(iface)->*m_event_method)(nullptr); 70} 71 72} // namespace tlm 73 74#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_EVENT_FINDER_HH__ */
|