⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node19.html

📁 相关搜索: ns2仿真结果分析 all-awk ns2 ns2 无限网络中awk文件 ... [2.tcl.rar] - 在ns2平台上实现对AODV协议的模拟
💻 HTML
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><!--Converted with jLaTeX2HTML 2002 (1.62) JA patch-1.4patched version by:  Kenshi Muto, Debian Project.LaTeX2HTML 2002 (1.62),original version by:  Nikos Drakos, CBLU, University of Leeds* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from:  Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>3.4.1.0.1 Creating TclObjects</TITLE><META NAME="description" CONTENT="3.4.1.0.1 Creating TclObjects"><META NAME="keywords" CONTENT="everything"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="jLaTeX2HTML v2002 JA patch-1.4"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="everything.css" tppabs="http://www.isi.edu/nsnam/ns/doc/everything.css"><LINK REL="next" HREF="node20.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node20.html"><LINK REL="previous" HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html"><LINK REL="up" HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html"><LINK REL="next" HREF="node20.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node20.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html1428"  HREF="node20.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node20.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html1422"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html1416"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html1424"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html1426"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html1429"  HREF="node20.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node20.html">3.4.1.0.2 Deletion of TclObjects</A><B> Up:</B> <A NAME="tex2html1423"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html">3.4.1 Creating and Destroying</A><B> Previous:</B> <A NAME="tex2html1417"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html">3.4.1 Creating and Destroying</A> &nbsp <B>  <A NAME="tex2html1425"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html1427"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H4><A NAME="SECTION02141010000000000000">3.4.1.0.1 Creating TclObjects</A></H4>By using []new, the user creates an interpreted TclObject.the interpreter will execute the constructor for that object, []init,passing it any arguments provided by the user. is responsible for automatically  creating the compiled object.The shadow object gets created by the base class TclObject's constructor.Therefore, the constructor for the new TclObjectmust call the parent class constructor first.[]new returns a handle to the object, that can then be usedfor further operations upon that object.<P>The following example illustrates the Agent/SRM/Adaptive constructor:<PRE>        Agent/SRM/Adaptive instproc init args {                eval \$self next \$args                \$self array set closest_ "requestor 0 repairor 0"                \$self set eps_    [\$class set eps_]        }</PRE><P>The following sequence of actions are performed by the interpreteras part of instantiating a new TclObject.For ease of exposition, we describe the steps that are executedto create an Agent/SRM/Adaptive object.The steps are:<OL><LI>Obtain an unique handle for the new object   from the TclObject name space.  The handle is returned to the user.  Most handles in  have the form <TT>_oNNN</TT>, where NNN  is an integer.  This handle is created by  getid../tclcl/tcl-object.tclTclObject::getid.  It can be retrieved from C++ with the  name()../tclcl/tclcl.hTclObject::name()  method.</LI><LI>Execute the constructor for the new object.  Any user-specified arguments are passed as arguments to the constructor.  This constructor must invoke the constructor  associated with its parent class.<P>In our example above, the Agent/SRM/Adaptive calls its parent class  in the very first line.  <P>Note that each constructor,  in turn invokes its parent class' constructor <I>ad nauseum</I>.  The last constructor in  is  the TclObject constructor../Tcl/tcl-object.tclTclObject::init.  This constructor is responsible for setting up the shadow object, and   performing other initializations and bindings, as we explain below.  <I>It is preferable to call the parent constructors first before    performing the initializations required in this class.</I>  This allows the shadow objects to be set up,  and the variable bindings established.</LI><LI>The TclObject constructor invokes the instance procedure  []create-shadow for the class Agent/SRM/Adaptive.</LI><LI>When the shadow object is created,   calls all of the constructors for the compiled object,  each of which may establish variable bindings for objects in that class,  and perform other necessary initializations.  Hence our earlier injunction that it is preferable to invoke the parent  constructors prior to performing the class initializations.</LI><LI>After the shadow object is successfully created,  create_shadow../Tcl/Tcl.ccTclClass::create_shadow  <OL><LI>adds the new object to hash table of TclObjects        described earlierSectionsec:HashTables.</LI><LI>makes []cmd an instance procedure of the newly created    interpreted object.    This instance procedure    invokes the []command method of the compiled object.    In a later subsectionSectionsec:Commands,    we describe how the <TT>command</TT> method is defined, and invoked.  </LI></OL></LI></OL>Note that all of the above shadowing mechanisms only work whenthe user creates a new TclObject through the interpreter.It will not work if the programmer creates a compiled TclObject unilaterally.Therefore, the programmer is enjoined not to use the C++ new methodto create compiled objects directly.<P><HR><!--Navigation Panel--><A NAME="tex2html1428"  HREF="node20.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node20.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html1422"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html1416"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html1424"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html1426"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html1429"  HREF="node20.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node20.html">3.4.1.0.2 Deletion of TclObjects</A><B> Up:</B> <A NAME="tex2html1423"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html">3.4.1 Creating and Destroying</A><B> Previous:</B> <A NAME="tex2html1417"  HREF="node18.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node18.html">3.4.1 Creating and Destroying</A> &nbsp <B>  <A NAME="tex2html1425"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html1427"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <!--End of Navigation Panel--><ADDRESS>2003-09-23</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -