OpenLexocad  28.0
AutoTransaction.h
Go to the documentation of this file.
1 
2 /****************************************************************************
3  * Copyright (c) 2019 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
4  * *
5  * This file is part of the FreeCAD CAx development system. *
6  * *
7  * This library is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU Library General Public *
9  * License as published by the Free Software Foundation; either *
10  * version 2 of the License, or (at your option) any later version. *
11  * *
12  * This library is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU Library General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Library General Public *
18  * License along with this library; see the file COPYING.LIB. If not, *
19  * write to the Free Software Foundation, Inc., 59 Temple Place, *
20  * Suite 330, Boston, MA 02111-1307, USA *
21  * *
22  ****************************************************************************/
23 
24 #pragma once
25 
26 namespace Core {
27 
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 
Core::TransactionLocker
Definition: AutoTransaction.h:109
Core
Definition: Base.h:5
Core::CoreApplication
Definition: CoreApplication.h:71
Core::AutoTransaction
Helper class to manager transaction (i.e. undo/redo)
Definition: AutoTransaction.h:50