Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Classes | Defines | Functions

GtpEngine.h File Reference

Basic implementation of the Go Text Protocol (GTP). More...

#include <cstddef>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <limits>
#include <typeinfo>
#include "GtpInputStream.h"
#include "GtpOutputStream.h"

Go to the source code of this file.

Classes

class  GtpFailure
 GTP failure. More...
class  GtpCommand
 GTP command. More...
struct  GtpCommand::Argument
 Argument in command line. More...
class  GtpCallbackBase
 Abstract base class for command handlers. More...
class  GtpCallback< ENGINE >
 Member function command handlers. More...
class  GtpEngine
 Base class for GTP (Go Text Protocol) engines. More...

Defines

#define GTPENGINE_PONDER   1
 Macro for enabling pondering.
#define GTPENGINE_INTERRUPT   1
 Macro for enabling interrupt ability.

Functions

template<>
std::size_t GtpCommand::Arg< std::size_t > (std::size_t i) const
 Specialization of Arg<T> for T=size_t to work around a GCC bug.

Detailed Description

Basic implementation of the Go Text Protocol (GTP).

Depends only on the standard C++ library for maximum reusability. If ponder or interrupt functionality is enabled by setting the macros GTPENGINE_PONDER and/or GTPENGINE_INTERRUPT to 1, the Boost.Thread library is also needed.

GtpEngine implements a GTP engine with some basic commands. This class is typically used as a base class for other GTP engines. GtpEngine::Register allows to register additional commands. GtpEngine::MainLoop starts the main command loop. Command handlers implement the interface GtpCallbackBase. For class member functions, such a callback can be constructed with the GtpCallback template class. Each callback function is passed a GtpCommand argument, which can be queried for arguments and used for writing the response to. GTP error responses are created by throwing an instance of GtpFailure. All such exceptions are caught in the main loop and converted into a response with error status.

Definition in file GtpEngine.h.


Define Documentation

#define GTPENGINE_INTERRUPT   1

Macro for enabling interrupt ability.

If this macro is enabled, GtpEngine has the additional function Interrupt() to interrupt a running command. Enabling this macro adds a dependency on the Boost.Thread library.

See also:
GtpEngine::Interrupt()

Definition at line 56 of file GtpEngine.h.

#define GTPENGINE_PONDER   1

Macro for enabling pondering.

If this macro is enabled, GtpEngine has the additional functions Ponder(), InitPonder() and StopPonder(), which will be called while waiting for the next command. This can be used for thinking during the opponent's time. Enabling this macro adds a dependency on the Boost.Thread library.

See also:
GtpEngine::Ponder()

Definition at line 47 of file GtpEngine.h.


Function Documentation

std::size_t GtpCommand::Arg< std::size_t > ( std::size_t  i  )  const

Specialization of Arg<T> for T=size_t to work around a GCC bug.

Workaround for bug in standard library of some GCC versions (e.g. GCC 4.4.1 on Ubuntu 9.10): negative numbers are parsed without error as size_t. The definition of this function is in GtpEngine.cpp, otherwise GCC 4.5.5 produces a link error, but there must be the function declaration in this header file, otherwise Visual Studio 2010 produces a link error.


Sun Mar 13 2011 Doxygen 1.7.1