Add AbstractDeclarationNavigationContext, and move the html-method from
[kdevelopdvcssupport.git] / language / duchain / safetycounter.h
blob66dd6c63b986eefcb37e3e9514eb7d6c9daa69cd
2 /***************************************************************************
3 Copyright 2006 David Nolden <david.nolden.kdevelop@art-master.de>
4 ***************************************************************************/
6 /***************************************************************************
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 ***************************************************************************/
15 #ifndef __SAFETYCOUNTER_H__
16 #define __SAFETYCOUNTER_H__
18 #include <kdebug.h>
20 struct SafetyCounter {
21 int safetyCounter;
22 const int maxSafetyCounter;
24 SafetyCounter( int max = 40000 ) : safetyCounter(0), maxSafetyCounter(max) {
27 void init() {
28 safetyCounter = 0;
31 SafetyCounter& operator ++() {
32 safetyCounter++;
33 return *this;
36 ///Returns whether the counter is ok, but without increasing it
37 bool ok() const {
38 return safetyCounter < maxSafetyCounter;
41 operator bool() {
42 safetyCounter++;
43 bool ret = safetyCounter < maxSafetyCounter;
44 if( !ret ) {
45 if( safetyCounter == maxSafetyCounter ) {
46 #ifdef DEPTHBACKTRACE
47 kDebug( 9007) << "WARNING: Safety-counter reached count > " << maxSafetyCounter << ", operation stopped";
48 #endif
49 kDebug( 9007 ) << endl << kBacktrace();
53 return ret;
58 #endif