40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
#pragma once
|
|
|
|
/**
|
|
* \file CommandVisitor.h
|
|
* \brief File containing the td::protocol::CommandVisitor class
|
|
*/
|
|
|
|
#include <td/protocol/command/Commands.h>
|
|
|
|
namespace td {
|
|
namespace protocol {
|
|
|
|
#define DeclareCommand(CommandName, ...) \
|
|
/** This function is called when the packet processed by CommandVisitor::Check is a CommandName */ \
|
|
virtual void Visit(const commands::CommandName&) {}
|
|
|
|
/**
|
|
* \class CommandVisitor
|
|
* \brief This class uses double-dispatch in order to find the real type of a packet
|
|
*/
|
|
class CommandVisitor : private NonCopyable {
|
|
protected:
|
|
CommandVisitor() {}
|
|
virtual ~CommandVisitor() {}
|
|
|
|
public:
|
|
/**
|
|
* \brief Calls the right CommandVisitor::Visit method corresponding to the real type of the packet
|
|
* \param packet the Command to visit
|
|
*/
|
|
void Check(const Command& packet);
|
|
|
|
DeclareAllCommand()
|
|
};
|
|
|
|
#undef DeclareCommand
|
|
|
|
} // namespace protocol
|
|
} // namespace td
|