2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
15 #include <boost/weak_ptr.hpp>
23 * @brief An external chess engine.
25 * This class incapsulates a connection with
26 * an external engine process in a protocol
29 class Engine
: public QObject
, public TextNotifier
{
33 QStringList m_arguments
;
36 boost::shared_ptr
<Console
> m_console
;
37 boost::weak_ptr
<EngineNotifier
> m_notifier
;
39 virtual void initializeEngine() = 0;
42 * Create an engine, setting the path to the engine
43 * program and its arguments.
45 Engine(const QString
& path
, const QStringList
& arguments
);
47 void setWorkingPath(const QString
& workPath
) { m_workPath
= workPath
; }
52 * Start the engine program. The initialization will
53 * take place automatically after the program has started.
58 * Send a command to the engine.
60 void sendCommand(const QString
& command
, bool echo
= true);
63 * Send a move to the engine.
65 virtual void sendMove(AbstractMove::Ptr move
, AbstractPosition::Ptr ref
) = 0;
69 * @param pos The position before the move. Used if the engine
70 * does not support the undo command.
72 virtual void backUp(AbstractPosition::Ptr pos
) = 0;
74 virtual void setBoard(AbstractPosition::Ptr pos
, int halfmove
, int fullmove
) = 0;
76 virtual void startAnalysis() = 0;
77 virtual void stopAnalysis() = 0;
82 virtual void reset(int side
) = 0;
87 virtual void stop() = 0;
90 * Receive a user command.
92 virtual void textNotify(const QString
& text
);
94 void setNotifier(const boost::shared_ptr
<EngineNotifier
>& notifier
);
95 void setConsole(const boost::shared_ptr
<Console
>& console
);
102 * Emitted when the engine sends a command to the interface.
104 void receivedCommand(const QString
& command
);
107 * Emitted when the engine exits (or crashes, etc...).
109 void lostConnection();