]> git.saurik.com Git - wxWidgets.git/blame - include/wx/snglinst.h
define wxUSE_LINE_IN_LISTBOOK to avoid -Wundef warnings (but define it as 0 so thje...
[wxWidgets.git] / include / wx / snglinst.h
CommitLineData
68a602fc
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/snglinst.h
3// Purpose: wxSingleInstanceChecker can be used to restrict the number of
4// simultaneously running copies of a program to one
5// Author: Vadim Zeitlin
6// Modified by:
7// Created: 08.06.01
8// RCS-ID: $Id$
9// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 10// Licence: wxWindows licence
68a602fc
VZ
11///////////////////////////////////////////////////////////////////////////////
12
13#ifndef _WX_SNGLINST_H_
14#define _WX_SNGLINST_H_
15
12028905 16#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
68a602fc
VZ
17 #pragma interface "snglinst.h"
18#endif
19
20#if wxUSE_SNGLINST_CHECKER
21
22// ----------------------------------------------------------------------------
23// wxSingleInstanceChecker
24// ----------------------------------------------------------------------------
25
bddd7a8d 26class WXDLLIMPEXP_BASE wxSingleInstanceChecker
68a602fc
VZ
27{
28public:
29 // default ctor, use Create() after it
30 wxSingleInstanceChecker() { Init(); }
31
32 // like Create() but no error checking (dangerous!)
33 wxSingleInstanceChecker(const wxString& name,
34 const wxString& path = wxEmptyString)
35 {
36 Init();
37 Create(name, path);
38 }
39
40 // name must be given and be as unique as possible, it is used as the mutex
41 // name under Win32 and the lock file name under Unix -
42 // wxTheApp->GetAppName() may be a good value for this parameter
43 //
44 // path is optional and is ignored under Win32 and used as the directory to
45 // create the lock file in under Unix (default is wxGetHomeDir())
46 //
d775fa82 47 // returns false if initialization failed, it doesn't mean that another
68a602fc
VZ
48 // instance is running - use IsAnotherRunning() to check it
49 bool Create(const wxString& name, const wxString& path = wxEmptyString);
50
51 // is another copy of this program already running?
52 bool IsAnotherRunning() const;
04354c1d 53
68a602fc
VZ
54 // dtor is not virtual, this class is not meant to be used polymorphically
55 ~wxSingleInstanceChecker();
56
57private:
58 // common part of all ctors
59 void Init() { m_impl = NULL; }
60
61 // the implementation details (platform specific)
bddd7a8d 62 class WXDLLIMPEXP_BASE wxSingleInstanceCheckerImpl *m_impl;
22f3361e
VZ
63
64 DECLARE_NO_COPY_CLASS(wxSingleInstanceChecker)
68a602fc
VZ
65};
66
67#endif // wxUSE_SNGLINST_CHECKER
68
69#endif // _WX_SNGLINST_H_