-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Implement a command transaction system
- Loading branch information
Showing
15 changed files
with
170 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "SendStrategy.hpp" | ||
|
||
#include <score/command/CommandStackFacade.hpp> | ||
#include <score/document/DocumentContext.hpp> | ||
|
||
#include <core/command/CommandStack.hpp> | ||
|
||
namespace SendStrategy | ||
{ | ||
|
||
void Simple::send(const score::CommandStackFacade& stack, score::Command* other) | ||
{ | ||
auto trans = stack.context().commandStack.transaction(); | ||
stack.redoAndPush(other); | ||
} | ||
|
||
void UndoRedo::send(const score::CommandStackFacade& stack, score::Command* other) | ||
{ | ||
auto trans = stack.context().commandStack.transaction(); | ||
other->undo(stack.context()); | ||
stack.redoAndPush(other); | ||
} | ||
|
||
void Quiet::send(const score::CommandStackFacade& stack, score::Command* other) | ||
{ | ||
stack.push(other); | ||
} | ||
|
||
} | ||
namespace RedoStrategy | ||
{ | ||
void Redo::redo(const score::DocumentContext& ctx, score::Command& cmd) | ||
{ | ||
auto trans = ctx.commandStack.transaction(); | ||
cmd.redo(ctx); | ||
} | ||
|
||
void Quiet::redo(const score::DocumentContext& ctx, score::Command& cmd) { } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,38 @@ | ||
#pragma once | ||
#include <score/command/CommandStackFacade.hpp> | ||
#include <score_lib_base_export.h> | ||
namespace score | ||
{ | ||
class CommandStackFacade; | ||
class Command; | ||
struct DocumentContext; | ||
} | ||
|
||
namespace SendStrategy | ||
{ | ||
struct Simple | ||
struct SCORE_LIB_BASE_EXPORT Simple | ||
{ | ||
static void send(const score::CommandStackFacade& stack, score::Command* other) | ||
{ | ||
stack.redoAndPush(other); | ||
} | ||
static void send(const score::CommandStackFacade& stack, score::Command* other); | ||
}; | ||
|
||
struct Quiet | ||
struct SCORE_LIB_BASE_EXPORT Quiet | ||
{ | ||
static void send(const score::CommandStackFacade& stack, score::Command* other) | ||
{ | ||
stack.push(other); | ||
} | ||
static void send(const score::CommandStackFacade& stack, score::Command* other); | ||
}; | ||
|
||
struct UndoRedo | ||
struct SCORE_LIB_BASE_EXPORT UndoRedo | ||
{ | ||
static void send(const score::CommandStackFacade& stack, score::Command* other) | ||
{ | ||
other->undo(stack.context()); | ||
stack.redoAndPush(other); | ||
} | ||
static void send(const score::CommandStackFacade& stack, score::Command* other); | ||
}; | ||
} | ||
namespace RedoStrategy | ||
{ | ||
struct Redo | ||
struct SCORE_LIB_BASE_EXPORT Redo | ||
{ | ||
static void redo(const score::DocumentContext& ctx, score::Command& cmd) | ||
{ | ||
cmd.redo(ctx); | ||
} | ||
static void redo(const score::DocumentContext& ctx, score::Command& cmd); | ||
}; | ||
|
||
struct Quiet | ||
struct SCORE_LIB_BASE_EXPORT Quiet | ||
{ | ||
static void redo(const score::DocumentContext& ctx, score::Command& cmd) { } | ||
static void redo(const score::DocumentContext& ctx, score::Command& cmd); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.