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

Generated on Wed Jan 21 15:32:10 2009 for SystemC by  doxygen 1.5.5