[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: basic question(emergency)
I do notice in the error message, the command was "new Tsw", while in your
Otcl linkage the difinition was "TclClass("TSW")". Others look fine for
me.
--Zhenhai
On Tue, 17 Aug 1999, richard wrote:
> May I ask a basic question?
>
> How to add a new class object(no matter C++ fomat or Tcl format)
>
> The following is my adding steps.
>
> (1). the creation of C++ class:
>
> I edit a tsw.cc and tsw.h , add "tsw.o" to Makefile, and compiled ok.
>
> ------------------------------------------------------------------------------------
>
> static class TSWClass : public TclClass {
> public:
> TSWClass() : TclClass("TSW") {}
> TclObject* create(int, const char*const*) {
> return (new TSW());
> }
> }class_TSW;
> (in tsw.cc)
>
> ------------------------------------------------------------------------------------
>
>
>
> class TSW : public Connector {
> public:
> TSW();
> int command(int argc, const char*const* argv);
> protected:
> :
> :
> }
> (in tsw.h)
> ------------------------------------------------------------------------------------
>
>
>
> (2). used by Tcl scripts:
>
> I edit a tcl script include create this object ( "set tsw_ [new TSW]" in
> rr.tcl).
>
> (3). error
> ns return the error message of tcl script(rr.tcl)
>
> ------------------------------------------------------------------------------------
>
> [~/ns2/ns-2/tcl/test#]ns rr.tcl
> invalid command name "Tsw"
> while executing
> "Tsw create _o72 "
> invoked from within
> "catch "$className create $o $args" msg"
> (procedure "new" line 3)
> invoked from within
> "new Tsw"
> (procedure "_o3" line 9)
> (Simulator duplex-rio_tsw-link line 9)
> invoked from within
> "$ns duplex-rio_tsw-link $n(2) $n(3) 5Mb 2ms"
> (file "rr.tcl" line 44)
> [~/ns2/ns-2/tcl/test#]
> ------------------------------------------------------------------------------------
>
> It cannot find the new object.I think there should be some other steps
> beteen (1) and (2).
>
> Whould you please tell me the correct adding steps.
>
> Thanks a lot.
>
> ps: I have already read the Greis's tutorial and ns documentation
> chapter 8.
> They are talking about Agent and Packet adding and I have imitated their
> adding
> steps .It still does not work.
>
>
>
>
>
>