>
> hello...
>
>      can ne explain me abt this code.... ns2/routing/route.cc i mean how
> these argc==2? and argv[1], compute is compared? how it works?
> int RouteLogic::command(int argc, const char*const* argv)
> {
>     Tcl& tcl = Tcl::instance();
>     if (argc == 2) {
>         if (strcmp(argv[1], "compute") == 0) {
>             if (adj_ == 0)
>                 return (TCL_OK);
>             compute_routes();
>             return (TCL_OK);
>

The first argument ( = arg[0]) for the binding the TCL commands is
prepared in the class "RouteLogicClass"

[quote]
class RouteLogicClass : public TclClass {
public:
        RouteLogicClass() : TclClass("RouteLogic") {}
        TclObject* create(int, const char*const*) {
                return (new RouteLogic());
        }
} routelogic_class;
[/quote]

argc is the number of arguments delivered from the TCL-script



> and also how cost is calculated using argc and argv[]?
> ...
>            * double cost = (argc == 5 ? atof(argv[4]) : 1);*
>             insert(src, dst, cost);
> ...

this is a short version of "if-then-else"-syntax

if (argc == 5) { double cost = atof(argv[4] } else { double cost = 1}


Reply via email to