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

📄 x1520.html

📁 set for Swarm2.1是圣菲研究院的开发人员对Swarm的特性及其使用描述的最为完备的指南性文档。从这里可以获得最细致的平台说明。
💻 HTML
字号:
<HTML><HEAD><TITLE>Porting from 1.1 to 1.2</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.53"><LINKREL="HOME"TITLE="Documentation Set for Swarm 2.1.1"HREF="set.html"><LINKREL="UP"TITLE="Swarm Changes and Compatibility"HREF="swarm.compatibility.sgml.preface.html"><LINKREL="PREVIOUS"TITLE="Porting from 1.2 to 1.3"HREF="x1509.html"><LINKREL="NEXT"TITLE="Porting from 1.0.5 to 1.1"HREF="x1613.html"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Documentation Set for Swarm 2.1.1</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="x1509.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Swarm Changes and Compatibility</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="x1613.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="AEN1520">5. Porting from 1.1 to 1.2</A></H1><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN1522">5.1. Major changes</A></H2><P>There are really only two main changes which are likely to        affect existing users, and all other changes required in        user's applications mostly flow from these two changes:      </P><P></P><UL><LI><P>All Swarm functionality is now exported through a            single, well-defined interface: Objective C protocols.            Essentially this means that all creatable or subclass-able            protocols now follow the same conventions as those in the            defobj, activity and collections libraries.  This means            that static typing of Swarm protocols is now obsolete            across the whole package.</P></LI><LI><P>Library header files no longer include any of their            individual class header files.</P></LI><LI><P>The <TTCLASS="CLASSNAME">XPixmap</TT> protocol has now            been changed to <TTCLASS="CLASSNAME">Pixmap</TT> to divorce            itself from it's association with            X-Windows.</P></LI></UL></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN1534">5.2. Porting Guide</A></H2><P></P><UL><LI><P>Any subclass of a class defined as a Swarm          protocol now requires the *specific* importation of that          protocol's header file.  Previously, only a warning was          raised.  This particularly affects          <TTCLASS="CLASSNAME">Swarm</TT> and          <TTCLASS="CLASSNAME">SwarmObject</TT>.  If you define something          like:<TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">  @interface MyObject: SwarmObject</PRE></TD></TR></TABLE>  then you need to include:<TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">  #import &lt;objectbase/SwarmObject.h&gt;</PRE></TD></TR></TABLE>           Similarly, if you subclass from Swarm, you will require            <TTCLASS="FILENAME">objectbase/Swarm.h</TT> </P></LI><LI><P>All references to objects conforming to Swarm          protocols should either be defined to conform to the          appropriate Swarm protocol, or be left untyped.  In no          circumstance should it be statically typed.  In practice,          this means that you can write, either:<TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">    id &lt;Grid2d&gt; world;  OR   id world;</PRE></TD></TR></TABLE>    but NOT<TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   Grid2d *world;</PRE></TD></TR></TABLE>             Note that this only applies to protocols defined by Swarm            proper, not to your own classes, although it is good            practice to adopt a convention and stick to it.          </P></LI></UL></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN1548">5.3. Porting example:      <SPANCLASS="APPLICATION">heatbugs</SPAN></A></H2><P><TTCLASS="FILENAME">HeatSpace.h</TT></P><P></P><UL><LI><P>Include header file for          <TTCLASS="LITERAL">space/Diffuse2d</TT> (x)</P></LI></UL><P><TTCLASS="FILENAME">Heatbug.h</TT></P><P></P><UL><LI><P>Make instance variable world conform to protocol:              <TTCLASS="LITERAL">id &lt;Grid2d&gt; world</TT> NOT              <TTCLASS="LITERAL">id Grid2d *;</TT> (x)</P></LI></UL><P><TTCLASS="FILENAME">Heatbug.m</TT></P><P></P><UL><LI><P>In <TTCLASS="LITERAL">[Heatbug -setWorld:]</TT> method:          make cast to protocol not static (x)</P></LI></UL><P><TTCLASS="FILENAME">HeatbugModelSwarm.h</TT></P><P></P><UL><LI><P>HeatbugObserverSwarm.h</P><P></P><UL><LI><P>Make instance variable <TTCLASS="LITERAL">id &lt;Grid2d&gt;                  world</TT> NOT <TTCLASS="LITERAL">Grid2d *world</TT> (x)</P></LI><LI><P>Change static cast of <TTCLASS="LITERAL">[HeatbugObserverSwarm                  -getWorld:]</TT> method to protocol version (x)</P></LI><LI><P>Change all the below to conform to their respective                protocols (x)                                <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">                  EZGraph *unhappyGraph;                  Value2dDisplay *heatDisplay;                  Object2dDisplay *heatbugDisplay;                </PRE></TD></TR></TABLE>              </P></LI></UL></LI></UL></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN1586">5.4. Porting example: <SPANCLASS="APPLICATION">mousetrap</SPAN></A></H2><P><TTCLASS="FILENAME">MousetrapModelSwarm.h</TT></P><P></P><UL><LI><P>Import <TTCLASS="LITERAL">&lt;objectbase/Swarm.h&gt;</TT>          for subclassing from Swarm (*)</P></LI><LI><P>Remove imports of <TTCLASS="LITERAL">&lt;activity.h&gt;            &lt;collections.h&gt; &lt;simtools.h&gt;            &lt;objectbase.h&gt;</TT> irrelevant, as not used in            the interface. (x)</P></LI><LI><P>Make instance of <TTCLASS="LITERAL">Grid2d</TT> conform to          protocol, not static typed. (x)</P></LI></UL><P><TTCLASS="FILENAME">MousetrapObserverSwarm.h</TT></P><P></P><UL><LI><P>Make instances of <TTCLASS="LITERAL">EZGraph,            Object2dDisplay</TT> conform to protocol, rather than            be statically typed. (x)          </P></LI></UL><P><TTCLASS="FILENAME">Mousetrap.h</TT></P><P></P><UL><LI><P>Remove import of          <TTCLASS="LITERAL">&lt;objectbase.h&gt;</TT> (x)</P></LI></UL></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="x1509.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="set.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="x1613.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Porting from 1.2 to 1.3</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="swarm.compatibility.sgml.preface.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Porting from 1.0.5 to 1.1</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

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