00001 00032 #ifndef LL_LLUNDO_H 00033 #define LL_LLUNDO_H 00034 00035 class LLUndoAction 00036 { 00037 friend class LLUndoBuffer; 00038 protected: 00039 S32 mClusterID; 00040 protected: 00041 LLUndoAction(): mClusterID(0) {}; 00042 virtual ~LLUndoAction(){}; 00043 00044 public: 00045 static LLUndoAction *create() { return NULL; } 00046 00047 virtual void undo() = 0; 00048 virtual void redo() = 0; 00049 virtual void cleanup() {}; 00050 }; 00051 00052 class LLUndoBuffer 00053 { 00054 protected: 00055 LLUndoAction **mActions; // array of pointers to undoactions 00056 S32 mNumActions; // total number of actions in ring buffer 00057 S32 mNextAction; // next action to perform undo/redo on 00058 S32 mLastAction; // last action actually added to undo buffer 00059 S32 mFirstAction; // beginning of ring buffer (don't undo any further) 00060 S32 mOperationID; // current operation id, for undoing and redoing in clusters 00061 00062 public: 00063 LLUndoBuffer( LLUndoAction (*create_func()), S32 initial_count ); 00064 virtual ~LLUndoBuffer(); 00065 00066 LLUndoAction *getNextAction(BOOL setClusterBegin = TRUE); 00067 BOOL undoAction(); 00068 BOOL redoAction(); 00069 BOOL canUndo() { return (mNextAction != mFirstAction); } 00070 BOOL canRedo() { return (mNextAction != mLastAction); } 00071 00072 void flushActions(); 00073 }; 00074 00075 #endif //LL_LLUNDO_H