Client connection to an external GTP engine. More...
#include <SgGtpClient.h>
Public Member Functions | |
SgGtpClient (std::istream &in, std::ostream &out, bool verbose=false) | |
Constructor. | |
virtual | ~SgGtpClient () |
std::string | Send (const std::string &command) |
Send a command. | |
Private Attributes | |
bool | m_verbose |
std::istream & | m_in |
std::ostream & | m_out |
Client connection to an external GTP engine.
Usage example:
// Run GNU Go and send a GTP command try { SgProcess process("gnugo --mode gtp"); SgGtpClient gtp(process.Input(), process.Output()); string result = gtp.Send("version"); SgDebug() << "Success response: " << result << '\n'; } catch (const SgGtpFailure& e) { SgDebug() << "Error response: " << e.what() << '\n'; } catch (const SgException& e) { SgDebug() << "Error running GNU Go: " << e.what() << '\n'; }
Definition at line 49 of file SgGtpClient.h.
SgGtpClient::SgGtpClient | ( | std::istream & | in, | |
std::ostream & | out, | |||
bool | verbose = false | |||
) |
Constructor.
in | Input stream. | |
out | Output stream. | |
verbose | Log stream to SgDebug() |
Definition at line 23 of file SgGtpClient.cpp.
SgGtpClient::~SgGtpClient | ( | ) | [virtual] |
Definition at line 30 of file SgGtpClient.cpp.
string SgGtpClient::Send | ( | const std::string & | command | ) |
Send a command.
SgGtpFailure | If command fails or connection is broken. |
Definition at line 34 of file SgGtpClient.cpp.
std::istream& SgGtpClient::m_in [private] |
Definition at line 69 of file SgGtpClient.h.
Referenced by Send().
std::ostream& SgGtpClient::m_out [private] |
Definition at line 71 of file SgGtpClient.h.
Referenced by Send().
bool SgGtpClient::m_verbose [private] |
Definition at line 67 of file SgGtpClient.h.
Referenced by Send().