SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_event_finder.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_event_finder.h --
21 
22  Original Author: Martin Janssen, Synopsys, Inc.
23  Stan Y. Liao, Synopsys, Inc., 2001-05-21
24 
25  CHANGE LOG IS AT THE END OF THE FILE
26  *****************************************************************************/
27 
28 #ifndef SC_EVENT_FINDER
29 #define SC_EVENT_FINDER
30 
31 
33 
34 namespace sc_core {
35 
36 // ----------------------------------------------------------------------------
37 // CLASS : sc_event_finder
38 //
39 // Event finder base class.
40 // ----------------------------------------------------------------------------
41 
43 {
44  friend class sc_simcontext;
45 
46 public:
47 
48  const sc_port_base& port() const
49  { return m_port; }
50 
51  // destructor (does nothing)
52  virtual ~sc_event_finder();
53 
54  virtual const sc_event& find_event( sc_interface* if_p = 0 ) const = 0;
55 
56 protected:
57 
58  // constructor
59  sc_event_finder( const sc_port_base& );
60 
61  // error reporting
62  void report_error( const char* id, const char* add_msg = 0 ) const;
63 
64 
65 private:
66  const sc_port_base& m_port; // port providing the event.
67 
68 private:
69 
70  // disabled
73  sc_event_finder& operator = ( const sc_event_finder& );
74 };
75 
76 
77 // ----------------------------------------------------------------------------
78 // CLASS : sc_event_finder_t<IF>
79 //
80 // Interface specific event finder class.
81 // ----------------------------------------------------------------------------
82 
83 template <class IF>
85 : public sc_event_finder
86 {
87 public:
88 
89  // constructor
90 
92  const sc_event& (IF::*event_method_) () const )
93  : sc_event_finder( port_ ), m_event_method( event_method_ )
94  {}
95 
96  // destructor (does nothing)
97 
99  {}
100 
101  virtual const sc_event& find_event( sc_interface* if_p = 0 ) const;
102 
103 private:
104 
105  const sc_event& (IF::*m_event_method) () const;
106 
107 private:
108 
109  // disabled
112  sc_event_finder_t<IF>& operator = ( const sc_event_finder_t<IF>& );
113 };
114 
115 
116 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
117 
118 template <class IF>
119 inline
120 const sc_event&
122 {
123  const IF* iface = ( if_p ) ? DCAST<const IF*>( if_p ) :
124  DCAST<const IF*>( port().get_interface() );
125  if( iface == 0 ) {
126  report_error( SC_ID_FIND_EVENT_, "port is not bound" );
127  }
128  return (CCAST<IF*>( iface )->*m_event_method) ();
129 }
130 
131 } // namespace sc_core
132 
133 //$Log: sc_event_finder.h,v $
134 //Revision 1.3 2011/08/26 20:45:39 acg
135 // Andy Goodrich: moved the modification log to the end of the file to
136 // eliminate source line number skew when check-ins are done.
137 //
138 //Revision 1.2 2011/02/18 20:23:45 acg
139 // Andy Goodrich: Copyright update.
140 //
141 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
142 //SystemC 2.3
143 //
144 //Revision 1.4 2006/02/02 23:42:37 acg
145 // Andy Goodrich: implemented a much better fix to the sc_event_finder
146 // proliferation problem. This new version allocates only a single event
147 // finder for each port for each type of event, e.g., pos(), neg(), and
148 // value_change(). The event finder persists as long as the port does,
149 // which is what the LRM dictates. Because only a single instance is
150 // allocated for each event type per port there is not a potential
151 // explosion of storage as was true in the 2.0.1/2.1 versions.
152 //
153 //Revision 1.3 2006/02/02 20:43:09 acg
154 // Andy Goodrich: Added an existence linked list to sc_event_finder so that
155 // the dynamically allocated instances can be freed after port binding
156 // completes. This replaces the individual deletions in ~sc_bind_ef, as these
157 // caused an exception if an sc_event_finder instance was used more than
158 // once, due to a double freeing of the instance.
159 //
160 //Revision 1.2 2006/01/03 23:18:26 acg
161 //Changed copyright to include 2006.
162 //
163 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
164 //First check in of SystemC 2.1 into its own archive.
165 //
166 //Revision 1.10 2005/09/15 23:01:51 acg
167 //Added std:: prefix to appropriate methods and types to get around
168 //issues with the Edison Front End.
169 //
170 //Revision 1.9 2005/06/10 22:43:55 acg
171 //Added CVS change log annotation.
172 //
173 
174 #endif
175 
176 // Taf!
const sc_port_base & port() const
void report_error(const char *id, const char *add_msg=0) const
virtual const sc_event & find_event(sc_interface *if_p=0) const =0
virtual const sc_event & find_event(sc_interface *if_p=0) const
sc_event_finder_t(const sc_port_base &port_, const sc_event &(IF::*event_method_)() const )