| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 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 |
|
| 24 |
#ifndef APP_TRANSACTIONALOBJECT_H |
| 25 |
#define APP_TRANSACTIONALOBJECT_H |
| 26 |
|
| 27 |
#include <App/ExtensionContainer.h> |
| 28 |
|
| 29 |
namespace App |
| 30 |
{ |
| 31 |
|
| 32 |
class Document; |
| 33 |
class TransactionObject; |
| 34 |
|
| 35 |
/** |
| 36 |
* @brief Base class of transactional objects. |
| 37 |
* |
| 38 |
* A transactional object provides functionality that is inherited by its |
| 39 |
* children to ensure that these children objects can be targeted by a |
| 40 |
* transaction. |
| 41 |
*/ |
| 42 |
class AppExport TransactionalObject: public App::ExtensionContainer |
| 43 |
{ |
| 44 |
PROPERTY_HEADER_WITH_OVERRIDE(App::TransactionalObject); |
| 45 |
|
| 46 |
public: |
| 47 |
TransactionalObject(); |
| 48 |
~TransactionalObject() override; |
| 49 |
|
| 50 |
/// Check if this object is attached to a document. |
| 51 |
virtual bool isAttachedToDocument() const; |
| 52 |
|
| 53 |
/** |
| 54 |
* @brief Deteach this object from the document. |
| 55 |
* |
| 56 |
* @return the name of the document this object was attached to. |
| 57 |
*/ |
| 58 |
virtual const char* detachFromDocument(); |
| 59 |
|
| 60 |
protected: |
| 61 |
/** |
| 62 |
* @brief Notify the document that a property is about to be changed. |
| 63 |
* |
| 64 |
* This function is called before the property is changed. |
| 65 |
* |
| 66 |
* @param[in,out] doc the document this object is attached to. |
| 67 |
* @param[in] prop the property that is about to be changed. |
| 68 |
*/ |
| 69 |
void onBeforeChangeProperty(Document* doc, const Property* prop); |
| 70 |
}; |
| 71 |
|
| 72 |
} // namespace App |
| 73 |
|
| 74 |
|
| 75 |
#endif // APP_TRANSACTIONALOBJECT_H |