fw4spl
SCommandHistory.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __CTRLHISTORY_SCOMMANDHISTORY_HPP__
8 #define __CTRLHISTORY_SCOMMANDHISTORY_HPP__
9 
10 #include "ctrlHistory/config.hpp"
11 
12 #include <fwCommand/ICommand.hpp>
13 #include <fwCommand/UndoRedoManager.hpp>
14 
15 #include <fwCore/base.hpp>
16 
17 #include <fwServices/IService.hpp>
18 #include <fwServices/macros.hpp>
19 
20 namespace ctrlHistory
21 {
22 
51 class CTRLHISTORY_CLASS_API SCommandHistory : public ::fwServices::IService
52 {
53 public:
54 
56 
58  CTRLHISTORY_API SCommandHistory();
59 
61  CTRLHISTORY_API virtual ~SCommandHistory();
62 
63 protected:
64 
66  CTRLHISTORY_API virtual void configuring() override;
67 
69  CTRLHISTORY_API virtual void starting() override;
70 
72  CTRLHISTORY_API virtual void updating() override;
73 
75  CTRLHISTORY_API virtual void stopping() override;
76 
77 private:
78 
79  typedef ::fwCom::Signal<void (bool)> CanDoSignalType;
80 
82  void enqueue(::fwCommand::ICommand::sptr command);
83 
85  void undo();
86 
88  void redo();
89 
91  void clear();
92 
94  void emitModifSig() const;
95 
96  CanDoSignalType::sptr m_canUndoSig;
97 
98  CanDoSignalType::sptr m_canRedoSig;
99 
100  ::fwCommand::UndoRedoManager m_undoRedoManager;
101 };
102 
103 } // namespace ctrlHistory
104 
105 #endif /* __CTRLHISTORY_SCOMMANDHISTORY_HPP__ */
Base class for all services.
Definition: IService.hpp:61
Keep track of commands, undo/redo them.
The namespace ctrlHistory contains services handling command histories.
This service manages a command history. The history is modified when receiving "undo", "redo", "enqueue" or "clear" signal.
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.