Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4FFGDebuggingMacros.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * File:   G4FFGDebuggingMacros.hh
0028  * Author: B. Wendt (wendbryc@isu.edu)
0029  *
0030  * Created on August 17, 2012, 12:54
0031  */
0032 
0033 #ifndef G4FFGDEBUGGINGMACROS_HH
0034 #define G4FFGDEBUGGINGMACROS_HH
0035 
0036 #include "G4FFGEnumerations.hh"
0037 #include "G4FFGVerboseMacros.hh"
0038 #include "globals.hh"
0039 
0040 // Define the function as available by the compiler
0041 #if defined(__GNUC__)
0042 #  define G4FFG_FUNCTION_SIGNATURE__ G4String(__func__) + "()"
0043 #elif defined(_MSC_VER)
0044 // I'm not sure if this is the correct syntax for MS VC
0045 #  define G4FFG_FUNCTION_SIGNATURE__ G4String(__FUNCTION__) + "()"
0046 #else
0047 #  define G4FFG_FUNCTION_SIGNATURE__ "a function"
0048 #endif
0049 
0050 // Only define the variables and macros if G4DEBUG_VERBOSE is set
0051 #if defined(G4DEBUG_VERBOSE)
0052 /** G4FFGDEBUG_RECURSIVE_REPRESSION is used to aid in the repression of
0053  *  debugging messages from recursive function calls.
0054  */
0055 extern G4long G4FFGDEBUG_RECURSIVE_REPRESSION;
0056 /** G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER tracks the number of recursive
0057  *  function debugging messages were repressed.
0058  */
0059 extern G4long G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER;
0060 /** G4FFGDEBUG_DATA_STRUCTURE_REPRESSION is used to aid in the repression of
0061  *  debugging messages from functions that sort/access data elements.
0062  */
0063 extern G4long G4FFGDEBUG_DATA_STRUCTURE_REPRESSION;
0064 /** G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER tracks the number of recursive
0065  *  function debugging messages were repressed.
0066  */
0067 extern G4long G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER;
0068 
0069 // Entering functions
0070 /** G4FFG_FUNCTIONENTER__ is blank if G4DEBUG_VERBOSE is not defined at compile time.
0071  *  Otherwise, it is used by the fission fragment code to notify when a function is
0072  *  first entered.
0073  */
0074 #  define G4FFG_FUNCTIONENTER__                                                      \
0075     if ((Verbosity_ & G4FFGEnumerations::DEBUG)                                      \
0076         && !(Verbosity_ & G4FFGEnumerations::REPRESS_FUNCTION_ENTER_LEAVE_MESSAGES)) \
0077     {                                                                                \
0078       G4FFG_SPACING__                                                                \
0079       G4cout << "Entering ";                                                         \
0080       G4FFG_LOCATION__                                                               \
0081       G4cout << G4endl;                                                              \
0082     }                                                                                \
0083     G4FFG_DEPTH++;
0084 
0085 /** G4FFG_SAMPLING_FUNCTIONENTER__ wraps around G4FFG_FUNCTIONENTER__ and
0086  *  can be used in conjunctions with
0087  *  G4FFGEnumeration::REPRESS_RANDOM_SAMPLING_MESSAGES to repress debugging output
0088  *  for psuedorandom number generation functions
0089  */
0090 #  define G4FFG_SAMPLING_FUNCTIONENTER__                                       \
0091     if (!(Verbosity_ & G4FFGEnumerations::REPRESS_RANDOM_SAMPLING_MESSAGES)) { \
0092       G4FFG_FUNCTIONENTER__                                                    \
0093     }
0094 
0095 /** G4FFG_RECURSIVE_FUNCTIONENTER__ wraps around G4FFG_FUNCTIONENTER__ and
0096  *  can be used in conjunctions with
0097  *  G4FFGEnumeration::REPRESS_RECURSIVE_DEBUG_MESSAGES to repress debugging output
0098  *  recursive function calls.
0099  */
0100 #  define G4FFG_RECURSIVE_FUNCTIONENTER__                                   \
0101     if (Verbosity_ & G4FFGEnumerations::REPRESS_RECURSIVE_DEBUG_MESSAGES) { \
0102       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                           \
0103         G4FFG_FUNCTIONENTER__                                               \
0104       }                                                                     \
0105       else {                                                                \
0106         G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER++;                          \
0107       }                                                                     \
0108       G4FFGDEBUG_RECURSIVE_REPRESSION++;                                    \
0109     }                                                                       \
0110     else {                                                                  \
0111       G4FFG_FUNCTIONENTER__                                                 \
0112     }
0113 
0114 /** G4FFG_DATA_FUNCTIONENTER__ wraps around G4FFG_FUNCTIONENTER__ and
0115  *  can be used in conjunctions with
0116  *  G4FFGEnumeration::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES to repress debugging output
0117  *  recursive function calls.
0118  */
0119 #  define G4FFG_DATA_FUNCTIONENTER__                                             \
0120     if (Verbosity_ & G4FFGEnumerations::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES) { \
0121       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                                \
0122         G4FFG_FUNCTIONENTER__                                                    \
0123       }                                                                          \
0124       else {                                                                     \
0125         G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER++;                          \
0126       }                                                                          \
0127       G4FFGDEBUG_RECURSIVE_REPRESSION++;                                         \
0128     }                                                                            \
0129     else {                                                                       \
0130       G4FFG_FUNCTIONENTER__                                                      \
0131     }
0132 
0133 // Leaving functions
0134 /** G4FFG_FUNCTIONLEAVE__ is blank if G4DEBUG_VERBOSE is not defined at compile time.
0135  *  Otherwise, it is used by the fission fragment code to notify when a function is
0136  *  exited. It will also be found before \p return statements, since those exit a
0137  *  funtion as well.
0138  */
0139 #  define G4FFG_FUNCTIONLEAVE__                                                      \
0140     G4FFG_DEPTH--;                                                                   \
0141     if ((Verbosity_ & G4FFGEnumerations::DEBUG)                                      \
0142         && !(Verbosity_ & G4FFGEnumerations::REPRESS_FUNCTION_ENTER_LEAVE_MESSAGES)) \
0143     {                                                                                \
0144       G4FFG_SPACING__                                                                \
0145       G4cout << "Leaving ";                                                          \
0146       G4FFG_LOCATION__                                                               \
0147       G4cout << G4endl;                                                              \
0148     }
0149 
0150 /** G4FFG_SAMPLING_FUNCTIONLEAVE__ wraps around G4FFG_FUNCTIONLEAVE__ and
0151  *  can be used in conjunctions with
0152  *  G4FFGEnumeration::REPRESS_RANDOM_SAMPLING_MESSAGES to repress debugging output
0153  *  for psuedorandom number generation functions
0154  */
0155 #  define G4FFG_SAMPLING_FUNCTIONLEAVE__                                       \
0156     if (!(Verbosity_ & G4FFGEnumerations::REPRESS_RANDOM_SAMPLING_MESSAGES)) { \
0157       G4FFG_FUNCTIONLEAVE__                                                    \
0158     }
0159 
0160 /** G4FFG_RECURSIVE_FUNCTIONLEAVE__ wraps around G4FFG_FUNCTIONLEAVE__ and
0161  *  can be used in conjunctions with
0162  *  G4FFGEnumeration::REPRESS_RECURSIVE_DEBUG_MESSAGES to repress debugging output
0163  *  recursive function calls.
0164  */
0165 #  define G4FFG_RECURSIVE_FUNCTIONLEAVE__                                     \
0166     if (Verbosity_ & G4FFGEnumerations::REPRESS_RECURSIVE_DEBUG_MESSAGES) {   \
0167       G4FFGDEBUG_RECURSIVE_REPRESSION--;                                      \
0168       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                             \
0169         if (G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER > 0) {                    \
0170           G4FFG_SPACING__                                                     \
0171           G4cout << "==== " << G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER * 2    \
0172                  << " recursive function messages suppressed ====" << G4endl; \
0173           G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER = 0;                        \
0174         }                                                                     \
0175         G4FFG_FUNCTIONLEAVE__                                                 \
0176       }                                                                       \
0177     }                                                                         \
0178     else {                                                                    \
0179       G4FFG_FUNCTIONLEAVE__                                                   \
0180     }
0181 
0182 /** G4FFG_DATA_FUNCTIONLEAVE__ wraps around G4FFG_FUNCTIONLEAVE__ and
0183  *  can be used in conjunctions with
0184  *  G4FFGEnumeration::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES to repress debugging output
0185  *  recursive function calls.
0186  */
0187 #  define G4FFG_DATA_FUNCTIONLEAVE__                                               \
0188     if (Verbosity_ & G4FFGEnumerations::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES) {   \
0189       G4FFGDEBUG_RECURSIVE_REPRESSION--;                                           \
0190       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                                  \
0191         if (G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER > 0) {                    \
0192           G4FFG_SPACING__                                                          \
0193           G4cout << "==== " << G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER * 2    \
0194                  << " data structure function messages suppressed ====" << G4endl; \
0195           G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER = 0;                        \
0196         }                                                                          \
0197         G4FFG_FUNCTIONLEAVE__                                                      \
0198       }                                                                            \
0199     }                                                                              \
0200     else {                                                                         \
0201       G4FFG_FUNCTIONLEAVE__                                                        \
0202     }
0203 #else /* G4DEBUG_VERBOSE */
0204 // If G4DEBUG_VERBOSE is not defined then we will need to define these macros but leave them empty
0205 // Except for G4FFG_FUNCTIONENTER__ and G4FFG_FUNCTIONLEAVE__, which will be used to track
0206 // G4FFG_DEPTH
0207 #  define G4FFG_FUNCTIONENTER__ G4FFG_DEPTH++;
0208 #  define G4FFG_SAMPLING_FUNCTIONENTER__
0209 #  define G4FFG_RECURSIVE_FUNCTIONENTER__
0210 #  define G4FFG_DATA_FUNCTIONENTER__
0211 #  define G4FFG_FUNCTIONLEAVE__ G4FFG_DEPTH--;
0212 #  define G4FFG_SAMPLING_FUNCTIONLEAVE__
0213 #  define G4FFG_RECURSIVE_FUNCTIONLEAVE__
0214 #  define G4FFG_DATA_FUNCTIONLEAVE__
0215 #endif /* G4DEBUG_VERBOSE */
0216 
0217 #endif /* G4FFGDEBUGGINGMACROS_HH */