]> git.saurik.com Git - wxWidgets.git/blame - include/wx/recguard.h
Add wxDataViewRendererBase::GetEffectiveAlignment() and use it.
[wxWidgets.git] / include / wx / recguard.h
CommitLineData
7b4d7f99
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/recguard.h
3// Purpose: declaration and implementation of wxRecursionGuard class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 14.08.2003
77ffb593 7// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 8// Licence: wxWindows licence
7b4d7f99
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_RECGUARD_H_
12#define _WX_RECGUARD_H_
13
14#include "wx/defs.h"
15
16// ----------------------------------------------------------------------------
17// wxRecursionGuardFlag is used with wxRecursionGuard
18// ----------------------------------------------------------------------------
19
20typedef int wxRecursionGuardFlag;
21
22// ----------------------------------------------------------------------------
23// wxRecursionGuard is the simplest way to protect a function from reentrancy
24// ----------------------------------------------------------------------------
25
26class WXDLLIMPEXP_BASE wxRecursionGuard
27{
28public:
29 wxRecursionGuard(wxRecursionGuardFlag& flag)
30 : m_flag(flag)
701a0b47 31 {
7b4d7f99
VZ
32 m_isInside = flag++ != 0;
33 }
34
35 ~wxRecursionGuard()
36 {
9a83f860 37 wxASSERT_MSG( m_flag > 0, wxT("unbalanced wxRecursionGuards!?") );
7b4d7f99
VZ
38
39 m_flag--;
40 }
41
42 bool IsInside() const { return m_isInside; }
43
44private:
45 wxRecursionGuardFlag& m_flag;
46
47 // true if the flag had been already set when we were created
48 bool m_isInside;
49};
50
51#endif // _WX_RECGUARD_H_
52