Record.hpp
1 #pragma once
2 #include <Recording/Commands/RecordingCommandFactory.hpp>
3 
4 #include <score/command/AggregateCommand.hpp>
5 
6 #include <ossia/detail/ssize.hpp>
7 
8 namespace Recording
9 {
10 class Record final : public score::AggregateCommand
11 {
12  SCORE_COMMAND_DECL(RecordingCommandFactoryName(), Record, "Record")
13 public:
14  void undo(const score::DocumentContext& ctx) const override
15  {
16  const int N = std::ssize(m_cmds);
17  // Undo 1
18  if(N >= 2)
19  {
20  auto it = m_cmds.begin();
21  std::advance(it, 1);
22  (*it)->undo(ctx);
23  }
24 
25  if(N >= 1)
26  {
27  // Undo 0
28  (*m_cmds.begin())->undo(ctx);
29  }
30  }
31 };
32 }
Definition: Record.hpp:11
Allows for grouping of multiple commands in a single one.
Definition: AggregateCommand.hpp:15
Definition: DocumentContext.hpp:18