C:/ESLX/projects/TLMWG/tlm2/include/tlm/tlm_h/tlm_req_rsp/tlm_ports/tlm_event_finder.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2008 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 3.0 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 #ifndef __TLM_EVENT_FINDER_H__
00019 #define __TLM_EVENT_FINDER_H__
00020 
00021 //#include <systemc>
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     // constructor
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     // destructor (does nothing)
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     // disabled
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 } // namespace tlm
00091 
00092 #endif

Generated on Thu Jun 5 17:43:03 2008 for TLM 2 by  doxygen 1.5.3