Files
Tower-Defense2/src/td/protocol/command/CommandFactory.cpp
2024-10-18 15:36:00 +02:00

25 lines
709 B
C++

#include <td/protocol/command/CommandFactory.h>
#include <array>
#include <cassert>
#include <functional>
namespace td {
namespace protocol {
namespace CommandFactory {
using CommandCreator = std::function<std::shared_ptr<Command>()>;
#define DeclareCommand(CommandName, ...) std::make_shared<commands::CommandName>(),
static std::array<std::shared_ptr<Command>, static_cast<std::size_t>(CommandType::COMMAND_COUNT)> Commands = {DeclareAllCommand()};
const std::shared_ptr<Command>& CreateReadOnlyCommand(CommandType a_Type) {
assert(a_Type < CommandType::COMMAND_COUNT);
return Commands[static_cast<std::size_t>(a_Type)];
}
} // namespace CommandFactory
} // namespace protocol
} // namespace td