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


Sun Mar 13 2011 Doxygen 1.7.1