Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

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-2004 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.3 (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 "systemc/communication/sc_port.h"
00042 
00043 
00044 // ----------------------------------------------------------------------------
00045 //  CLASS : sc_event_finder
00046 //
00047 //  Event finder base class.
00048 // ----------------------------------------------------------------------------
00049 
00050 class sc_event_finder
00051 : public sc_event
00052 {
00053 public:
00054 
00055     const sc_port_base& port() const
00056         { return m_port; }
00057 
00058     // destructor (does nothing)
00059     virtual ~sc_event_finder();
00060 
00061     virtual const sc_event& find_event() const = 0;
00062 
00063 protected:
00064     
00065     // constructor
00066     sc_event_finder( const sc_port_base& );
00067 
00068     // error reporting
00069     void report_error( const char* id, const char* add_msg = 0 ) const;
00070 
00071 private:
00072 
00073     const sc_port_base& m_port;
00074 
00075 private:
00076 
00077     // disabled
00078     sc_event_finder();
00079     sc_event_finder( const sc_event_finder& );
00080     sc_event_finder& operator = ( const sc_event_finder& );
00081 };
00082 
00083 
00084 // ----------------------------------------------------------------------------
00085 //  CLASS : sc_event_finder_t<IF>
00086 //
00087 //  Interface specific event finder class.
00088 // ----------------------------------------------------------------------------
00089 
00090 template <class IF>
00091 class sc_event_finder_t
00092 : public sc_event_finder
00093 {
00094 public:
00095 
00096     // constructor
00097 
00098     sc_event_finder_t( const sc_port_base& port_,
00099            const sc_event& (IF::*event_method_) () const )
00100         : sc_event_finder( port_ ), m_event_method( event_method_ )
00101         {}
00102 
00103     // destructor (does nothing)
00104 
00105     virtual ~sc_event_finder_t()
00106         {}
00107 
00108     virtual const sc_event& find_event() const;
00109 
00110 private:
00111 
00112     const sc_event& (IF::*m_event_method) () const;
00113 
00114 private:
00115 
00116     // disabled
00117     sc_event_finder_t();
00118     sc_event_finder_t( const sc_event_finder_t<IF>& );
00119     sc_event_finder_t<IF>& operator = ( const sc_event_finder_t<IF>& );
00120 };
00121 
00122 
00123 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00124 
00125 template <class IF>
00126 inline
00127 const sc_event&
00128 sc_event_finder_t<IF>::find_event() const
00129 {
00130     const IF* iface = DCAST<const IF*>( port().get_interface() );
00131     if( iface == 0 ) {
00132   report_error( SC_ID_FIND_EVENT_, "port is not bound" );
00133     }
00134     return (CCAST<IF*>( iface )->*m_event_method) ();
00135 }
00136 
00137 
00138 #endif
00139 
00140 // Taf!

Generated on Fri Jan 14 08:29:01 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18