MDAT  1.0
 All Classes Files Functions Variables Typedefs Pages
trace.h
Go to the documentation of this file.
1 
9 /* Copyright (C) 2013 Eric Larson and Rochelle Palting
10  elarson@seattleu.edu
11 
12  This file is part of the MDAT infrastructure.
13 
14  This program is free software: you can redistribute it and/or modify
15  it under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with this program. If not, see <http://www.gnu.org/licenses/>.
26 */
27 
28 #ifndef TRACE_H
29 #define TRACE_H
30 
31 #include <string>
32 #include <fstream>
33 #include <deque>
34 using namespace std;
35 
86 {
87 
88  public:
89 
98  void init(char *fileName, bool _useConsole);
99 
105  void finish();
106 
115  void printHeader(string header);
116 
125  void printThreadId(int id);
126 
135  void printSection(string section);
136 
145  void printMessage(string message);
146 
153  void printTables();
154 
164  void internalError(string errorMsg);
165 
175  void externalError(string errorMsg);
176 
177  private:
178 
179  /* Trace state */
180  enum {
181  HEADER, /* header line is next required thing to print */
182  THREAD, /* thread line is next required thing to print */
183  MESSAGE, /* message line is next required thing to print */
184  TABLE /* tables are next required thing to print */
185  } traceState;
186 
187  ofstream traceFile; /* output trace file stream */
188  bool useFile; /* print trace to file if set */
189  bool useConsole; /* print trace to screen if set */
190 
191  /* Prints the string to the trace file. */
192  void printString(string traceStr);
193 
194 };
195 
196 /*
197  * Global trace manager.
198  */
199 extern TraceManager tracer;
200 
201 #endif
202 
This is a personal WEB site developed and maintained by an individual and not by Seattle University. The content and link(s) provided on this site do not represent or reflect the view(s) of Seattle University. The individual who authored this site is solely responsible for the site's content. This site and its author are subject to applicable University policies including the Computer Acceptable Use Policy (www.seattleu.edu/policies).