src/sysc/communication/sc_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-2005 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 2.4 (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 /*****************************************************************************
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  *****************************************************************************/
00026 
00027 /*****************************************************************************
00028 
00029   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00030   changes you are making here.
00031 
00032       Name, Affiliation, Date:
00033   Description of Modification:
00034     
00035  *****************************************************************************/
00036 
00037 #ifndef SC_EVENT_FINDER
00038 #define SC_EVENT_FINDER
00039 
00040 
00041 #include "sysc/communication/sc_port.h"
00042 
00043 namespace sc_core {
00044 
00045 // ----------------------------------------------------------------------------
00046 //  CLASS : sc_event_finder
00047 //
00048 //  Event finder base class.
00049 // ----------------------------------------------------------------------------
00050 
00051 class sc_event_finder
00052 : public sc_event
00053 {
00054 public:
00055 
00056     const sc_port_base& port() const
00057         { return m_port; }
00058 
00059     // destructor (does nothing)
00060     virtual ~sc_event_finder();
00061 
00062     virtual const sc_event& find_event() const = 0;
00063 
00064 protected:
00065     
00066     // constructor
00067     sc_event_finder( const sc_port_base& );
00068 
00069     // error reporting
00070     void report_error( const char* id, const char* add_msg = 0 ) const;
00071 
00072 private:
00073 
00074     const sc_port_base& m_port;
00075 
00076 private:
00077 
00078     // disabled
00079     sc_event_finder();
00080     sc_event_finder( const sc_event_finder& );
00081     sc_event_finder& operator = ( const sc_event_finder& );
00082 };
00083 
00084 
00085 // ----------------------------------------------------------------------------
00086 //  CLASS : sc_event_finder_t<IF>
00087 //
00088 //  Interface specific event finder class.
00089 // ----------------------------------------------------------------------------
00090 
00091 template <class IF>
00092 class sc_event_finder_t
00093 : public sc_event_finder
00094 {
00095 public:
00096 
00097     // constructor
00098 
00099     sc_event_finder_t( const sc_port_base& port_,
00100                        const sc_event& (IF::*event_method_) () const )
00101         : sc_event_finder( port_ ), m_event_method( event_method_ )
00102         {}
00103 
00104     // destructor (does nothing)
00105 
00106     virtual ~sc_event_finder_t()
00107         {}
00108 
00109     virtual const sc_event& find_event() const;
00110 
00111 private:
00112 
00113     const sc_event& (IF::*m_event_method) () const;
00114 
00115 private:
00116 
00117     // disabled
00118     sc_event_finder_t();
00119     sc_event_finder_t( const sc_event_finder_t<IF>& );
00120     sc_event_finder_t<IF>& operator = ( const sc_event_finder_t<IF>& );
00121 };
00122 
00123 
00124 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00125 
00126 template <class IF>
00127 inline
00128 const sc_event&
00129 sc_event_finder_t<IF>::find_event() const
00130 {
00131     const IF* iface = DCAST<const IF*>( port().get_interface() );
00132     if( iface == 0 ) {
00133         report_error( SC_ID_FIND_EVENT_, "port is not bound" );
00134     }
00135     return (CCAST<IF*>( iface )->*m_event_method) ();
00136 }
00137 
00138 } // namespace sc_core
00139 
00140 #endif
00141 
00142 // Taf!

Generated on Wed Apr 25 13:53:25 2007 for SystemC by  doxygen 1.5.1