add tests
This commit is contained in:
26
src/td/protocol/command/CommandFactory.cpp
Normal file
26
src/td/protocol/command/CommandFactory.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <td/protocol/command/CommandFactory.h>
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
|
||||
namespace td {
|
||||
namespace protocol {
|
||||
namespace CommandFactory {
|
||||
|
||||
using CommandCreator = std::function<std::unique_ptr<Command>()>;
|
||||
|
||||
#define DeclareCommand(CommandName, ...) std::make_unique<commands::CommandName>(),
|
||||
|
||||
static std::array<std::unique_ptr<Command>, static_cast<std::size_t>(CommandType::COMMAND_COUNT)> Commands = {
|
||||
DeclareAllCommand()
|
||||
};
|
||||
|
||||
const std::unique_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
|
||||
Reference in New Issue
Block a user