TLM-2.0  2.0.4
Accellera TLM-2.0 proof-of-concept library
tlm_event_finder.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 #ifndef TLM_CORE_TLM_EVENT_FINDER_H_INCLUDED_
21 #define TLM_CORE_TLM_EVENT_FINDER_H_INCLUDED_
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 
45  virtual const sc_core::sc_event& find_event( sc_core::sc_interface* if_p = 0 ) const;
46 
47 private:
48 
49  const sc_core::sc_event& (IF::*m_event_method) ( tlm_tag<T> * ) const;
50 
51 private:
52 
53  // disabled
57 };
58 
59 
60 template <class IF , class T>
61 inline
62 const sc_core::sc_event&
64 {
65  const IF* iface = ( if_p ) ? dynamic_cast<const IF*>( if_p ) :
66  dynamic_cast<const IF*>( port().get_interface() );
67  if( iface == 0 ) {
68  report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
70  }
71  return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
72 }
73 
74 } // namespace tlm
75 
76 #endif // TLM_CORE_TLM_EVENT_FINDER_H_INCLUDED_
virtual const sc_core::sc_event & find_event(sc_core::sc_interface *if_p=0) const
static const sc_event none
tlm_event_finder_t(const sc_core::sc_port_base &port_, const sc_core::sc_event &(IF::*event_method_)(tlm_tag< T > *) const)
virtual sc_interface * get_interface()=0
const sc_port_base & port() const
sc_event_finder(const sc_port_base &)
void report_error(const char *id, const char *add_msg=0) const