The Gnome Chemistry Utils  0.14.0
operation.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * operation.h
6  *
7  * Copyright (C) 2002-2008 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
26 #ifndef GCHEMPAINT_OPERATION_H
27 #define GCHEMPAINT_OPERATION_H
28 
29 #include <gcu/macros.h>
30 #include <gcu/object.h>
31 
33 namespace gcp {
34 
35 class Document;
36 
41 typedef enum
42 {
56 
61 class Operation
62 {
63 public:
71  Operation (Document *pDoc, unsigned long ID);
72  virtual ~Operation ();
73 
77  virtual void Undo () = 0;
81  virtual void Redo () = 0;
105  virtual void AddObject (gcu::Object* pObject, unsigned type = 0);
117  virtual void AddNode (xmlNodePtr node, unsigned type = 0);
118 
119 protected:
129  void Add (unsigned type = 0);
139  void Delete (unsigned type = 0);
140 
141 protected:
145  xmlNodePtr* m_Nodes;
146 
147 private:
148  gcp::Document* m_pDoc;
149 
150 GCU_RO_PROP (unsigned long, ID);
151 };
152 
156 class AddOperation: public Operation
157 {
158 public:
166  AddOperation (gcp::Document *pDoc, unsigned long ID);
167  virtual ~AddOperation ();
168 
172  void Undo ();
176  void Redo ();
177 };
178 
183 {
184 public:
192  DeleteOperation (gcp::Document *pDoc, unsigned long ID);
193  virtual ~DeleteOperation ();
194 
198  void Undo ();
202  void Redo ();
203 };
204 
209 {
210 public:
218  ModifyOperation (gcp::Document *pDoc, unsigned long ID);
219  virtual ~ModifyOperation ();
220 
224  void Undo ();
228  void Redo ();
229 };
230 
231 } // namespace gcp
232 
233 #endif //GCHEMPAINT_OPERATION_H