00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Luke Moore 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: UT_UndoWorkerFinder.h 00015 * 00016 * COMMENTS: 00017 * This class is contained within an object that does the work to 00018 * execute an undo (the undo worker). When the worker is constructed, 00019 * an object of this class is also constructed, and the object adds 00020 * itself to the table of undo workers. When the worker is 00021 * destructed, this object is also destructed, and this class removes 00022 * itself from the table of undo worker finders. 00023 * 00024 * Use this class as follows: 00025 * 00026 * - If the class that executes the undo/redo's is called Worker, add a 00027 * member variable of type UT_UndoWorkerFinder<Worker> and pass in 00028 * a reference to the Worker class in the worker finder's constructor. 00029 * - Create undos that are a subclass of UT_DelegatedUndo<Worker> and 00030 * pass the a reference to the undo worker finder to the constructor 00031 * of the delegated undo. 00032 * - The delegated undo's undoWorker() method will return a pointer 00033 * to the Worker object, or null if it has been deleted. The 00034 * undo()/redo() method will not be called if the undo worker was 00035 * deleted, so undoWorker() won't return null in these methods. 00036 */ 00037 00038 #ifndef __UT_UndoWorkerFinder_h__ 00039 #define __UT_UndoWorkerFinder_h__ 00040 00041 #include "UT_API.h" 00042 // This base class treats the undo worker as a void pointer. 00043 class UT_API UT_UndoWorkerFinderBase 00044 { 00045 public: 00046 UT_UndoWorkerFinderBase(void *opaque_undo_worker); 00047 ~UT_UndoWorkerFinderBase(); 00048 00049 int undoWorkerId() const { return myUndoWorkerId; } 00050 00051 private: 00052 // The UT_UndoWorkerFinderTable class may set our undo worker id. 00053 friend class UT_UndoWorkerFinderTable; 00054 00055 void *myOpaqueUndoWorker; 00056 int myUndoWorkerId; 00057 }; 00058 00059 00060 // This templated class is a convenience class. Its methods are all inlined. 00061 template <class UndoWorker> 00062 class UT_UndoWorkerFinder : public UT_UndoWorkerFinderBase 00063 { 00064 public: 00065 UT_UndoWorkerFinder(UndoWorker &undo_worker) 00066 : UT_UndoWorkerFinderBase(&undo_worker) {} 00067 00068 private: 00069 }; 00070 00071 00072 #endif
1.5.9