00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 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 (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.accellera.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 /***************************************************************************** 00019 00020 sc_event_finder.h -- 00021 00022 Original Author: Martin Janssen, Synopsys, Inc. 00023 Stan Y. Liao, Synopsys, Inc., 2001-05-21 00024 00025 CHANGE LOG IS AT THE END OF THE FILE 00026 *****************************************************************************/ 00027 00028 #ifndef SC_EVENT_FINDER 00029 #define SC_EVENT_FINDER 00030 00031 00032 #include "sysc/communication/sc_port.h" 00033 00034 namespace sc_core { 00035 00036 /**************************************************************************/ 00042 class sc_event_finder 00043 { 00044 friend class sc_simcontext; 00045 00046 public: 00047 00048 const sc_port_base& port() const 00049 { return m_port; } 00050 00051 // destructor (does nothing) 00052 virtual ~sc_event_finder(); 00053 00054 virtual const sc_event& find_event( sc_interface* if_p = 0 ) const = 0; 00055 00056 protected: 00057 00058 // constructor 00059 sc_event_finder( const sc_port_base& ); 00060 00061 // error reporting 00062 void report_error( const char* id, const char* add_msg = 0 ) const; 00063 00064 00065 private: 00066 const sc_port_base& m_port; // port providing the event. 00067 00068 private: 00069 00070 // disabled 00071 sc_event_finder(); 00072 sc_event_finder( const sc_event_finder& ); 00073 sc_event_finder& operator = ( const sc_event_finder& ); 00074 }; 00075 00076 00077 /**************************************************************************/ 00083 template <class IF> 00084 class sc_event_finder_t 00085 : public sc_event_finder 00086 { 00087 public: 00088 00089 // constructor 00090 00091 sc_event_finder_t( const sc_port_base& port_, 00092 const sc_event& (IF::*event_method_) () const ) 00093 : sc_event_finder( port_ ), m_event_method( event_method_ ) 00094 {} 00095 00096 // destructor (does nothing) 00097 00098 virtual ~sc_event_finder_t() 00099 {} 00100 00101 virtual const sc_event& find_event( sc_interface* if_p = 0 ) const; 00102 00103 private: 00104 00105 const sc_event& (IF::*m_event_method) () const; 00106 00107 private: 00108 00109 // disabled 00110 sc_event_finder_t(); 00111 sc_event_finder_t( const sc_event_finder_t<IF>& ); 00112 sc_event_finder_t<IF>& operator = ( const sc_event_finder_t<IF>& ); 00113 }; 00114 00115 00116 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 00117 00118 template <class IF> 00119 inline 00120 const sc_event& 00121 sc_event_finder_t<IF>::find_event( sc_interface* if_p ) const 00122 { 00123 const IF* iface = ( if_p ) ? DCAST<const IF*>( if_p ) : 00124 DCAST<const IF*>( port().get_interface() ); 00125 if( iface == 0 ) { 00126 report_error( SC_ID_FIND_EVENT_, "port is not bound" ); 00127 } 00128 return (CCAST<IF*>( iface )->*m_event_method) (); 00129 } 00130 00131 } // namespace sc_core 00132 00133 //$Log: sc_event_finder.h,v $ 00134 //Revision 1.3 2011/08/26 20:45:39 acg 00135 // Andy Goodrich: moved the modification log to the end of the file to 00136 // eliminate source line number skew when check-ins are done. 00137 // 00138 //Revision 1.2 2011/02/18 20:23:45 acg 00139 // Andy Goodrich: Copyright update. 00140 // 00141 //Revision 1.1.1.1 2006/12/15 20:20:04 acg 00142 //SystemC 2.3 00143 // 00144 //Revision 1.4 2006/02/02 23:42:37 acg 00145 // Andy Goodrich: implemented a much better fix to the sc_event_finder 00146 // proliferation problem. This new version allocates only a single event 00147 // finder for each port for each type of event, e.g., pos(), neg(), and 00148 // value_change(). The event finder persists as long as the port does, 00149 // which is what the LRM dictates. Because only a single instance is 00150 // allocated for each event type per port there is not a potential 00151 // explosion of storage as was true in the 2.0.1/2.1 versions. 00152 // 00153 //Revision 1.3 2006/02/02 20:43:09 acg 00154 // Andy Goodrich: Added an existence linked list to sc_event_finder so that 00155 // the dynamically allocated instances can be freed after port binding 00156 // completes. This replaces the individual deletions in ~sc_bind_ef, as these 00157 // caused an exception if an sc_event_finder instance was used more than 00158 // once, due to a double freeing of the instance. 00159 // 00160 //Revision 1.2 2006/01/03 23:18:26 acg 00161 //Changed copyright to include 2006. 00162 // 00163 //Revision 1.1.1.1 2005/12/19 23:16:43 acg 00164 //First check in of SystemC 2.1 into its own archive. 00165 // 00166 //Revision 1.10 2005/09/15 23:01:51 acg 00167 //Added std:: prefix to appropriate methods and types to get around 00168 //issues with the Edison Front End. 00169 // 00170 //Revision 1.9 2005/06/10 22:43:55 acg 00171 //Added CVS change log annotation. 00172 // 00173 00174 #endif 00175 00176 // Taf!