1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration and implementation of wxRecursionGuard class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RECGUARD_H_
12 #define _WX_RECGUARD_H_
16 // ----------------------------------------------------------------------------
17 // wxRecursionGuardFlag is used with wxRecursionGuard
18 // ----------------------------------------------------------------------------
20 typedef int wxRecursionGuardFlag
;
22 // ----------------------------------------------------------------------------
23 // wxRecursionGuard is the simplest way to protect a function from reentrancy
24 // ----------------------------------------------------------------------------
26 class WXDLLIMPEXP_BASE wxRecursionGuard
29 wxRecursionGuard(wxRecursionGuardFlag
& flag
)
32 m_isInside
= flag
++ != 0;
37 wxASSERT_MSG( m_flag
> 0, wxT("unbalanced wxRecursionGuards!?") );
42 bool IsInside() const { return m_isInside
; }
45 wxRecursionGuardFlag
& m_flag
;
47 // true if the flag had been already set when we were created
51 #endif // _WX_RECGUARD_H_