HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_UndoWorkerFinder.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_UndoWorkerFinder.h
7  *
8  * COMMENTS:
9  * This class is contained within an object that does the work to
10  * execute an undo (the undo worker). When the worker is constructed,
11  * an object of this class is also constructed, and the object adds
12  * itself to the table of undo workers. When the worker is
13  * destructed, this object is also destructed, and this class removes
14  * itself from the table of undo worker finders.
15  *
16  * Use this class as follows:
17  *
18  * - If the class that executes the undo/redo's is called Worker, add a
19  * member variable of type UT_UndoWorkerFinder<Worker> and pass in
20  * a reference to the Worker class in the worker finder's constructor.
21  * - Create undos that are a subclass of UT_DelegatedUndo<Worker> and
22  * pass the a reference to the undo worker finder to the constructor
23  * of the delegated undo.
24  * - The delegated undo's undoWorker() method will return a pointer
25  * to the Worker object, or null if it has been deleted. The
26  * undo()/redo() method will not be called if the undo worker was
27  * deleted, so undoWorker() won't return null in these methods.
28  */
29 
30 #ifndef __UT_UndoWorkerFinder_h__
31 #define __UT_UndoWorkerFinder_h__
32 
33 #include "UT_API.h"
34 #include "UT_NonCopyable.h"
35 
36 // This base class treats the undo worker as a void pointer.
37 // Because our opaque undo worker often is a self pointer, we can't
38 // copy this as we don't know how to update it.
40 {
41 public:
42  UT_UndoWorkerFinderBase(void *opaque_undo_worker);
44 
46 
47  int undoWorkerId() const { return myUndoWorkerId; }
48 
49  // Normally, the destructor will invalidate itself, but you can invoke this
50  // earlier if you want.
51  void invalidate();
52 
53 private:
54  // The UT_UndoWorkerFinderTable class may set our undo worker id.
56 
57  void *myOpaqueUndoWorker;
58  int myUndoWorkerId;
59 };
60 
61 
62 // This templated class is a convenience class. Its methods are all inlined.
63 template <class UndoWorker>
65 {
66 public:
67  UT_UndoWorkerFinder(UndoWorker &undo_worker)
68  : UT_UndoWorkerFinderBase(&undo_worker) {}
69 
70 private:
71 };
72 
73 
74 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
UT_UndoWorkerFinder(UndoWorker &undo_worker)
#define UT_API
Definition: UT_API.h:14
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.