📄 x1613.html
字号:
<HTML><HEAD><TITLE>Porting from 1.0.5 to 1.1</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.1 to 1.2"HREF="x1520.html"><LINKREL="NEXT"TITLE="Porting from 1.0.4 to 1.0.5"HREF="x1797.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="x1520.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Swarm Changes and Compatibility</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="x1797.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="AEN1613">6. Porting from 1.0.5 to 1.1</A></H1><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN1615">6.1. Major changes</A></H2><P> The major changes which are likely to affect existing users are the following:</P><P></P><UL><LI><P>Addition of a new library class "gui" which replaces the existing "tkobjc" library.</P></LI><LI><P>All direct references to any Tcl/Tk code such as the "globalTkInterp" variable have been completely removed from any library code and should not be used in any application.</P></LI><LI><P> Splitting of simtools into two separate libraries: simtools and simtoolsgui. Classes that intrinsically depend on a GUI toolkit being present (either Tcl/Tk or Java AWT) were put into simtoolsgui. This allows a user who never intends to use a GUI toolkit, to be able to compile, link and run Swarm applications <ICLASS="EMPHASIS">without any</I> GUI toolkit installed at all. This was not previously possible.</P></LI><LI><P> The above change has been made possible by the fact that the dependency of Tcl/Tk in the Probing mechanism has been completely removed. It has been replaced by the libffi/ffcall libraries. Other than the fact that the user will need to install this new library if they are not using a binary distribution, this new dependence should <ICLASS="EMPHASIS">not</I> break any user code.</P></LI><LI><P> The header file to the random library is no longer included in simtools.h you need to explicitly import random.h when you use a default random number generator.</P></LI><LI><P>The XColormap class is now just Colormap to divorce it from its association with X-Windows. Similarly, BLTGraph is now just Graph.</P></LI><LI><P>The class named Histo is now named Histogram.</P></LI><LI><P>Certain classes now enforce their defining by the protocol method. For example an instance of the Raster class must be defined as <TTCLASS="LITERAL">(id <Raster> r)</TT> rather than <TTCLASS="LITERAL">(Raster * r)</TT>.</P></LI><LI><P> Backwardly-compatible references to the old swarmobject library are no longer supported. You should always use objectbase.</P></LI></UL></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN1641">6.2. Porting guide</A></H2><P></P><UL><LI><P> Always use the "gui" protocol when calling doing any GUI events: <P></P><UL><LI><P>Replace all occurences of tkobjc.h with gui.h</P></LI><LI><P><ICLASS="EMPHASIS">never</I> explicitly reference any Tcl/Tk-specific code, in particular module with a call to globalTkInterp will no longer compile.</P></LI></UL> </P></LI><LI><P> Using simtools/simtoolsgui: <P></P><UL><LI><P>Add the header file simtoolsgui.h to your list of imports whenever you are referencing any of the following classes: <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">ActionCache, ControlPanel, SimpleProbeDisplay, ActionHolder,GUIComposite, VarProbeWidget, ActiveGraph, GUISwarm,ClassDisplayWidget, MessageProbeWidget, CommonProbeDisplay,ProbeDisplay, CompleteProbeDisplay,ProbeDisplayManager</PRE></TD></TR></TABLE> </P></LI></UL> </P></LI><LI><P> Explictly import the header when you are subclassing from a given class: <P></P><UL><LI><P>You also need to import the header file for any class for which you are subclassing. In particular, when you are creating a GUISwarm you are subclassing from GUISwarm so you need to explicitly import both <simtoolsgui.h> AND <simtoolsgui/GUISwarm.h>. The same is true for <objectbase/SwarmObject.h> and <objectbase/Swarm.h></P></LI></UL></P></LI><LI><P> Colormap class name change: <P></P><UL><LI><P>Change all references of XColormap to Colormap as it is no longer specific to X11.</P></LI><LI><P> Change all method references to set the Colormap for the Value2dDisplay class ([Value2dDisplay -Colormap]) to lowercase ([Value2dDisplay -colormap]) to avoid namespace conflicts with Colormap class. For example, in <SPANCLASS="APPLICATION">heatbugs</SPAN>: <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">[heatDisplay setDisplayWidget: worldRaster Colormap: colormap]; should now be: [heatDisplay setDisplayWidget: worldRaster colormap: colormap]; </PRE></TD></TR></TABLE> </P></LI></UL> </P></LI><LI><P> Ensure that all required classes conform to their protocol: <P></P><UL><LI><P>Make all occurences of (Raster *) to the protocol i.e. (id <Raster>)</P></LI><LI><P>Similarly change any references to Colormap, ZoomRaster, InFile and OutFile.</P></LI></UL> </P></LI><LI><P> Import random.h explicitly: <P></P><UL><LI><P>The header file <random.h> is no longer included by <simtools.h> should always <ICLASS="EMPHASIS">explicitly</I> reference the random library if you use it in a given module (.m) file. This again reduces the inter-library dependence, if you don't need to use the random library in your application, you shouldn't be including it. </P></LI></UL></P></LI><LI><P> ActionCache and ControlPanel: <P></P><UL><LI><P>Make all references to -doTkEvents and -waitForControlEvent be to actionCache NOT controlPanel.</P></LI></UL> </P></LI></UL></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN1690">6.3. Porting example: <SPANCLASS="APPLICATION">heatbugs</SPAN></A></H2><P>To help users port their applications to 1.1, I have included a checklist of changes that were required to update <SPANCLASS="APPLICATION">heatbugs</SPAN> from 1.0.5 to 1.1. This may help some users as a kind of "template" for changes they may require for their applications. The <TTCLASS="FILENAME">ChangeLog</TT> entries in in the<SPANCLASS="APPLICATION"> heatbug-1.1</SPAN> distribution also provide further specific information.</P><P><TTCLASS="FILENAME">Heatbug.h</TT></P><P></P><UL><LI><P> Replace <tkobjc/Raster.h> with <gui.h> <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P> Make all occurences of (Raster *) to the protocol (id <Raster>) <ICLASS="EMPHASIS">(*)</I></P></LI></UL><P><TTCLASS="FILENAME">Heatbug.m</TT></P><P></P><UL><LI><P>Make all occurences of (Raster *) to the protocol (id <Raster>) <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P>Removed <simtools.h> altogether - not used. <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P>Added <random.h> - no longer included by <simtools.h> - should always <ICLASS="EMPHASIS">explicitly</I> reference the random library if you use it in your code. <ICLASS="EMPHASIS">(*)</I></P></LI></UL><P><TTCLASS="FILENAME">HeatbugBatchSwarm.h</TT></P><P></P><UL><LI><P> Changed <swarmobject.h> to <objectbase.h> <ICLASS="EMPHASIS">(*)</I></P></LI></UL><P><TTCLASS="FILENAME">HeatbugBatchSwarm.m</TT></P><P></P><UL><LI><P> Removed redundant <collections.h> <ICLASS="EMPHASIS">(x)</I></P></LI></UL><P><TTCLASS="FILENAME">HeatbugModelSwarm.h</TT></P><P></P><UL><LI><P>Removed <tkobjc.h> irrelevant in this context - tkobjc should never be included directly in any case, if required use <gui.h> <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P> Changed <swarmobject.h> to <objectbase.h>. <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P> Note we need to <ICLASS="EMPHASIS">separately</I> include <objectbase/Swarm.h> since you always need to the header file for a class if you need to subclass from it. <ICLASS="EMPHASIS">(*)</I></P></LI></UL><P><TTCLASS="FILENAME">HeatbugModelSwarm.m</TT></P><P></P><UL><LI><P> Include <random.h> explicitly since we use the default random number generators. <ICLASS="EMPHASIS">(*)</I></P></LI></UL><P><TTCLASS="FILENAME">HeatbugObserverSwarm.h</TT></P><P></P><UL><LI><P> Change <simtools.h> to <simtoolsgui.h> since we are using GUI widgets <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P> Explicitly import <simtoolsgui/GUISwarm.h> since we subclass from it <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P> Remove: <swarmobject.h> <space.h> <activity.h> <collections.h> all are irrelevant in the header file. <ICLASS="EMPHASIS">(x)</I></P></LI><LI><P><tkobjc.h> has been relocated to the (.m) file as no gui classes are referenced directly in the header (.h) file. It is now changed to <gui.h>. <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P> Change all references of XColormap to Colormap and use protocol form: <ICLASS="EMPHASIS">(*)</I><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING"> XColormap * colormap TO id <Colormap> colormap</PRE></TD></TR></TABLE> </P></LI><LI><P>Make ZoomRaster conform to protocol, ie: <ICLASS="EMPHASIS">(*)</I> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING"> ZoomRaster * worldRaster TO id <ZoomRaster> worldRaster</PRE></TD></TR></TABLE> </P></LI></UL><P><TTCLASS="FILENAME">HeatbugObserverSwarm.m</TT></P><P></P><UL><LI><P>Change swarmobject to objectbase <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P>Import the <gui.h> in the implementation file - since it is not referenced in the header file <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P>Change XColormap to Colormap - no longer specific to X11 - so name should not suggest so. <ICLASS="EMPHASIS">(*)</I></P></LI><LI><P>Message to set colormap for worldRaster changed name from (uppercase) Colormap to (lowercase) colormap.<ICLASS="EMPHASIS">(*)</I></P></LI><LI><P>Call -enableDestroyNotification method on worldRaster after createEnd. <ICLASS="EMPHASIS">(x)</I></P></LI></UL><P><TTCLASS="FILENAME">main.m</TT></P><P></P><UL><LI><P>Need to import <simtoolsgui.h> in addition to <simtools.h> since we reference GUISwarm methods. <ICLASS="EMPHASIS">(*)</I></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="x1520.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="set.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="x1797.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Porting from 1.1 to 1.2</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.4 to 1.0.5</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -