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

📄 node28.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.8 Class InstVar</TITLE><META NAME="description" CONTENT="3.8 Class InstVar"><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="previous" HREF="node27.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node27.html"><LINK REL="up" HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html"><LINK REL="next" HREF="node29.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node29.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html1547"  HREF="node29.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node29.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html1541"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html1537"  HREF="node27.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node27.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html1543"  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="tex2html1545"  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="tex2html1548"  HREF="node29.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node29.html">2 Simulator Basics</A><B> Up:</B> <A NAME="tex2html1542"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html">3. OTcl Linkage</A><B> Previous:</B> <A NAME="tex2html1538"  HREF="node27.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node27.html">3.7 Class EmbeddedTcl</A> &nbsp <B>  <A NAME="tex2html1544"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html1546"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H1><A NAME="SECTION02180000000000000000"></A><A NAME="sec:InstVar"></A><BR>3.8 Class InstVar</H1><P>This section describes the internals of the InstVar../Tcl/Tcl.cc.This class defines the methods and mechanisms to binda C++ member variable in the compiled shadow objectto a specified OTcl instance variable in the equivalent interpreted object.The binding is set up such that the value of the variable can beset or accessed either from within the interpreter, or fromwithin the compiled code at all times.<P>There are five instance variable classes:InstVarReal../Tcl/Tcl.cc,InstVarTime../Tcl/Tcl.cc,InstVarBandwidth../Tcl/Tcl.cc,InstVarInt../Tcl/Tcl.cc,and InstVarBool../Tcl/Tcl.cc,corresponding to bindings for real, time, bandwidth, integer, andboolean valued variables respectively.<P>We now describe the mechanism by which instance variables are set up.We use the InstVarReal../Tcl/Tcl.ccto illustrate the concept.However, this mechanism is applicable to all five types of instance variables.<P>When setting up an interpreted variable to access a member variable,the member functions of the class InstVar assume that they are executingin the appropriate method execution context;therefore, they do not query the interpreter to determine the context inwhich this variable must exist.<P>In order to guarantee the correct method execution context,a variable must only be bound if its class is already established withinthe interpreter, andthe interpreter is currently operating on an object in that class.Note that the former requires that when a method in a given class isgoing to make its variables accessible via the interpreter,there must be an associated class TclClassSectionsec:TclClassdefined that identifies the appropriate class hierarchy to the interpreter.The appropriate method execution context can therefore be created in oneof two ways.<P>An implicit solution occurs whenever a new TclObject is created withinthe interpreter.This sets up the method execution context within the interpreter.When the compiled shadow object of the interpreted TclObject is created,the constructor for that compiled object can bind its member variablesof that objectto interpreted instance variables in the context of the newly createdinterpreted object.<P>An explicit solution is to define a <TT>bind-variables</TT> operationwithin a <TT>command</TT> function, that can then be invoked via the<TT>cmd</TT> method.The correct method execution context is established in order to executethe <TT>cmd</TT> method.Likewise, the compiled code is now operating on the appropriateshadow object, and can therefore safely bind the required member variables.<P>An instance variable is created by specifying the name of theinterpreted variable, and the address of the member variable in thecompiled object.Theconstructor../Tcl/Tcl.ccInstVar::InstVarfor the base class InstVar creates an instance of the variable in the interpreter,and then sets up atrap routine../Tcl/Tcl.ccInstVar::catch_varto  catch all accesses to the variable through the interpreter.<P>Whenever the variable is read through the interpreter, thetrap routine../Tcl/Tcl.ccInstVar::catch_readis invoked just prior to the occurrence of the read.The routine invokes the appropriateget function../Tcl/Tcl.ccInstVarReal::getthat returns the current value of the variable.This value is then used to set the value of the interpreted variablethat is then read by the interpreter.<P>Likewise,whenever the variable is set through the interpreter, thetrap routine../Tcl/Tcl.ccInstVar::catch_writeis invoked just after to the write is completed.The routine gets the current value set by the interpreter, and invokes the appropriateset function../Tcl/Tcl.ccInstVarReal::setthat sets the value of the compiled member to the current value setwithin the interpreter.<P><HR><!--Navigation Panel--><A NAME="tex2html1547"  HREF="node29.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node29.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html1541"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html1537"  HREF="node27.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node27.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html1543"  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="tex2html1545"  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="tex2html1548"  HREF="node29.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node29.html">2 Simulator Basics</A><B> Up:</B> <A NAME="tex2html1542"  HREF="node5.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node5.html">3. OTcl Linkage</A><B> Previous:</B> <A NAME="tex2html1538"  HREF="node27.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node27.html">3.7 Class EmbeddedTcl</A> &nbsp <B>  <A NAME="tex2html1544"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html1546"  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 + -