| 1 | \r |
| 2 | /*****************************************************************************\r |
| 3 | \r |
| 4 | The following code is derived, directly or indirectly, from the SystemC\r |
| 5 | source code Copyright (c) 1996-2004 by all Contributors.\r |
| 6 | All Rights reserved.\r |
| 7 | \r |
| 8 | The contents of this file are subject to the restrictions and limitations\r |
| 9 | set forth in the SystemC Open Source License Version 2.4 (the "License");\r |
| 10 | You may not use this file except in compliance with such restrictions and\r |
| 11 | limitations. You may obtain instructions on how to receive a copy of the\r |
| 12 | License at http://www.systemc.org/. Software distributed by Contributors\r |
| 13 | under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF\r |
| 14 | ANY KIND, either express or implied. See the License for the specific\r |
| 15 | language governing rights and limitations under the License.\r |
| 16 | \r |
| 17 | *****************************************************************************/\r |
| 18 | \r |
| 19 | #ifndef TLM_EVENT_FINDER\r |
| 20 | #define TLM_EVENT_FINDER\r |
| 21 | \r |
| 22 | #include <systemc.h>\r |
| 23 | \r |
| 24 | #include "tlm_core/tlm_interfaces/tlm_tag.h"\r |
| 25 | \r |
| 26 | \r |
| 27 | template <class IF , class T>\r |
| 28 | class tlm_event_finder_t\r |
| 29 | : public sc_event_finder\r |
| 30 | {\r |
| 31 | public:\r |
| 32 | \r |
| 33 | // constructor\r |
| 34 | \r |
| 35 | tlm_event_finder_t( const sc_port_base& port_,\r |
| 36 | const sc_event& (IF::*event_method_) ( tlm_tag<T> * ) const )\r |
| 37 | : sc_event_finder( port_ ), m_event_method( event_method_ )\r |
| 38 | {}\r |
| 39 | \r |
| 40 | // destructor (does nothing)\r |
| 41 | \r |
| 42 | virtual ~tlm_event_finder_t()\r |
| 43 | {}\r |
| 44 | \r |
| 45 | virtual const sc_event& find_event() const;\r |
| 46 | \r |
| 47 | private:\r |
| 48 | \r |
| 49 | const sc_event& (IF::*m_event_method) ( tlm_tag<T> * ) const;\r |
| 50 | \r |
| 51 | private:\r |
| 52 | \r |
| 53 | // disabled\r |
| 54 | tlm_event_finder_t();\r |
| 55 | tlm_event_finder_t( const tlm_event_finder_t<IF,T>& );\r |
| 56 | tlm_event_finder_t<IF,T>& operator = ( const tlm_event_finder_t<IF,T>& );\r |
| 57 | };\r |
| 58 | \r |
| 59 | \r |
| 60 | template <class IF , class T>\r |
| 61 | inline\r |
| 62 | const sc_event&\r |
| 63 | tlm_event_finder_t<IF,T>::find_event() const\r |
| 64 | {\r |
| 65 | const IF* iface = DCAST<const IF*>( port().get_interface() );\r |
| 66 | if( iface == 0 ) {\r |
| 67 | report_error( SC_ID_FIND_EVENT_, "port is not bound" );\r |
| 68 | }\r |
| 69 | return (CCAST<IF*>( iface )->*m_event_method) ( 0 );\r |
| 70 | }\r |
| 71 | \r |
| 72 | #endif\r |