Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgGtpCommands.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgGtpCommands.h
00003     General utility GTP commands.
00004 */
00005 //----------------------------------------------------------------------------
00006 
00007 #ifndef SG_GTPCOMMANDS_H
00008 #define SG_GTPCOMMANDS_H
00009 
00010 #include "GtpEngine.h"
00011 
00012 //----------------------------------------------------------------------------
00013 
00014 /** General utility GTP commands.
00015     Implements generally useful command, which do not require a board or
00016     player. Uses functionality from module SmartGo.
00017     This class can be used in GTP engines.
00018     @note
00019     You should make it a member of your engine to ensure that its lifetime
00020     is as long as the engine's lifetime, otherwise the pointers in GtpCallback
00021     will point to freed memory.
00022     @see @ref sggtpcommandscommands
00023 */
00024 class SgGtpCommands
00025 {
00026 public:
00027     /** Constructor.
00028         @param engine The GTP engine (needed for wrapper commands that invoke
00029         arbitrary other engine commands like sg_compare_float)
00030         @param programPath The path to the executable for the engine for
00031         sg_debug, 0 if unknown
00032     */
00033     SgGtpCommands(GtpEngine& engine, const char* programPath = 0);
00034 
00035     virtual ~SgGtpCommands();
00036 
00037     /** @page sggtpcommandscommands SgGtpCommands Commands
00038         - @link CmdCpuTime() @c cputime @endlink
00039         - @link CmdCpuTimeReset() @c cputime_reset @endlink
00040         - @link CmdEcho() @c echo @endlink
00041         - @link CmdEchoErr() @c echo_err @endlink
00042         - @link CmdGetRandomSeed() @c get_random_seed @endlink
00043         - @link CmdPid() @c pid @endlink
00044         - @link CmdSetRandomSeed() @c set_random_seed @endlink
00045         - @link CmdCompareFloat() @c sg_compare_float @endlink
00046         - @link CmdCompareInt() @c sg_compare_int @endlink
00047         - @link CmdDebugger() @c sg_debugger @endlink
00048         - @link CmdExec() @c sg_exec @endlink
00049         - @link CmdParam() @c sg_param @endlink
00050         - @link CmdQuiet() @c quiet @endlink
00051     */
00052     /** @name Command Callbacks */
00053     // @{
00054     virtual void CmdCompareFloat(GtpCommand&);
00055     virtual void CmdCompareInt(GtpCommand&);
00056     virtual void CmdCpuTime(GtpCommand&);
00057     virtual void CmdCpuTimeReset(GtpCommand&);
00058     virtual void CmdDebugger(GtpCommand&);
00059     virtual void CmdEcho(GtpCommand&);
00060     virtual void CmdEchoErr(GtpCommand&);
00061     virtual void CmdExec(GtpCommand&);
00062     virtual void CmdGetRandomSeed(GtpCommand&);
00063     virtual void CmdParam(GtpCommand&);
00064     virtual void CmdPid(GtpCommand&);
00065     virtual void CmdSetRandomSeed(GtpCommand&);
00066     virtual void CmdQuiet(GtpCommand&);
00067     // @} // @name
00068 
00069     void AddGoGuiAnalyzeCommands(GtpCommand& cmd);
00070 
00071     /** Register commands at engine.
00072         Make sure that this object lives as long as the GtpEngine,
00073         for example by making it a member of the engine.
00074     */
00075     void Register(GtpEngine& engine);
00076 
00077 private:
00078     const char* m_programPath;
00079 
00080     GtpEngine& m_engine;
00081 
00082     /** Cputimes for cputime and cputime_reset commands. */
00083     std::map<std::string,double> m_cpuTimes;
00084 };
00085 
00086 //----------------------------------------------------------------------------
00087 
00088 #endif // SG_GTPCOMMANDS_H


17 Jun 2010 Doxygen 1.4.7