ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4FFGDebuggingMacros.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4FFGDebuggingMacros.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /*
27  * File: G4FFGDebuggingMacros.hh
28  * Author: B. Wendt (wendbryc@isu.edu)
29  *
30  * Created on August 17, 2012, 12:54
31  */
32 
33 #ifndef G4FFGDEBUGGINGMACROS_HH
34 #define G4FFGDEBUGGINGMACROS_HH
35 
36 #include "globals.hh"
37 
38 #include "G4FFGEnumerations.hh"
39 #include "G4FFGVerboseMacros.hh"
40 
41 // Define the function as available by the compiler
42 #if defined(__GNUC__)
43  #define G4FFG_FUNCTION_SIGNATURE__ G4String(__func__) + "()"
44 #elif defined(_MSC_VER)
45  // I'm not sure if this is the correct syntax for MS VC
46  #define G4FFG_FUNCTION_SIGNATURE__ G4String(__FUNCTION__) + "()"
47 #else
48  #define G4FFG_FUNCTION_SIGNATURE__ "a function"
49 #endif
50 
51 // Only define the variables and macros if G4DEBUG_VERBOSE is set
52 #if defined(G4DEBUG_VERBOSE)
53 
56  extern G4long G4FFGDEBUG_RECURSIVE_REPRESSION;
60  extern G4long G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER;
64  extern G4long G4FFGDEBUG_DATA_STRUCTURE_REPRESSION;
68  extern G4long G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER;
69 
70 // Entering functions
75  #define G4FFG_FUNCTIONENTER__ \
76  if((Verbosity_ & G4FFGEnumerations::DEBUG) && !(Verbosity_ & G4FFGEnumerations::REPRESS_FUNCTION_ENTER_LEAVE_MESSAGES)) \
77  { \
78  G4FFG_SPACING__ \
79  G4cout << "Entering ";\
80  G4FFG_LOCATION__ \
81  G4cout << G4endl; \
82  } \
83  G4FFG_DEPTH++;
84 
90  #define G4FFG_SAMPLING_FUNCTIONENTER__ \
91  if(!(Verbosity_ & G4FFGEnumerations::REPRESS_RANDOM_SAMPLING_MESSAGES)) \
92  { \
93  G4FFG_FUNCTIONENTER__ \
94  }
95 
101  #define G4FFG_RECURSIVE_FUNCTIONENTER__ \
102  if(Verbosity_ & G4FFGEnumerations::REPRESS_RECURSIVE_DEBUG_MESSAGES)\
103  { \
104  if(G4FFGDEBUG_RECURSIVE_REPRESSION == 0) \
105  { \
106  G4FFG_FUNCTIONENTER__ \
107  } else \
108  { \
109  G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER++; \
110  } \
111  G4FFGDEBUG_RECURSIVE_REPRESSION++; \
112  } else \
113  { \
114  G4FFG_FUNCTIONENTER__ \
115  }
116 
122  #define G4FFG_DATA_FUNCTIONENTER__ \
123  if(Verbosity_ & G4FFGEnumerations::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES)\
124  { \
125  if(G4FFGDEBUG_RECURSIVE_REPRESSION == 0) \
126  { \
127  G4FFG_FUNCTIONENTER__ \
128  } else \
129  { \
130  G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER++; \
131  } \
132  G4FFGDEBUG_RECURSIVE_REPRESSION++; \
133  } else \
134  { \
135  G4FFG_FUNCTIONENTER__ \
136  }
137 
138 // Leaving functions
144  #define G4FFG_FUNCTIONLEAVE__ \
145  G4FFG_DEPTH--; \
146  if((Verbosity_ & G4FFGEnumerations::DEBUG) && !(Verbosity_ & G4FFGEnumerations::REPRESS_FUNCTION_ENTER_LEAVE_MESSAGES)) \
147  { \
148  G4FFG_SPACING__ \
149  G4cout << "Leaving ";\
150  G4FFG_LOCATION__ \
151  G4cout << G4endl; \
152  }
153 
159  #define G4FFG_SAMPLING_FUNCTIONLEAVE__ \
160  if(!(Verbosity_ & G4FFGEnumerations::REPRESS_RANDOM_SAMPLING_MESSAGES)) \
161  { \
162  G4FFG_FUNCTIONLEAVE__ \
163  }
164 
170  #define G4FFG_RECURSIVE_FUNCTIONLEAVE__ \
171  if(Verbosity_ & G4FFGEnumerations::REPRESS_RECURSIVE_DEBUG_MESSAGES)\
172  { \
173  G4FFGDEBUG_RECURSIVE_REPRESSION--; \
174  if(G4FFGDEBUG_RECURSIVE_REPRESSION == 0) \
175  { \
176  if(G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER > 0) \
177  { \
178  G4FFG_SPACING__ \
179  G4cout << "==== " << G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER * 2 << " recursive function messages suppressed ====" << G4endl; \
180  G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER = 0; \
181  } \
182  G4FFG_FUNCTIONLEAVE__ \
183  } \
184  } else \
185  { \
186  G4FFG_FUNCTIONLEAVE__ \
187  }
188 
194  #define G4FFG_DATA_FUNCTIONLEAVE__ \
195  if(Verbosity_ & G4FFGEnumerations::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES)\
196  { \
197  G4FFGDEBUG_RECURSIVE_REPRESSION--; \
198  if(G4FFGDEBUG_RECURSIVE_REPRESSION == 0) \
199  { \
200  if(G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER > 0) \
201  { \
202  G4FFG_SPACING__ \
203  G4cout << "==== " << G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER * 2 << " data structure function messages suppressed ====" << G4endl; \
204  G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER = 0; \
205  } \
206  G4FFG_FUNCTIONLEAVE__ \
207  } \
208  } else \
209  { \
210  G4FFG_FUNCTIONLEAVE__ \
211  }
212 #else /* G4DEBUG_VERBOSE */
213 // If G4DEBUG_VERBOSE is not defined then we will need to define these macros but leave them empty
214 // Except for G4FFG_FUNCTIONENTER__ and G4FFG_FUNCTIONLEAVE__, which will be used to track G4FFG_DEPTH
215  #define G4FFG_FUNCTIONENTER__ G4FFG_DEPTH++;
216  #define G4FFG_SAMPLING_FUNCTIONENTER__
217  #define G4FFG_RECURSIVE_FUNCTIONENTER__
218  #define G4FFG_DATA_FUNCTIONENTER__
219  #define G4FFG_FUNCTIONLEAVE__ G4FFG_DEPTH--;
220  #define G4FFG_SAMPLING_FUNCTIONLEAVE__
221  #define G4FFG_RECURSIVE_FUNCTIONLEAVE__
222  #define G4FFG_DATA_FUNCTIONLEAVE__
223 #endif /* G4DEBUG_VERBOSE */
224 
225 #endif /* G4FFGDEBUGGINGMACROS_HH */
226