OpenWalnut  1.5.0dev
WActionHandler.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WACTIONHANDLER_H
26 #define WACTIONHANDLER_H
27 
28 #include <memory>
29 #include <vector>
30 
31 #include "WFiberAction.h"
32 
33 
34 /**
35  * Handles undo and redo action.
36  */
38 {
39 public:
40  /**
41  * A shared_ptr to this class.
42  */
43  typedef std::shared_ptr< WActionHandler > SPtr;
44 
45  /**
46  * Creates the undo and redo vectors.
47  */
49 
50  /**
51  * Clears the vectors for destruction.
52  */
54 
55  /**
56  * Pushes an action to the undo vector and clears the redo vector.
57  * \param action The ation to push.
58  */
59  void pushAction( WFiberAction::SPtr action );
60 
61  /**
62  * Undos the last action and pushes it to the redo vector.
63  */
64  void undo();
65 
66  /**
67  * Redos the last action and pushes it to the undo vector.
68  */
69  void redo();
70 
71 private:
72  /**
73  * A shared_ptr to a vector of an action.
74  */
75  typedef std::shared_ptr< std::vector< WFiberAction::SPtr > > ActionStack;
76 
77  /**
78  * The undo vector.
79  */
81 
82  /**
83  * The redo vector.
84  */
86 };
87 
88 #endif // WACTIONHANDLER_H
Handles undo and redo action.
~WActionHandler()
Clears the vectors for destruction.
void pushAction(WFiberAction::SPtr action)
Pushes an action to the undo vector and clears the redo vector.
WActionHandler()
Creates the undo and redo vectors.
std::shared_ptr< WActionHandler > SPtr
A shared_ptr to this class.
void redo()
Redos the last action and pushes it to the undo vector.
ActionStack m_redo
The redo vector.
void undo()
Undos the last action and pushes it to the redo vector.
std::shared_ptr< std::vector< WFiberAction::SPtr > > ActionStack
A shared_ptr to a vector of an action.
ActionStack m_undo
The undo vector.
std::shared_ptr< WFiberAction > SPtr
A shared_ptr to this class.
Definition: WFiberAction.h:41