-
Notifications
You must be signed in to change notification settings - Fork 0
/
DgBase.h
103 lines (69 loc) · 2.96 KB
/
DgBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
////////////////////////////////////////////////////////////////////////////////
//
// DgBase.h: DgBase class definitions
//
// Version 6.1 - Kevin Sahr, 5/23/13
//
////////////////////////////////////////////////////////////////////////////////
#ifndef DGBASE_H
#define DGBASE_H
#include <iostream>
#include <string>
using namespace std;
#define DGDEBUG 0
#define DGGRID_VERSION "6.2b1"
////////////////////////////////////////////////////////////////////////////////
class DgBase {
public:
enum DgReportLevel { Debug1, Debug0, Info, Warning, Fatal, Silent };
private:
static const string defaultName;
static DgReportLevel minReportLevel_;
public:
virtual ~DgBase (void);
static void setMinReportLevel (DgReportLevel newRLevel)
{ minReportLevel_ = newRLevel; }
static DgReportLevel minReportLevel (void) { return minReportLevel_; }
static bool testArgEqual (int argc, int expected,
const string& message = string("invalid argument count"),
DgReportLevel level = Fatal);
static bool testArgEqual (int argc, char* argv[], int expected,
const string& message = string("invalid argument count"));
static bool testArgMin (int argc, int minExpected,
const string& message = string("invalid argument count"),
DgReportLevel level = Fatal);
static bool testArgMin (int argc, char* argv[], int minExpected,
const string& message = string("invalid argument count"));
DgBase (const string& instanceName = defaultName);
DgBase (const string* instanceName = NULL);
void setInstanceName (const string& instanceName)
{ instanceName_ = instanceName; }
const string& instanceName (void) const { return instanceName_; }
protected:
void report (const string& message, DgReportLevel level = Info) const;
void debug (const string& message) const;
private:
// data members
string instanceName_;
};
////////////////////////////////////////////////////////////////////////////////
extern "C" void report (const string& message,
DgBase::DgReportLevel level = DgBase::Info);
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
inline void
DgBase::debug (const string& message) const
//
// Print-out a debugging message if the DGDEBUG flag is set. Otherwise this
// is a null operation.
//
////////////////////////////////////////////////////////////////////////////////
{
#if DGDEBUG
cout << "DEBUG: [" << instanceName_ << "] " << message << endl;
#endif
} // void DgBase::debug
////////////////////////////////////////////////////////////////////////////////
inline ostream& operator<< (ostream& stream, const DgBase& b)
{ return stream << b.instanceName(); }
#endif