Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Attributes

SgGtpClient Class Reference

Client connection to an external GTP engine. More...

#include <SgGtpClient.h>

List of all members.

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

Detailed Description

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.


Constructor & Destructor Documentation

SgGtpClient::SgGtpClient ( std::istream &  in,
std::ostream &  out,
bool  verbose = false 
)

Constructor.

Parameters:
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.


Member Function Documentation

string SgGtpClient::Send ( const std::string &  command  ) 

Send a command.

Returns:
The response if command succeeds (without status character and whitespace after status character)
Exceptions:
SgGtpFailure If command fails or connection is broken.

Definition at line 34 of file SgGtpClient.cpp.

References m_in, m_out, m_verbose, and SgDebug().


Member Data Documentation

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().


The documentation for this class was generated from the following files:


Sun Mar 13 2011 Doxygen 1.7.1