#pragma once /** * \file CommandVisitor.h * \brief File containing the sp::protocol::CommandVisitor class */ #include 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