TLM-2.0  2.0.3
Accellera TLM-2.0 proof-of-concept library
tlm_event_finder.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 #ifndef __TLM_EVENT_FINDER_H__
19 #define __TLM_EVENT_FINDER_H__
20 
21 //#include <systemc>
22 
24 
25 namespace tlm {
26 
27 template <class IF , class T>
30 {
31 public:
32 
33  // constructor
34 
36  const sc_core::sc_event& (IF::*event_method_) ( tlm_tag<T> * ) const )
37  : sc_core::sc_event_finder( port_ ), m_event_method( event_method_ )
38  {}
39 
40  // destructor (does nothing)
41 
43  {}
44 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
45  virtual const sc_core::sc_event& find_event( sc_core::sc_interface* if_p = 0 ) const;
46 #else
47  virtual const sc_core::sc_event& find_event() const;
48 #endif
49 
50 private:
51 
52  const sc_core::sc_event& (IF::*m_event_method) ( tlm_tag<T> * ) const;
53 
54 private:
55 
56  // disabled
60 };
61 
62 
63 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
64 template <class IF , class T>
65 inline
66 const sc_core::sc_event&
68 {
69  const IF* iface = ( if_p ) ? dynamic_cast<const IF*>( if_p ) :
70  dynamic_cast<const IF*>( port().get_interface() );
71  if( iface == 0 ) {
72  report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
73  }
74  return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
75 }
76 #else
77 template <class IF , class T>
78 inline
79 const sc_core::sc_event&
81 {
82  const IF* iface = dynamic_cast<const IF*>( port().get_interface() );
83  if( iface == 0 ) {
84  report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
85  }
86  return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
87 }
88 #endif
89 
90 } // namespace tlm
91 
92 #endif
sc_event_finder(const sc_port_base &)
tlm_event_finder_t(const sc_core::sc_port_base &port_, const sc_core::sc_event &(IF::*event_method_)(tlm_tag< T > *) const )
virtual const sc_core::sc_event & find_event(sc_core::sc_interface *if_p=0) const