Frobby 0.9.5
DebugAllocator.h
Go to the documentation of this file.
1/* Frobby: Software for monomial ideal computations.
2 Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see http://www.gnu.org/licenses/.
16*/
17#ifndef DEBUG_ALLOCATOR_GUARD
18#define DEBUG_ALLOCATOR_GUARD
19
20class TestCase;
21
22#include <string>
23
24#ifdef DEBUG
25
67class DebugAllocator {
68 public:
72 int runDebugMain(int argc, const char** argv);
73
75 void* allocate(size_t size);
76
80 void* allocate(size_t size, const char* file, size_t lineNumber);
81
85 void runTest(TestCase& test, const string& name);
86
88 static DebugAllocator& getSingleton();
89
90 private:
94 DebugAllocator();
95
98 void processDebugOptions(int& argc, const char**& argv);
99
104 void rewindInput();
105
109 void runWithLimit(int argc, const char** argv, size_t limit);
110
115 bool _debugAllocation;
116
121 bool _detailAllocation;
122
127 bool _limitAllocation;
128
136 bool _expectBadAllocException;
137
142 bool _actionIsTest;
143
148 size_t _allocationCount;
149
154 size_t _allocationLimit;
155
159 string _inputFile;
160};
161
162#endif
163
164#endif
Represents a test case, which is usually created through a macro that defines a subclass.
Definition TestCase.h:29