[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can I add a new C++ class in ns?(from Taiwan)






subscribe ns-users


I try to add a C++ class in ns,and I edit a tsw.cc and tsw.h .
After add this files,I add "tsw.o" in the Makefile.
Finally,it is compiled ok.

-------------------------------------------------------------------------

the c++ file include:
static class TSWClass : public TclClass {
public:
        TSWClass() : TclClass("TSW") {}
        TclObject* create(int, const char*const*) {
                return (new TSW());
        }
} class_tsw;
                        :
                        :
------------------------------------------------------------------------

the .h file include:
class TSW : public Connector {
public:
        TSW();
        int command(int argc, const char*const* argv);
protected:
        double prob;
        double win_length ;
                        :
                        :
---------------------------------------------------------------------
When I edit a tcl script file to test the object:
    :
    :
set tsw_[new  TSW]
    :
-----------------------------------------------------------------------
ns response:
invalid command name "TSW"
    while executing

I have read examples of adding agent ,packet class in
Marc Greis's tutorial and ns documentation chapt.8,but
I still can not find the problem.

Please tell me  the correct way to adding.

Thanks a lot.

                                                        Richard Liu