Transactions.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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 }
00111
00112 #endif // APP_TRANSACTION_H
00113