The Command
Encapsulating an incantation as an object to be invoked later.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Enchantment // Binding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EXECUTABLE C++ PATTERN //
#include <memory>
class SpellCommand {
public: virtual ~SpellCommand() = default; virtual void Execute() = 0;
};
class Teleport : public SpellCommand {
public: void Execute() override {}
};
class Wand {
std::unique_ptr<SpellCommand> cmd;
public:
void Bind(std::unique_ptr<SpellCommand> c) { cmd = std::move(c); }
void Wave() { if(cmd) cmd->Execute(); }
};
Runic Tags:
#behavioral
#command
#cpp