First Class Interface:
The statement in Tcl:
Set Chan ($j) [New Wimshchannel]
C + + corresponding statement:
1. Define Wimshchannel Class
Class Wimshchannel:public Tclobject {};
2. Do the two-layer interface
Static class Wimshchannelclass:public Tclclass {
Public
Wimshchannelclass (): Tclclass ("Wimshchannel") {}
tclobject* Create (int, const char*const*) {
Return (new Wimshchannel);
}
} Class_wimsh_channel;
Type II Interface:
The statement in Tcl:
$chan ($j) Topology $topo
The corresponding statement in 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;
}
Type III Interface:
TCL in the corresponding statement:
mac/802_11e Set Basicrate_ 1Mb
The corresponding statement in 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_;