src/sysc/utils/sc_report_handler.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_report_handler.h - 
00021 
00022   Original Author: Alex Riesen, Synopsys, Inc.
00023   see also sc_report.h
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_REPORT_HANDLER_H
00038 #define SC_REPORT_HANDLER_H
00039 
00040 namespace sc_core {
00041 
00042 // ----------------------------------------------------------------------------
00043 //  STRUCT : sc_msg_def
00044 //
00045 //  Exception message definition structure
00046 // ----------------------------------------------------------------------------
00047 
00048 struct sc_msg_def
00049 {
00050     const char*  msg_type;
00051     sc_actions   actions;
00052     sc_actions   sev_actions[SC_MAX_SEVERITY];
00053     unsigned     limit;
00054     unsigned     sev_limit[SC_MAX_SEVERITY];
00055     unsigned     limit_mask; // 0 - limit, 1..4 - sev_limit
00056     unsigned     call_count;
00057     unsigned     sev_call_count[SC_MAX_SEVERITY];
00058     char*        msg_type_data;
00059 
00060     int          id; // backward compatibility with 2.0+
00061 };
00062 
00063 typedef void (* sc_report_handler_proc)(const sc_report&, const sc_actions &);
00064 class sc_report;
00065 extern bool sc_report_close_default_log();
00066 class sc_report_handler
00067 {
00068 public:
00069     static void report(sc_severity,
00070                        const char* msg_type,
00071                        const char* msg,
00072                        const char* file,
00073                        int line);
00074 
00075     static sc_actions set_actions(sc_severity,
00076                                   sc_actions = SC_UNSPECIFIED);
00077 
00078     static sc_actions set_actions(const char * msg_type,
00079                                   sc_actions = SC_UNSPECIFIED);
00080 
00081     static sc_actions set_actions(const char * msg_type,
00082                                   sc_severity,
00083                                   sc_actions = SC_UNSPECIFIED);
00084 
00085     static int stop_after(sc_severity, int limit = -1);
00086     static int stop_after(const char* msg_type, int limit = -1);
00087     static int stop_after(const char* msg_type, sc_severity, int limit = -1);
00088 
00089     static sc_actions suppress(sc_actions);
00090     static sc_actions suppress();
00091     static sc_actions force(sc_actions);
00092     static sc_actions force();
00093 
00094     static int get_count(sc_severity severity_);
00095     static int get_count(const char* msg_type_);
00096     static int get_count(const char* msg_type_, 
00097         sc_severity severity_);
00098 
00099     static void initialize(); // just reset counters
00100     static void release(); // initialize() needed for reports after it
00101 
00102     static void set_handler(sc_report_handler_proc);
00103     // use set_handler(&sc_report_handler::default_handler); to restore
00104     static void default_handler(const sc_report&, const sc_actions&);
00105 
00106     static sc_actions get_new_action_id();
00107 
00108     static sc_report* get_cached_report();
00109     static void clear_cached_report();
00110 
00111     // if filename is NULL, the previous log file name will be removed.
00112     // The provider of a report_handler supposed to handle this.
00113     // Return false if filename is not NULL and filename is already set.
00114     static bool set_log_file_name(const char* filename);
00115     static const char* get_log_file_name();
00116 
00117 public: // private, actually
00118 
00119     struct msg_def_items
00120     {
00121         sc_msg_def*     md;        // have to point to sc_msg_def-s
00122         int             count;     // set to number of items in md[]
00123         bool            allocated; // used internally, previous value ignored
00124         msg_def_items*  next;      // used internally, previous value ignored
00125     };
00126 
00127     static void add_static_msg_types(msg_def_items *);
00128     static sc_msg_def* add_msg_type(const char * msg_type);
00129 
00130 protected:
00131 
00132     static void cache_report(const sc_report&);
00133     static sc_actions execute(sc_msg_def*, sc_severity);
00134 
00135     static sc_actions   suppress_mask;
00136     static sc_actions   force_mask;
00137     static sc_actions   sev_actions[SC_MAX_SEVERITY];
00138     static unsigned     sev_limit[SC_MAX_SEVERITY];
00139     static unsigned     sev_call_count[SC_MAX_SEVERITY];
00140     static sc_report*   last_global_report;
00141     static sc_actions   available_actions;
00142     static char*        log_file_name;
00143 
00144     static msg_def_items*  messages;
00145     static msg_def_items   msg_terminator;
00146 
00147     static sc_report_handler_proc  handler;
00148 
00149     static sc_msg_def* mdlookup(const char* msg_type);
00150 
00151 private: // backward compatibility with 2.0+
00152 
00153     friend class sc_report;
00154     static sc_msg_def* mdlookup(int id);
00155 
00156 public:
00157 
00158     static void report(sc_severity,
00159                        int         id,
00160                        const char* add_msg,
00161                        const char* file,
00162                        int         line);
00163 
00164 };
00165 
00166 } // namespace sc_core
00167 
00168 #endif
00169 
00170 // Taf!

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