Transactions.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Juergen Riegel         <juergen.riegel@web.de>          *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef APP_TRANSACTION_H
00025 #define APP_TRANSACTION_H
00026 
00027 #include <Base/Persistence.h>
00028 
00029 namespace App
00030 {
00031 
00032 class Document;
00033 class DocumentObject;
00034 class Property;
00035 class Transaction;
00036 
00037 
00040 class AppExport TransactionObject: public Base::Persistence
00041 {
00042     TYPESYSTEM_HEADER();
00043 
00044 public:
00046     TransactionObject(const DocumentObject *pcObj,const char *NameInDocument=0);
00048     virtual ~TransactionObject();
00049 
00050     void applyNew(Document &Doc, DocumentObject *pcObj);
00051     void applyDel(Document &Doc, DocumentObject *pcObj);
00052     void applyChn(Document &Doc, DocumentObject *pcObj,bool Forward);
00053 
00054     void setProperty(const Property* pcProp);
00055 
00056     virtual unsigned int getMemSize (void) const;
00057     virtual void Save (Base::Writer &writer) const;
00059     virtual void Restore(Base::XMLReader &reader);
00060 
00061     friend class Transaction;
00062 
00063 protected:
00064     enum Status {New,Del,Chn} status;
00065     std::map<const Property*,Property*> _PropChangeMap;
00066     std::string _NameInDocument;
00067 };
00068 
00071 class AppExport Transaction : public Base::Persistence
00072 {
00073     TYPESYSTEM_HEADER();
00074 
00075 public:
00077     Transaction();
00079     Transaction(int pos);
00081     virtual ~Transaction();
00082 
00084     void apply(Document &Doc,bool forward);
00085 
00086     // the utf-8 name of the transaction
00087     std::string Name; 
00088 
00089     virtual unsigned int getMemSize (void) const;
00090     virtual void Save (Base::Writer &writer) const;
00092     virtual void Restore(Base::XMLReader &reader);
00093 
00095     int getPos(void) const;
00096 
00097     friend class Document;
00098 
00099 protected:
00100     void addObjectNew(DocumentObject *Obj);
00101     void addObjectDel(const DocumentObject *Obj);
00102     void addObjectChange(const DocumentObject *Obj,const Property *Prop);
00103 
00104 private:
00105     int iPos;
00106     std::map<const DocumentObject*,TransactionObject*> _Objects;
00107 };
00108 
00109 
00110 } //namespace App
00111 
00112 #endif // APP_TRANSACTION_H
00113 

Generated on Wed Nov 23 19:00:50 2011 for FreeCAD by  doxygen 1.6.1