BsEditorCommand.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. namespace bs
  6. {
  7. /** @addtogroup UndoRedo
  8. * @{
  9. */
  10. /**
  11. * A command used for undo/redo purposes. It records a change occurring on some object and allows you to apply or
  12. * revert that change as needed.
  13. */
  14. class BS_ED_EXPORT EditorCommand
  15. {
  16. public:
  17. EditorCommand(const String& description);
  18. virtual ~EditorCommand() { }
  19. /** Applies the command, committing the change. */
  20. virtual void commit() { }
  21. /** Reverts the command, reverting the change previously done with commit(). */
  22. virtual void revert() { }
  23. private:
  24. friend class UndoRedo;
  25. /** Triggers when a command is added to an undo/redo stack. */
  26. virtual void onCommandAdded() { }
  27. /** Triggers when a command is removed from an undo/redo stack. */
  28. virtual void onCommandRemoved() {}
  29. String mDescription;
  30. UINT32 mId;
  31. };
  32. /** @} */
  33. }