operation.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * operation.h 
00006  *
00007  * Copyright (C) 2002-2007 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 
00026 #ifndef GCHEMPAINT_OPERATION_H
00027 #define GCHEMPAINT_OPERATION_H
00028 
00029 #include <gcu/macros.h>
00030 #include <gcu/object.h>
00031 
00032 namespace gcp {
00033 
00034 class Document;
00035 
00036 typedef enum
00037 {
00038         GCP_ADD_OPERATION,
00039         GCP_DELETE_OPERATION,
00040         GCP_MODIFY_OPERATION,
00041 } OperationType;
00042 
00043 class Operation
00044 {
00045 public:
00046         Operation (Document *pDoc, unsigned long ID);
00047         virtual ~Operation ();
00048 
00049         virtual void Undo () = 0;
00050         virtual void Redo () = 0;
00051         virtual void AddObject (gcu::Object* pObject, unsigned type = 0);
00052         virtual void AddNode (xmlNodePtr node, unsigned type = 0);
00053 
00054 protected:
00055         void Add (unsigned type = 0);
00056         void Delete (unsigned type = 0);
00057 
00058 protected:
00059         xmlNodePtr* m_Nodes;
00060 
00061 private:
00062         gcp::Document* m_pDoc;
00063 
00064 GCU_RO_PROP (unsigned long, ID);
00065 };
00066 
00067 class AddOperation: public Operation
00068 {
00069 public:
00070         AddOperation (gcp::Document *pDoc, unsigned long ID);
00071         virtual ~AddOperation ();
00072 
00073         virtual void Undo ();
00074         virtual void Redo ();
00075 };
00076 
00077 class DeleteOperation: public Operation
00078 {
00079 public:
00080         DeleteOperation (gcp::Document *pDoc, unsigned long ID);
00081         virtual ~DeleteOperation ();
00082 
00083         virtual void Undo ();
00084         virtual void Redo ();
00085 };
00086 
00087 class ModifyOperation: public Operation
00088 {
00089 public:
00090         ModifyOperation (gcp::Document *pDoc, unsigned long ID);
00091         virtual ~ModifyOperation ();
00092 
00093         virtual void Undo ();
00094         virtual void Redo ();
00095 };
00096 
00097 }       // namespace gcp
00098 
00099 #endif //GCHEMPAINT_OPERATION_H

Generated on Sun Jun 22 13:26:05 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6