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