OpenLexocad  27.1
AutoTransaction.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2019 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
3  * *
4  * This file is part of the FreeCAD CAx development system. *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Library General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Library General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Library General Public *
17  * License along with this library; see the file COPYING.LIB. If not, *
18  * write to the Free Software Foundation, Inc., 59 Temple Place, *
19  * Suite 330, Boston, MA 02111-1307, USA *
20  * *
21  ****************************************************************************/
22 
23 #pragma once
24 
25 namespace Core {
26 
27 class CoreApplication;
28 
30 class LX_CORE_EXPORT AutoTransaction {
31 private:
33  void* operator new(size_t size);
34 
35 public:
50  AutoTransaction(const char *name=0, bool tmpName=false);
51 
58  ~AutoTransaction();
59 
66  void close(bool abort=false);
67 
77  static void setEnable(bool enable);
78 
79 private:
80  int tid = 0;
81 };
82 
83 
89 class LX_CORE_EXPORT TransactionLocker {
90 public:
91 
95  TransactionLocker(bool lock=true);
96 
101 
110  void activate(bool enable);
111 
113  bool isActive() const {return active;}
114 
116  static bool isLocked();
117 
118  friend class CoreApplication;
119 
120 private:
122  void* operator new(size_t size);
123 
124 private:
125  bool active;
126 };
127 
128 } // namespace Core
129 
Definition: CoreApplication.h:94
bool isActive() const
Check if the locker is active.
Definition: AutoTransaction.h:113
Definition: AutoTransaction.h:89
Core::PropertyText name
Definition: CoreDocument.h:167
Definition: Base.h:12
friend class CoreApplication
Definition: CoreDocument.h:138
Helper class to manager transaction (i.e. undo/redo)
Definition: AutoTransaction.h:30