00001 #ifndef GNUCHESSCONTROLER_HPP
00002 #define GNUCHESSCONTROLER_HPP
00003
00004 #include "Controler.hpp"
00005 #include "Game/Boards/ChessBoard.hpp"
00006
00007 #include <cassert>
00008
00009 #ifdef Q_OS_LINUX
00010 class GNUChessControler : public Controler<ChessBoard>
00011 {
00012 private:
00013
00014 int m_readPipe[2];
00015 int m_writePipe[2];
00016 int m_forkID;
00017
00018 bool m_isStarted;
00019
00020 void sendCommand(const std::string& command)const;
00021
00022 public:
00023 GNUChessControler();
00024 ~GNUChessControler();
00025
00030 void start();
00031 Move<ChessBoard::Coords> getMove();
00032
00033 void notify(const Move<ChessBoard::Coords> & move);
00034
00039 void setColorControled(int color)
00040 {
00041 assert(m_isStarted);
00042
00043 m_colorControlled = color;
00044 if ( color == 0 )
00045 {
00046 sendCommand("white");
00047 sendCommand("go");
00048 }
00049 }
00050 };
00051 #endif
00052
00062 #endif