2
/***************************************************************************
3
copyright : (C) 2006 by David Nolden
4
email : david.nolden.kdevelop@art-master.de
5
***************************************************************************/
7
/***************************************************************************
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
14
***************************************************************************/
16
#ifndef __SAFETYCOUNTER_H__
17
#define __SAFETYCOUNTER_H__
21
struct SafetyCounter {
23
const int maxSafetyCounter;
25
SafetyCounter( int max = 40000 ) : safetyCounter(0), maxSafetyCounter(max) {
32
SafetyCounter& operator ++() {
37
///Returns whether the counter is ok, but without increasing it
39
return safetyCounter < maxSafetyCounter;
44
bool ret = safetyCounter < maxSafetyCounter;
46
if( safetyCounter == maxSafetyCounter ) {
48
kdDebug( 9007) << "WARNING: Safety-counter reached count > " << maxSafetyCounter << ", operation stopped" << endl;
50
kdDebug( 9007 ) << endl << kdBacktrace() << endl;