PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llundo.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 68 lines | 35 code | 8 blank | 25 comment | 2 complexity | 7bac9818b1d02361e204e4a069bc7fd6 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llundo.h
  3. * @brief Generic interface for undo/redo circular buffer.
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLUNDO_H
  27. #define LL_LLUNDO_H
  28. class LLUndoBuffer
  29. {
  30. public:
  31. class LLUndoAction
  32. {
  33. friend class LLUndoBuffer;
  34. public:
  35. virtual void undo() = 0;
  36. virtual void redo() = 0;
  37. virtual void cleanup() {};
  38. protected:
  39. LLUndoAction(): mClusterID(0) {};
  40. virtual ~LLUndoAction(){};
  41. private:
  42. S32 mClusterID;
  43. };
  44. LLUndoBuffer( LLUndoAction (*create_func()), S32 initial_count );
  45. virtual ~LLUndoBuffer();
  46. LLUndoAction *getNextAction(BOOL setClusterBegin = TRUE);
  47. BOOL undoAction();
  48. BOOL redoAction();
  49. BOOL canUndo() { return (mNextAction != mFirstAction); }
  50. BOOL canRedo() { return (mNextAction != mLastAction); }
  51. void flushActions();
  52. private:
  53. LLUndoAction **mActions; // array of pointers to undoactions
  54. S32 mNumActions; // total number of actions in ring buffer
  55. S32 mNextAction; // next action to perform undo/redo on
  56. S32 mLastAction; // last action actually added to undo buffer
  57. S32 mFirstAction; // beginning of ring buffer (don't undo any further)
  58. S32 mOperationID; // current operation id, for undoing and redoing in clusters
  59. };
  60. #endif //LL_LLUNDO_H