HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_DelegatedUndo.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_DelegatedUndo.h
7  *
8  * COMMENTS:
9  * This class is the base class for undo objects that delegate their
10  * work to someone else (the undo worker). It uses UT_UndoWorkerFinder's
11  * to see if the undo worker has been deleted.
12  *
13  * See the comments in UT_UndoWorkerFinder.h for instructions on how
14  * to use this class.
15  */
16 
17 #ifndef __UT_DelegatedUndo_h__
18 #define __UT_DelegatedUndo_h__
19 
20 #include "UT_API.h"
21 #include "UT_Undo.h"
22 #include "UT_UndoWorkerFinder.h"
23 
24 // Undo classes do not need to work with UT_DelegatedUndoBase directly.
26 {
27 public:
28  UT_DelegatedUndoBase(int undo_worker_id);
29  virtual ~UT_DelegatedUndoBase() { }
30 
31  // We can't undo or redo anything if our undo worker has been deleted.
32  virtual bool isValid() { return opaqueUndoWorker() != 0; }
33 
34 protected:
35  void *opaqueUndoWorker();
36 
37 private:
38  int myUndoWorkerId;
39 };
40 
41 
42 // This templated class is a convenience class to avoid casting.
43 template <class UndoWorker>
45 {
46 public:
48  : UT_DelegatedUndoBase(undo_worker_finder.undoWorkerId()) {}
49 
50 protected:
51  // A null pointer is returned if the undo work has been deleted.
52  // The undo() and redo() methods will not be called when undoWorker()
53  // returns null.
54  UndoWorker *undoWorker() { return (UndoWorker *)opaqueUndoWorker(); }
55 };
56 
57 
58 #endif
#define UT_API
Definition: UT_API.h:12
UndoWorker * undoWorker()
virtual bool isValid()
virtual ~UT_DelegatedUndoBase()
UT_DelegatedUndo(const UT_UndoWorkerFinder< UndoWorker > &undo_worker_finder)