Re: [Housebot-developers] SF.net SVN: housebot: [466] trunk/housebot/src
Status: Alpha
Brought to you by:
j_house
|
From: Phil G <go...@th...> - 2007-02-08 03:08:12
|
Jason:=0A=0AI just reviewed the "GTPFunctionObjectTemplate.hpp". It is a fi=
ne example of macro expansion using the c++ preprocessor. However, are you =
sure you want to go in this direction? This is an awfully complex (and obtu=
se) coding style - more macro rather than object oriented. It also has limi=
tations on the number of arguments. I'm worried about code maintainability =
and readability. =0A=0AOn another note for correctness, I think you wish to=
include "b" and "B" as Black and "W" and "w" for White, in the code below,=
or better yet, just check the first character.=0A=0A+ template<> inline=
=0A+ color_t converter(SmartString &x){=0A+ if (x=3D=3D"black" || x=3D=
=3D"Black" || x=3D=3D"BLACK")=0A+ return black;=0A+ if (x=3D=3D"whi=
te" || x=3D=3D"White" || x=3D=3D"WHITE")=0A+ return white;=0A+ asse=
rt(false);=0A+ }=0A=0APhil=0A=0A----- Original Message ----=0AFrom: "j_hou=
se...@us..." <j_...@us...>=0ATo: housebot-de=
vel...@li...=0ASent: Tuesday, February 6, 2007 4:16:25 PM=
=0ASubject: [Housebot-developers] SF.net SVN: housebot: [466] trunk/housebo=
t/src=0A=0A=0ARevision: 466=0A http://svn.sourceforge.net/housebot=
/?rev=3D466&view=3Drev=0AAuthor: j_house=0ADate: 2007-02-06 16:16:24 =
-0800 (Tue, 06 Feb 2007)=0A=0ALog Message:=0A-----------=0AA truly generic =
and functional GTP command registration=0ASadly, most uses are commented ou=
t right now :(=0AOn a positive note, they work if you uncomment them...=0A=
=0AModified Paths:=0A--------------=0A trunk/housebot/src/brains.cpp=0A =
trunk/housebot/src/gtp/GTPBoard.h=0A trunk/housebot/src/gtp/GTPFuncti=
onObject.h=0A trunk/housebot/src/housebot.cpp=0A=0AAdded Paths:=0A------=
-----=0A trunk/housebot/src/gtp/GTPFunctionObjectTemplate.hpp=0A=0AModif=
ied: trunk/housebot/src/brains.cpp=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=0A--- trunk/housebot/src/brains.cpp 2007-02-07 00:15:28 =
UTC (rev 465)=0A+++ trunk/housebot/src/brains.cpp 2007-02-07 00:16:24 UT=
C (rev 466)=0A@@ -580,14 +580,12 @@=0A=0Avoid =0Acollective::register_gtp(G=
TPBoard >p_engine){=0A-/// \bug since these command bypass the GoBoardInt=
erface and other data structures, like the GameTree, are not updated and ca=
uses the program to crash.=0A-=0A-// gtp_engine.RegisterCommand("boardsize=
", GTPCommandCallBack(new boost::function<void (int)> (boost::lambda::bi=
nd(boost::mem_fn(&collective::reinitialize), (collective*)this, boost::lamb=
da::_1))));=0A-// gtp_engine.RegisterCommand("clear_board", GTPCommandCall=
Back(new boost::function<void ()> (boost::lambda::bind(boost::mem_fn(&c=
ollective::clear), (collective*)this))));=0A-// gtp_engine.RegisterCommand=
("komi", GTPCommandCallBack(new boost::function<void (float)>(boost:=
:lambda::bind(boost::mem_fn(&collective::set_komi), (collective*)this, =
boost::lambda::_1))));=0A-// gtp_engine.RegisterCommand("undo", GTPCommand=
CallBack(new boost::function<void ()> (boost::lambda::bind(boost::mem_f=
n(&collective::undo), (collective*)this))));=0A- //gtp_engine.RegisterComm=
and("time_left", GTPCommandCallBack(new boost::function<void (color_t, in=
t, int)>(boost::lambda::bind(boost::mem_fn(&collective::time_left), (collec=
tive*)this, boost::lambda::_1, boost::lambda::_2, boost::lambda::_3))));=0A=
-=0A+ /// \bug since these command bypass the GoBoardInterface and other d=
ata structures, like the GameTree, are not updated and causes the program t=
o crash.=0A+// gtp_engine.RegisterCommand("boardsize", GTPCommandCallBac=
k1(new boost::function1<void, int> (boost::lambda::bind(boost::mem_fn(&col=
lective::reinitialize), (collective*)this, boost::lambda::_1))));=0A+// gt=
p_engine.RegisterCommand("clear_board", GTPCommandCallBack0(new boost::func=
tion0<void> (boost::lambda::bind(boost::mem_fn(&collective::clear), (=
collective*)this))));=0A+// gtp_engine.RegisterCommand("komi", GTPC=
ommandCallBack1(new boost::function1<void, float>(boost::lambda::bind(boost=
::mem_fn(&collective::set_komi), (collective*)this, boost::lambda::_1))=
));=0A+// gtp_engine.RegisterCommand("time_left", GTPCommandCallBack3(ne=
w boost::function3<void, color_t, int, int>(boost::lambda::bind(boost::mem_=
fn(&collective::time_left), (collective*)this, boost::lambda::_1, boost::la=
mbda::_2, boost::lambda::_3))));=0A+// gtp_engine.RegisterCommand("undo", =
GTPCommandCallBack0(new boost::function0<void> (boost::lambda:=
:bind(boost::mem_fn(&collective::undo), (collective*)this))));=0A}=0A=0Aboo=
l=0A=0AModified: trunk/housebot/src/gtp/GTPBoard.h=0A=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A--- trunk/housebot/src/gtp/GTPBoard.h 2=
007-02-07 00:15:28 UTC (rev 465)=0A+++ trunk/housebot/src/gtp/GTPBoard.h =
2007-02-07 00:16:24 UTC (rev 466)=0A@@ -140,7 +140,7 @@=0A// RegisterCo=
mmand("known_command", >PBoard::GTPKnownComand);=0A RegisterCommand("=
list_commands", GTPListCommands);=0A RegisterCommand("cputime", >PCPU=
Time);=0A- RegisterCommand("echo", GTPCommandCallBack(GTPBoard::GTPEcho)=
);=0A+ RegisterCommand("echo", GTPCommandCallBack1(new boost::function1<=
std::string, std::string>(GTPBoard::GTPEcho)));=0A RegisterCommand("qu=
it", >PBoard::GTPQuit);=0A RegisterCommand("timer_start", >PTimerSt=
art);=0A RegisterCommand("timer_now", >PTimerNow);=0A=0AModified: tru=
nk/housebot/src/gtp/GTPFunctionObject.h=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=0A--- trunk/housebot/src/gtp/GTPFunctionObject.h 2007=
-02-07 00:15:28 UTC (rev 465)=0A+++ trunk/housebot/src/gtp/GTPFunctionObjec=
t.h 2007-02-07 00:16:24 UTC (rev 466)=0A@@ -4,20 +4,27 @@=0A#include "GT=
PInternalResponse.h"=0A#include "GTPCommand.h"=0A=0A+/// \bug This should b=
e made indpendent of the housebot core=0A+#include "go_board.hpp" // for co=
lor_t=0A+=0A#include <boost/function.hpp>=0A#include <boost/lambda/bind.hpp=
>=0A#include <assert.h>=0A#include <list>=0A=0A+#include <boost/static_asse=
rt.hpp>=0A+#include <boost/preprocessor/enum_params.hpp> =
// expands for 0 ... N-1=0A+#include <boost/preprocessor/repetition/enum_=
shifted_params.hpp> // expands for 1 ... N-1=0A+=0Atypedef boost::function=
<GTPInternalResponse (GTPCommand)> GTPFunctionObject;=0A=0Anamespace gtp_de=
tail{=0A-=0A /// \bug Not very general purpose at this time=0A /// \bug=
Having to declare this inline is an anti-ld-error feature...=0A template=
<typename inputType, typename outputType> inline=0A outputType converter(=
inputType x){=0A outputType y =3D (outputType) x;=0A+ //BOOST_STATIC=
_ASSERT(false);=0A return y;=0A }=0A =0A@@ -51,6 +58,15 @@=0A r=
eturn x.GetAsFloat();=0A }=0A=0A+ template<> inline=0A+ color_t convert=
er(SmartString &x){=0A+ if (x=3D=3D"black" || x=3D=3D"Black" || x=3D=3D"=
BLACK")=0A+ return black;=0A+ if (x=3D=3D"white" || x=3D=3D"White" =
|| x=3D=3D"WHITE")=0A+ return white;=0A+ assert(false);=0A+ }=0A+=
=0A template<typename inputType> inline=0A inputType extract(GTPCommand=
&x, unsigned int &position){=0A SmartString arg =3D x.GetArgument(posi=
tion++);=0A@@ -67,122 +83,22 @@=0A return return_val;=0A }=0A=0A- te=
mplate <typename inputType, typename outputType> inline=0A- GTPInternalRes=
ponse type_wrapper(boost::function<outputType (inputType)> *callback_functi=
on, GTPCommand cmd){=0A- unsigned int position =3D 0;=0A- inputType a=
rg =3D extract<inputType>(cmd, position);=0A- assert(position =3D=3D cmd=
.GetArgumentCount());=0A- return converter<outputType, GTPInternalRespon=
se>( (*callback_function)(arg) );=0A- }=0A-=0A- // If there's no input ar=
gument, special handling is required=0A- template<typename outputType> inl=
ine =0A- GTPInternalResponse type_wrapper(boost::function<outputType (void=
)> *callback_function, GTPCommand cmd){=0A- assert(cmd.GetArgumentCount(=
)=3D=3D0);=0A- return converter<outputType, GTPInternalResponse>( (*call=
back_function)() );=0A- }=0A-=0A- // If there's no output argument, speci=
al handling is required=0A- template<typename inputType> inline=0A- GTPIn=
ternalResponse type_wrapper(boost::function<void (inputType)> *callback_fun=
ction, GTPCommand cmd){=0A- unsigned int position =3D 0;=0A- inputTyp=
e arg =3D extract<inputType>(cmd, position);=0A- assert(position =3D=3D =
cmd.GetArgumentCount());=0A- (*callback_function)(arg);=0A- return GT=
PInternalResponse(true, "");=0A- }=0A-=0A- // If neither... you get the i=
dea...=0A- template<> inline=0A- GTPInternalResponse type_wrapper(boost::=
function<void ()> *callback_function, GTPCommand cmd){=0A- assert(cmd.Ge=
tArgumentCount() =3D=3D 0);=0A- (*callback_function)();=0A- return GT=
PInternalResponse(true, "");=0A- }=0A- /*=0A- template<typename inputTyp=
e1, typename inputType2, typename outputType> inline=0A- GTPInternalRespon=
se type_wrapper(boost::function<outputType (inputType1, inputType2)> *callb=
ack_function, GTPCommand cmd){=0A- unsigned int position =3D 0;=0A- a=
ssert (position < cmd.GetArgumentCount());=0A- inputType1 arg1 =3D extra=
ct<inputType1>(cmd, position);=0A- assert(position < cmd.GetArgumentCoun=
t());=0A- inputType2 arg2 =3D extract<inputType2>(cmd, position);=0A- =
assert(position =3D=3D cmd.GetArgumentCount());=0A- return converter<ou=
tputType, GTPInternalResponse>( (*callback_function)(arg1, arg2) );=0A- }=
=0A-=0A- template<typename inputType1, typename inputType2> inline=0A- GT=
PInternalResponse type_wrapper(boost::function<void (inputType1, inputType2=
)> *callback_function, GTPCommand cmd){=0A- unsigned int position =3D 0;=
=0A- assert (position < cmd.GetArgumentCount());=0A- inputType1 arg1 =
=3D extract<inputType1>(cmd, position);=0A- assert(position < cmd.GetArg=
umentCount());=0A- inputType2 arg2 =3D extract<inputType2>(cmd, position=
);=0A- assert(position =3D=3D cmd.GetArgumentCount());=0A- (*callback=
_function)(arg1,arg2);=0A- return GTPInternalResponse (true, "");=0A- }=
=0A- */=0A-=0A};=0A=0A-template <typename inputType, typename outputType> =
inline=0A-GTPFunctionObject* GTPCommandCallBack(boost::function<outputType =
(inputType)> *callback_function){=0A- GTPInternalResponse (*type_wrapper)(=
boost::function<outputType (inputType)>*, GTPCommand) =3D gtp_detail::type_=
wrapper<inputType,outputType>;=0A- return new GTPFunctionObject(boost::lam=
bda::bind(type_wrapper, callback_function, boost::lambda::_1));=0A-}=0A+#de=
fine GTP_PARAM_COUNT 0=0A+#include "GTPFunctionObjectTemplate.hpp"=0A+#unde=
f GTP_PARAM_COUNT=0A=0A-template <typename inputType> inline=0A-GTPFunctio=
nObject* GTPCommandCallBack(boost::function<void (inputType)> *callback_fun=
ction){=0A- GTPInternalResponse (*type_wrapper)(boost::function<void (inpu=
tType)>*, GTPCommand) =3D gtp_detail::type_wrapper<inputType>;=0A- return =
new GTPFunctionObject(boost::lambda::bind(type_wrapper, callback_function, =
boost::lambda::_1));=0A-}=0A+#define GTP_PARAM_COUNT 1=0A+#include "GTPFunc=
tionObjectTemplate.hpp"=0A+#undef GTP_PARAM_COUNT=0A=0A-template <typename =
outputType> inline=0A-GTPFunctionObject* GTPCommandCallBack(boost::function=
<outputType ()> *callback_function){=0A- GTPInternalResponse (*type_wrappe=
r)(boost::function<outputType ()>*, GTPCommand) =3D gtp_detail::type_wrappe=
r<outputType>;=0A- return new GTPFunctionObject(boost::lambda::bind(type_w=
rapper, callback_function, boost::lambda::_1));=0A-}=0A+#define GTP_PARAM_C=
OUNT 2=0A+#include "GTPFunctionObjectTemplate.hpp"=0A+#undef GTP_PARAM_COUN=
T=0A=0A-template <typename inputType1, typename inputType2, typename output=
Type>=0A-GTPFunctionObject* GTPCommandCallBack(boost::function<outputType(i=
nputType1, inputType2)> *callback_function){=0A- GTPInternalResponse (*typ=
e_wrapper)(boost::function<outputType (inputType1,inputType2)>*, GTPCommand=
) =3D gtp_detail::type_wrapper<inputType1, inputType2, outputType>;=0A- re=
turn new GTPFunctionObject(boost::lambda::bind(type_wrapper, callback_funct=
ion, boost::lambda::_1));=0A-}=0A-/*=0A-template <typename inputType1, type=
name inputType2, typename inputType3, typename outputType>=0A-GTPFunctionOb=
ject* GTPCommandCallBack(boost::function<outputType(inputType1, inputType2,=
inputType3)> *callback_function){=0A- GTPInternalResponse (*type_wrapper)=
(boost::function<outputType (inputType1,inputType2,inputType3)>*, GTPComman=
d) =3D gtp_detail::type_wrapper<inputType1, inputType2, inputType3, outputT=
ype>;=0A- return new GTPFunctionObject(boost::lambda::bind(type_wrapper, c=
allback_function, boost::lambda::_1));=0A-}=0A+#define GTP_PARAM_COUNT 3=0A=
+#include "GTPFunctionObjectTemplate.hpp"=0A+#undef GTP_PARAM_COUNT=0A=0A-t=
emplate <typename inputType1, typename inputType2, typename inputType3>=0A-=
GTPFunctionObject* GTPCommandCallBack(boost::function<void (inputType1, inp=
utType2, inputType3)> *callback_function){=0A- GTPInternalResponse (*type_=
wrapper)(boost::function<void (inputType1,inputType2,inputType3)>*, GTPComm=
and) =3D gtp_detail::type_wrapper<inputType1, inputType2, inputType3>;=0A- =
return new GTPFunctionObject(boost::lambda::bind(type_wrapper, callback_fu=
nction, boost::lambda::_1));=0A-}=0A-*/=0A-=0A-////////////////////////=0A-=
=0A-template <typename inputType, typename outputType> inline=0A-GTPFunctio=
nObject* GTPCommandCallBack(outputType (*callback_function)(inputType)){=0A=
- return GTPCommandCallBack(new boost::function<outputType (inputType)>(ca=
llback_function));=0A-}=0A-=0A-template <typename inputType> inline=0A-GTPF=
unctionObject* GTPCommandCallBAck(void (*callback_function)(inputType)){=0A=
- return GTPCommandCallBack(new boost::function<void (inputType)>(callback=
_function));=0A-}=0A-=0A-template <typename outputType> inline=0A-GTPFuncti=
onObject* GTPCommandCallBack(outputType (*callback_function)()){=0A- retur=
n GTPCommandCallBack(new boost::function<outputType ()>(callback_function))=
;=0A-}=0A-=0A-template <typename inputType1, typename inputType2, typename =
outputType>=0A-GTPFunctionObject* GTPCommandCallBack(outputType(*callback_f=
unction)(inputType1, inputType2)){=0A- return GTPCommandCallBack(new boost=
::function<outputType (inputType1, inputType2)>(callback_function));=0A-}=
=0A-=0A#endif=0A=0AAdded: trunk/housebot/src/gtp/GTPFunctionObjectTemplate.=
hpp=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A--- trunk/house=
bot/src/gtp/GTPFunctionObjectTemplate.hpp (rev 0=
)=0A+++ trunk/housebot/src/gtp/GTPFunctionObjectTemplate.hpp 2007-02-07 =
00:16:24 UTC (rev 466)=0A@@ -0,0 +1,113 @@=0A+#if GTP_PARAM_COUNT =3D=3D 0=
=0A+# define GTP_OPTIONAL_COMMA=0A+#else=0A+# define GTP_OPTIONAL_COMMA ,=
=0A+#endif=0A+=0A+=0A+// GTP_PARMS expands to " typename T0, typename T1, t=
ypename T2" if GTP_PARAM_COUNT is 3=0A+#define GTP_TEMPLATE_PARAMS BOOST_PP=
_ENUM_PARAMS(GTP_PARAM_COUNT, typename T)=0A+=0A+// expands to "typename R0=
, typename T0, typename T1, typename T2" if GTP_PARAM_COUNT is 3=0A+#defin=
e GTP_FULL_TEMPLATE_PARAMS typename R0 GTP_OPTIONAL_COMMA GTP_TEMPLATE_PARA=
MS=0A+=0A+// GTP_PARAM expands to " T3 a3" if INDEX is 3=0A+#define GTP_PAR=
AM(UNKNOWN1,INDEX,UNKNOWN2) BOOST_PP_CAT(T,I) BOOST_PP_CAT(a,I)=0A+=0A+// G=
TP_PARAMS expands to " T0 a0, T1 a1, T2 a2" if GTP_PARAM_COUNT is 3=0A+#def=
ine GTP_PARAMS BOOST_PP_ENUM(GTP_PARAM_COUNT,GTP_PARAM,BOOST_PP_EMPTY)=0A+=
=0A+// GTP_PARAM_TYPES expands to " T0, T1, T2" if GTP_PARAM_COUNT is 3=0A+=
#define GTP_PARAM_TYPES BOOST_PP_ENUM_PARAMS(GTP_PARAM_COUNT, T)=0A+=0A+// =
expands to "R0 , T0, T1, T2" if GTP_PARAM_COUNT is 3=0A+#define GTP_FULL_PA=
RAM_TYPES R0 GTP_OPTIONAL_COMMA GTP_PARAM_TYPES=0A+=0A+// GTP_PARAM_NAMES e=
xpands to " a0, a1, a2" if GTP_PARAM_COUNT is 3=0A+#define GTP_PARAM_NAMES =
BOOST_PP_ENUM_PARAMS(GTP_PARAM_COUNT, a)=0A+=0A+// expands to "boost::funct=
ion3 < R0 , T0, T1, T2 >" when GTP_PARAM_COUNT is 3=0A+#define GTP_BOOST_F=
UNCTION BOOST_PP_CAT(boost::function,GTP_PARAM_COUNT) < GTP_FULL_PARAM_TYPE=
S >=0A+=0A+// expands to "boost::function3 < void , T0, T1, T2 >" when GTP=
_PARAM_COUNT is 3=0A+#define GTP_BOOST_FUNCTION_VOID BOOST_PP_CAT(boost::fu=
nction,GTP_PARAM_COUNT) < void GTP_OPTIONAL_COMMA GTP_PARAM_TYPES >=0A+=0A+=
// expands to type_wrapper3 when GTP_PARAM_COUNT is 3=0A+#define GTP_TYPE_W=
RAPPER BOOST_PP_CAT(type_wrapper,GTP_PARAM_COUNT)=0A+=0A+//////////////////=
////////////////////////////////////////////=0A+// gtp_detail::type_wrapper=
for converting all input arguments=0A+namespace gtp_detail{=0A+=0A+ templ=
ate < GTP_FULL_TEMPLATE_PARAMS >=0A+ struct GTP_TYPE_WRAPPER{=0A+ stati=
c GTPInternalResponse wrap(GTP_BOOST_FUNCTION *(callback_function), GTPComm=
and cmd){=0A+ unsigned int position =3D 0;=0A+ /// \bug Must figu=
re out how to auto generate this repetative body=0A+#if GTP_PARAM_COUNT >=
=3D 1=0A+ assert(position < cmd.GetArgumentCount());=0A+ T0 a0 =
=3D extract<T0>(cmd, position);=0A+#endif=0A+#if GTP_PARAM_COUNT >=3D 2=0A+=
assert(position < cmd.GetArgumentCount());=0A+ T1 a1 =3D extract=
<T1>(cmd,position);=0A+#endif=0A+#if GTP_PARAM_COUNT >=3D 3=0A+ assert=
(position < cmd.GetArgumentCount());=0A+ T2 a2 =3D extract<T2>(cmd,pos=
ition);=0A+#endif=0A+ assert(position =3D=3D cmd.GetArgumentCount());=
=0A+ return converter<R0, GTPInternalResponse>( (*callback_function)(G=
TP_PARAM_NAMES) );=0A+ }=0A+ };=0A+=0A+ template < GTP_TEMPLATE_PARAMS=
>=0A+ struct GTP_TYPE_WRAPPER < void GTP_OPTIONAL_COMMA GTP_PARAM_TYPES >=
{=0A+ static GTPInternalResponse wrap(GTP_BOOST_FUNCTION_VOID *(callback=
_function), GTPCommand cmd){=0A+ unsigned int position =3D 0;=0A+ =
/// \bug Must figure out how to auto generate this repetative body=0A+#if =
GTP_PARAM_COUNT >=3D 1=0A+ assert(position < cmd.GetArgumentCount());=
=0A+ T0 a0 =3D extract<T0>(cmd, position);=0A+#endif=0A+#if GTP_PARAM_=
COUNT >=3D 2=0A+ assert(position < cmd.GetArgumentCount());=0A+ T=
1 a1 =3D extract<T1>(cmd,position);=0A+#endif=0A+#if GTP_PARAM_COUNT >=3D 3=
=0A+ assert(position < cmd.GetArgumentCount());=0A+ T2 a2 =3D ext=
ract<T2>(cmd,position);=0A+#endif=0A+ assert(position =3D=3D cmd.GetAr=
gumentCount());=0A+ (*callback_function)(GTP_PARAM_NAMES);=0A+ re=
turn GTPInternalResponse();=0A+ }=0A+ };=0A+=0A+};=0A+=0A+/////////////=
//////////////////////////////////////////=0A+// GTPCommandCallBack accepti=
ng a boost function object=0A+=0A+// expands to GTPFunctionObject3 when GTP=
_PARAM_COUNT is 3=0A+#define GTP_COMMAND_CALLBACK BOOST_PP_CAT(GTPCommandCa=
llBack,GTP_PARAM_COUNT)=0A+=0A+template< GTP_FULL_TEMPLATE_PARAMS > inline=
=0A+GTPFunctionObject* GTP_COMMAND_CALLBACK(GTP_BOOST_FUNCTION *callback_fu=
nction){=0A+ return new GTPFunctionObject(boost::lambda::bind((>p_detail=
::GTP_TYPE_WRAPPER<GTP_FULL_PARAM_TYPES>::wrap), callback_function, boost::=
lambda::_1));=0A+}=0A+=0A+/////////////////////////////////////////////////=
//////=0A+// Cleanup=0A+=0A+#undef GTP_OPTIONAL_COMMA=0A+#undef GTP_TEMPLAT=
E_PARAMS=0A+#undef GTP_FULL_TEMPLATE_PARAMS=0A+#undef GTP_PARAM=0A+#undef G=
TP_PARAMS=0A+#undef GTP_PARAM_TYPES=0A+#undef GTP_PARAM_NAMES=0A+#undef GTP=
_BOOST_FUNCTION=0A+#undef GTP_BOOST_FUNCTION_VOID=0A+#undef GTP_TYPE_WRAPPE=
R=0A+#undef GTP_COMMAND_CALLBACK=0A=0AModified: trunk/housebot/src/housebot=
.cpp=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A--- trunk/ho=
usebot/src/housebot.cpp 2007-02-07 00:15:28 UTC (rev 465)=0A+++ trunk/ho=
usebot/src/housebot.cpp 2007-02-07 00:16:24 UTC (rev 466)=0A@@ -83,10 +8=
3,10 @@=0A=0A the_collective.register_gtp(lGTPGoBoard);=0A=0A- lGTPGoBoa=
rd.RegisterCommand("name", GTPCommandCallBack(name));=0A- lGTPGoB=
oard.RegisterCommand("version", GTPCommandCallBack(version));=0A- lG=
TPGoBoard.RegisterCommand("kgs-game_over", GTPCommandCallBack(consider_shut=
down));=0A- lGTPGoBoard.RegisterCommand("kgs-chat", GTPCommandCallBac=
k(chat));=0A+ lGTPGoBoard.RegisterCommand("name", GTPCommandCallB=
ack0(new boost::function0<std::string>(name)));=0A+ lGTPGoBoard.RegisterCo=
mmand("version", GTPCommandCallBack0(new boost::function0<std::string=
>(version)));=0A+ lGTPGoBoard.RegisterCommand("kgs-game_over", GTPCommandC=
allBack0(new boost::function0<void>(consider_shutdown)));=0A+ lGTPGoBoard.=
RegisterCommand("kgs-chat", GTPCommandCallBack1(new boost::function1<s=
td::string,std::list<std::string> >(chat)));=0A=0A GTPCommStream lComm(&s=
td::cin,&std::cout);=0A GTPEngine lGTPEngine(lGTPGoBoard, lComm);=0A=0A=
=0AThis was sent by the SourceForge.net collaborative development platform,=
the world's largest Open Source development site.=0A=0A-------------------=
------------------------------------------------------=0AUsing Tomcat but n=
eed to do more? Need to support web services, security?=0AGet stuff done qu=
ickly with pre-integrated technology to make your job easier.=0ADownload IB=
M WebSphere Application Server v.1.0.1 based on Apache Geronimo=0Ahttp://se=
l.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642=0A_=
______________________________________________=0AHousebot-developers mailin=
g lis...@li...=0Ahttps://lists.sourcefo=
rge.net/lists/listinfo/housebot-developers |