src/sysc/kernel/sc_process_host.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_process_host.h -- Declarations for sc_process_host class.
00021 
00022   Original Author: Andy Goodrich, Forte Design Systems, 11 May 2003
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028     MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029     changes you are making here.
00030 
00031         Name, Affiliation, Date:
00032     Description of Modification:
00033 
00034  *****************************************************************************/
00035 
00036 #ifndef SC_PROCESS_HOST_H
00037 #define SC_PROCESS_HOST_H
00038 
00039 #include "sysc/kernel/sc_object.h"
00040 
00041 namespace sc_core {
00042 
00043 // -----------------------------------------------------------------------------
00044 // CLASS sc_process_host
00045 //
00046 // This is the base class for objects which may have processes defined for
00047 // their methods (e.g., sc_module)
00048 // -----------------------------------------------------------------------------
00049 
00050 class sc_process_host : public sc_object
00051 {
00052 
00053   public:
00054         sc_process_host(const char* nm=0) : sc_object(nm)
00055         {}
00056         ~sc_process_host() { }
00057         void defunct() {}
00058 };
00059 
00060 
00061 // -----------------------------------------------------------------------------
00062 // CLASS sc_process_monitor
00063 //
00064 // This class provides a way of monitoring a process' status (e.g., waiting 
00065 // for a thread to complete its execution.) This class is intended to be a base
00066 // class for classes which need to monitor a process or processes (e.g.,
00067 // sc_join.) Its methods should be overloaded where notifications are desired.
00068 // -----------------------------------------------------------------------------
00069 
00070 class sc_process_monitor {
00071   public:
00072         enum {
00073                 spm_exit = 0
00074         };
00075     virtual void signal(sc_thread_handle thread_p, int type);  
00076 };
00077 
00078 // -----------------------------------------------------------------------------
00079 // SUPPORT FOR PROCESS INVOCATION IF CASTS TO void (sc_process_host::*)() ARE
00080 // NOT ALLOWED
00081 // -----------------------------------------------------------------------------
00082 #if !defined(SC_USE_MEMBER_FUNC_PTR)
00083 
00084         template<class T>
00085         sc_method_handle sc_create_dynamic_method( 
00086                 const char* name, T* host_p, void (T::*method_p)(), 
00087                 bool dont_initialize = false
00088         ) {
00089                 sc_simcontext* simc = sc_get_curr_simcontext();
00090                 return simc->create_dynamic_method_process(
00091                   name, (SC_ENTRY_FUNC)(new sc_process_call<T>(method_p)),
00092                   host_p, dont_initialize);
00093          }
00094 
00095 
00096         template<class T>
00097         sc_thread_handle sc_create_dynamic_thread( 
00098                 const char* name, T* host_p, void (T::*method_p)(), 
00099                 int stk_size = 0, bool dont_initialize = false
00100         ) {
00101                 sc_simcontext* simc = sc_get_curr_simcontext();
00102                 return simc->create_dynamic_thread_process(
00103                   name, (SC_ENTRY_FUNC)(new sc_process_call<T>(method_p)),
00104                   host_p, stk_size, dont_initialize);
00105          }
00106 
00107 
00108 // -----------------------------------------------------------------------------
00109 // SUPPORT FOR PROCESS INVOCATION IF CASTS TO void (sc_process_host::*)() ARE
00110 // LEGAL
00111 // -----------------------------------------------------------------------------
00112 # else
00113 
00114         template<class T>
00115         sc_method_handle sc_create_dynamic_method( 
00116                 const char* name, T* host_p, void (T::*method_p)(), 
00117                 bool dont_initialize = false
00118         ) {
00119                 sc_simcontext* simc = sc_get_curr_simcontext();
00120                 return simc->create_dynamic_method_process(
00121                   name, (SC_ENTRY_FUNC)method_p,
00122                   host_p, dont_initialize);
00123          }
00124 
00125         template<class T>
00126         sc_thread_handle sc_create_dynamic_thread( 
00127                 const char* name, T* host_p, void (T::*method_p)(), 
00128                 int stk_size = 0, bool dont_initialize = false
00129         ) {
00130                 sc_simcontext* simc = sc_get_curr_simcontext();
00131                 return simc->create_dynamic_thread_process(
00132                   name, (SC_ENTRY_FUNC)method_p,
00133                   host_p, stk_size, dont_initialize);
00134          }
00135 
00136 
00137 #endif // !defined(SC_USE_MEMBER_FUNC_PTR)
00138 
00139 } // namespace sc_core
00140 
00141 #endif // SC_PROCESS_HOST_H
00142 

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