The Gnome Chemistry Utils 0.13.3
operation.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * operation.h 
00006  *
00007  * Copyright (C) 2002-2008 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 
00026 #ifndef GCHEMPAINT_OPERATION_H
00027 #define GCHEMPAINT_OPERATION_H
00028 
00029 #include <gcu/macros.h>
00030 #include <gcu/object.h>
00031 
00033 namespace gcp {
00034 
00035 class Document;
00036 
00041 typedef enum
00042 {
00046         GCP_ADD_OPERATION,
00050         GCP_DELETE_OPERATION,
00054         GCP_MODIFY_OPERATION,
00055 } OperationType;
00056 
00061 class Operation
00062 {
00063 public:
00071         Operation (Document *pDoc, unsigned long ID);
00072         virtual ~Operation ();
00073 
00077         virtual void Undo () = 0;
00081         virtual void Redo () = 0;
00105         virtual void AddObject (gcu::Object* pObject, unsigned type = 0);
00117         virtual void AddNode (xmlNodePtr node, unsigned type = 0);
00118 
00119 protected:
00129         void Add (unsigned type = 0);
00139         void Delete (unsigned type = 0);
00140 
00141 protected:
00145         xmlNodePtr* m_Nodes;
00146 
00147 private:
00148         gcp::Document* m_pDoc;
00149 
00150 GCU_RO_PROP (unsigned long, ID);
00151 };
00152 
00156 class AddOperation: public Operation
00157 {
00158 public:
00166         AddOperation (gcp::Document *pDoc, unsigned long ID);
00167         virtual ~AddOperation ();
00168 
00172         void Undo ();
00176         void Redo ();
00177 };
00178 
00182 class DeleteOperation: public Operation
00183 {
00184 public:
00192         DeleteOperation (gcp::Document *pDoc, unsigned long ID);
00193         virtual ~DeleteOperation ();
00194 
00198         void Undo ();
00202         void Redo ();
00203 };
00204 
00208 class ModifyOperation: public Operation
00209 {
00210 public:
00218         ModifyOperation (gcp::Document *pDoc, unsigned long ID);
00219         virtual ~ModifyOperation ();
00220 
00224         void Undo ();
00228         void Redo ();
00229 };
00230 
00231 }       // namespace gcp
00232 
00233 #endif //GCHEMPAINT_OPERATION_H