Loading...
Searching...
No Matches
CreationMetaCommand.hpp
1#pragma once
2#include "CreateEvent_State.hpp"
3#include "CreateInterval.hpp"
4#include "CreateInterval_State.hpp"
5#include "CreateInterval_State_Event.hpp"
6#include "CreateInterval_State_Event_TimeSync.hpp"
7#include "CreateSequence.hpp"
8#include "CreateState.hpp"
9
10#include <score/command/AggregateCommand.hpp>
11
12#include <boost/range/adaptor/reversed.hpp>
13namespace Scenario
14{
15namespace Command
16{
18{
19 SCORE_COMMAND_DECL(
20 CommandFactoryName(), CreationMetaCommand, "Create elements in scenario")
21public:
22 void undo(const score::DocumentContext& ctx) const override
23 {
24 // We only undo the creation commands
25 // since the move ones perform unnecessary serialization / etc in this case
26 // and don't bring anything to the table.
27 // TODO REFACTOR WITH SCENARIOROLLBACKSTRATEGY
28 for(auto& cmd : boost::adaptors::reverse(m_cmds))
29 {
30 if(cmd->key() == CreateInterval::static_key()
31 || cmd->key() == CreateState::static_key()
32 || cmd->key() == CreateEvent_State::static_key()
33 || cmd->key() == CreateInterval_State::static_key()
34 || cmd->key() == CreateInterval_State_Event::static_key()
35 || cmd->key() == CreateInterval_State_Event_TimeSync::static_key()
36 || cmd->key() == CreateSequence::static_key())
37 {
38 cmd->undo(ctx);
39 }
40 }
41 }
42};
43}
44}
Definition CreationMetaCommand.hpp:18
Allows for grouping of multiple commands in a single one.
Definition AggregateCommand.hpp:15
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
Definition DocumentContext.hpp:18