corecommand.h
Go to the documentation of this file.
1 #ifndef DNAI_COMMANDS_CORECOMMAND_H
2 #define DNAI_COMMANDS_CORECOMMAND_H
3 
4 #include <functional>
5 #include <queue>
6 
7 #include "command.h"
8 #include "core.h"
9 
10 namespace dnai
11 {
12  namespace commands
13  {
14  class CoreCommand : public Command
15  {
16  public:
17  using Event = std::function<void()>;
18 
19  public:
20  CoreCommand(QString const &name, bool save, Event const &exec, Event const &undo);
21  virtual ~CoreCommand() = default;
22 
23  public:
24  void execute() const override;
25  void executeSave() override;
26  void unExcute() const override;
27 
28  private:
31 
32  private:
33  static std::queue<CoreCommand *> commandQueue;
34 
35  public:
36  static void Success();
37  static void Error();
38  };
39  }
40 }
41 
42 #endif // DNAI_COMMANDS_CORECOMMAND_H
void executeSave() override
Save current state of the command for the reverse unExcute()
Definition: corecommand.cpp:27
Definition: corecommand.h:14
Event exec
Definition: corecommand.h:29
void unExcute() const override
Reverse the execute() function.
Definition: corecommand.cpp:32
Event undo
Definition: corecommand.h:30
static void Error()
Definition: corecommand.cpp:47
void execute() const override
Execute the command.
Definition: corecommand.cpp:18
std::function< void()> Event
Definition: corecommand.h:17
virtual ~CoreCommand()=default
CoreCommand(QString const &name, bool save, Event const &exec, Event const &undo)
Definition: corecommand.cpp:10
Definition: command.h:11
static void Success()
Definition: corecommand.cpp:41
Definition: api.h:13
static std::queue< CoreCommand * > commandQueue
Definition: corecommand.h:33
const QString & name() const
Get the command name.
Definition: command.cpp:34