1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration and implementation of wxRecursionGuard class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RECGUARD_H_
13 #define _WX_RECGUARD_H_
17 // ----------------------------------------------------------------------------
18 // wxRecursionGuardFlag is used with wxRecursionGuard
19 // ----------------------------------------------------------------------------
21 typedef int wxRecursionGuardFlag
;
23 // ----------------------------------------------------------------------------
24 // wxRecursionGuard is the simplest way to protect a function from reentrancy
25 // ----------------------------------------------------------------------------
27 class WXDLLIMPEXP_BASE wxRecursionGuard
30 wxRecursionGuard(wxRecursionGuardFlag
& flag
)
33 m_isInside
= flag
++ != 0;
38 wxASSERT_MSG( m_flag
> 0, wxT("unbalanced wxRecursionGuards!?") );
43 bool IsInside() const { return m_isInside
; }
46 wxRecursionGuardFlag
& m_flag
;
48 // true if the flag had been already set when we were created
52 #endif // _WX_RECGUARD_H_