2 /***************************************************************************
3 Copyright 2006 David Nolden <david.nolden.kdevelop@art-master.de>
4 ***************************************************************************/
6 /***************************************************************************
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. *
13 ***************************************************************************/
15 #ifndef __SAFETYCOUNTER_H__
16 #define __SAFETYCOUNTER_H__
20 struct SafetyCounter
{
22 const int maxSafetyCounter
;
24 SafetyCounter( int max
= 40000 ) : safetyCounter(0), maxSafetyCounter(max
) {
31 SafetyCounter
& operator ++() {
36 ///Returns whether the counter is ok, but without increasing it
38 return safetyCounter
< maxSafetyCounter
;
43 bool ret
= safetyCounter
< maxSafetyCounter
;
45 if( safetyCounter
== maxSafetyCounter
) {
47 kDebug( 9007) << "WARNING: Safety-counter reached count > " << maxSafetyCounter
<< ", operation stopped";
49 kDebug( 9007 ) << endl
<< kBacktrace();