first commit
This commit is contained in:
39
include/sp/protocol/command/CommandVisitor.h
Normal file
39
include/sp/protocol/command/CommandVisitor.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file CommandVisitor.h
|
||||
* \brief File containing the sp::protocol::CommandVisitor class
|
||||
*/
|
||||
|
||||
#include <sp/protocol/command/Commands.h>
|
||||
|
||||
namespace sp {
|
||||
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 sp
|
||||
Reference in New Issue
Block a user