你必须非常努力,才能看起来毫不费力!
分类: 系统运维
2008-12-15 18:49:37
第一类接口:
tcl中的语句:
set chan($j) [new WimshChannel]
c++对应的语句:
1.定义WimshChannel类
class WimshChannel : public TclObject {};
2.做好两层的接口
static class WimshChannelClass : public TclClass {
public:
WimshChannelClass() : TclClass("WimshChannel") {}
TclObject* create(int, const char*const*) {
return (new WimshChannel);
}
} class_wimsh_channel;
第二类接口:
tcl中的语句:
$chan($j) topology $topo
c++中对应的语句
int WimshChannel::command(int argc, const char*const* argv)
if ( argc == 3 && strcmp (argv[1], "topology") == 0 ) {
topology_ = (WimshTopologySimple*) TclObject::lookup(argv[2]);
return TCL_OK;
}
第三类接口:
tcl中的语句:
Mac/802_11e set basicRate_ 1Mb
c++中对应的语句:
Tcl& tcl = Tcl::instance();
tcl.evalf("Mac/802_11e set basicRate_");
if (strcmp(tcl.result(), "0") != 0)
bind_bw("basicRate_", &basicRate_);
else
basicRate_ = bandwidth_;