00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __TLM_EVENT_FINDER_H__
00019 #define __TLM_EVENT_FINDER_H__
00020
00021
00022
00023 #include "tlm_h/tlm_req_rsp/tlm_1_interfaces/tlm_tag.h"
00024
00025 namespace tlm {
00026
00027 template <class IF , class T>
00028 class tlm_event_finder_t
00029 : public sc_core::sc_event_finder
00030 {
00031 public:
00032
00033
00034
00035 tlm_event_finder_t( const sc_core::sc_port_base& port_,
00036 const sc_core::sc_event& (IF::*event_method_) ( tlm_tag<T> * ) const )
00037 : sc_core::sc_event_finder( port_ ), m_event_method( event_method_ )
00038 {}
00039
00040
00041
00042 virtual ‾tlm_event_finder_t()
00043 {}
00044 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00045 virtual const sc_core::sc_event& find_event( sc_core::sc_interface* if_p = 0 ) const;
00046 #else
00047 virtual const sc_core::sc_event& find_event() const;
00048 #endif
00049
00050 private:
00051
00052 const sc_core::sc_event& (IF::*m_event_method) ( tlm_tag<T> * ) const;
00053
00054 private:
00055
00056
00057 tlm_event_finder_t();
00058 tlm_event_finder_t( const tlm_event_finder_t<IF,T>& );
00059 tlm_event_finder_t<IF,T>& operator = ( const tlm_event_finder_t<IF,T>& );
00060 };
00061
00062
00063 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00064 template <class IF , class T>
00065 inline
00066 const sc_core::sc_event&
00067 tlm_event_finder_t<IF,T>::find_event( sc_core::sc_interface* if_p ) const
00068 {
00069 const IF* iface = ( if_p ) ? dynamic_cast<const IF*>( if_p ) :
00070 dynamic_cast<const IF*>( port().get_interface() );
00071 if( iface == 0 ) {
00072 report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
00073 }
00074 return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
00075 }
00076 #else
00077 template <class IF , class T>
00078 inline
00079 const sc_core::sc_event&
00080 tlm_event_finder_t<IF,T>::find_event() const
00081 {
00082 const IF* iface = dynamic_cast<const IF*>( port().get_interface() );
00083 if( iface == 0 ) {
00084 report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
00085 }
00086 return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
00087 }
00088 #endif
00089
00090 }
00091
00092 #endif