AggregateCommand.hpp
1 #pragma once
2 #include <score/command/Command.hpp>
3 
4 #include <list>
5 #include <memory>
6 
7 namespace score
8 {
14 class SCORE_LIB_BASE_EXPORT AggregateCommand : public score::Command
15 {
16  using command_ptr = score::Command*;
17 
18 public:
19  AggregateCommand() = default;
20  virtual ~AggregateCommand();
21 
22  template <typename T>
23  AggregateCommand(T* cmd)
25  {
26  m_cmds.push_front(cmd);
27  }
28 
35  template <typename T, typename... Args>
36  AggregateCommand(T* cmd, Args&&... remaining)
37  : AggregateCommand{std::forward<Args>(remaining)...}
38  {
39  m_cmds.push_front(cmd);
40  }
41 
42  void undo(const score::DocumentContext& ctx) const override;
43  void redo(const score::DocumentContext& ctx) const override;
44 
46  void addCommand(score::Command* cmd);
47 
49  int count() const;
50 
51  const auto& commands() const { return m_cmds; }
52 
53 protected:
54  void serializeImpl(DataStreamInput&) const override;
55  void deserializeImpl(DataStreamOutput&) override;
56 
57  std::list<score::Command*> m_cmds;
58 };
59 }
Allows for grouping of multiple commands in a single one.
Definition: AggregateCommand.hpp:15
AggregateCommand(T *cmd, Args &&... remaining)
Definition: AggregateCommand.hpp:36
The Command class.
Definition: Command.hpp:34
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: DocumentContext.hpp:18