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 using namespace gcu; 
00033 
00034 namespace gcp {
00035 
00036 class Document;
00037 
00038 typedef enum
00039 {
00040         GCP_ADD_OPERATION,
00041         GCP_DELETE_OPERATION,
00042         GCP_MODIFY_OPERATION,
00043 } OperationType;
00044 
00045 class Operation
00046 {
00047 public:
00048         Operation (Document *pDoc, unsigned long ID);
00049         virtual ~Operation ();
00050 
00051         virtual void Undo () = 0;
00052         virtual void Redo () = 0;
00053         virtual void AddObject (Object* pObject, unsigned type = 0);
00054         virtual void AddNode (xmlNodePtr node, unsigned type = 0);
00055 
00056 protected:
00057         void Add (unsigned type = 0);
00058         void Delete (unsigned type = 0);
00059 
00060 protected:
00061         xmlNodePtr* m_Nodes;
00062 
00063 private:
00064         gcp::Document* m_pDoc;
00065 
00066 GCU_RO_PROP (unsigned long, ID);
00067 };
00068 
00069 class AddOperation: public Operation
00070 {
00071 public:
00072         AddOperation (gcp::Document *pDoc, unsigned long ID);
00073         virtual ~AddOperation ();
00074 
00075         virtual void Undo ();
00076         virtual void Redo ();
00077 };
00078 
00079 class DeleteOperation: public Operation
00080 {
00081 public:
00082         DeleteOperation (gcp::Document *pDoc, unsigned long ID);
00083         virtual ~DeleteOperation ();
00084 
00085         virtual void Undo ();
00086         virtual void Redo ();
00087 };
00088 
00089 class ModifyOperation: public Operation
00090 {
00091 public:
00092         ModifyOperation (gcp::Document *pDoc, unsigned long ID);
00093         virtual ~ModifyOperation ();
00094 
00095         virtual void Undo ();
00096         virtual void Redo ();
00097 };
00098 
00099 }       // namespace gcp
00100 
00101 #endif //GCHEMPAINT_OPERATION_H

Generated on Sun Sep 16 14:21:55 2007 for The Gnome Chemistry Utils by  doxygen 1.5.3