MASA-Core
Command.hpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2010-2015   Edans Sandes
00004  *
00005  * This file is part of MASA-Core.
00006  * 
00007  * MASA-Core is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation, either version 3 of the License, or
00010  * (at your option) any later version.
00011  * 
00012  * MASA-Core is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with MASA-Core.  If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  ******************************************************************************/
00021 
00022 class Command;
00023 
00024 #ifndef COMMAND_HPP_
00025 #define COMMAND_HPP_
00026 
00027 #include "../Peer.hpp"
00028 
00029 #define REQUEST_COMMAND         0x1000
00030 #define RESPONSE_COMMAND        0x2000
00031 
00032 #define COMMAND_JOIN                    (1)
00033 #define COMMAND_LEAVE                   (2)
00034 #define COMMAND_NOTIFY_SCORE    (3)
00035 #define COMMAND_DISCOVER                (4)
00036 #define COMMAND_STATUS_REQUEST  (5 | REQUEST_COMMAND)
00037 #define COMMAND_STATUS_RESPONSE (5 | RESPONSE_COMMAND)
00038 #define COMMAND_PEER_REQUEST    (6 | REQUEST_COMMAND)
00039 #define COMMAND_PEER_RESPONSE   (6 | RESPONSE_COMMAND)
00040 #define COMMAND_CREATE_RING             (7)
00041 #define COMMAND_UNDISCOVER              (8)
00042 #define COMMAND_TEST_RING               (9)
00043 
00044 class Command {
00045 public:
00046         Command();
00047         virtual ~Command();
00048 
00049         virtual int getId() = 0;
00050 
00051         virtual void send(Peer* socket) = 0;
00052         virtual void receive(Peer* socket) = 0;
00053 
00054         int getSerial() const;
00055         void setSerial(int serial);
00056 
00057 private:
00058         int serial;
00059 };
00060 
00061 #endif /* COMMAND_HPP_ */