/usr/share/mozart/doc/demo/node27.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Programming abstractions for agents: AgentAbstractions.oz</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node26.html#code.transportation.main"><< Prev</A></TD><TD><A href="transportation.html">- Up -</A></TD><TD><A href="node28.html#code.transportation.agents">Next >></A></TD></TR></TABLE><DIV class="unnumbered" id="code.transportation.agentabstractions"><H3><A name="code.transportation.agentabstractions">Programming abstractions for agents: <CODE>AgentAbstractions.oz</CODE></A></H3><P class="margin"><A href="Transport/AgentAbstractions.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR> <BR><SPAN class="keyword">export</SPAN> <BR> new: NewAgent<BR> contract: Contract<BR> <BR><SPAN class="keyword">prepare</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NewAgent</SPAN> Class Mess}<BR> Stream<BR> ThisPort = {NewPort Stream}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">thread</SPAN> <BR> ThisObject = {New Class Mess}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">try</SPAN> <BR> {ForAll Stream ThisObject}<BR> <SPAN class="keyword">catch</SPAN> system(_ debug:_) <SPAN class="keyword">then</SPAN> <BR> %% <SPAN class="comment">The toplevel widget has been closed<BR></SPAN> {ThisObject close}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Mess}<BR> {Send ThisPort Mess}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SendSlaves</SPAN> Ss M}<BR> <SPAN class="keyword">case</SPAN> Ss <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">[]</SPAN> S<SPAN class="keyword">|</SPAN>Sr <SPAN class="keyword">then</SPAN> NewM={Adjoin M announce(answer:_ reply:_)} <SPAN class="keyword">in</SPAN> <BR> {S NewM}<BR> NewM<SPAN class="keyword">|</SPAN>{SendSlaves Sr M}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">FindBest</SPAN> As BA}<BR> <SPAN class="keyword">case</SPAN> As <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> BA<BR> <SPAN class="keyword">[]</SPAN> A<SPAN class="keyword">|</SPAN>Ar <SPAN class="keyword">then</SPAN> <BR> RA<SPAN class="keyword">#</SPAN>KA = <SPAN class="keyword">if</SPAN> A<SPAN class="keyword">.</SPAN>answer<SPAN class="keyword">==</SPAN>reject <SPAN class="keyword">then</SPAN> A<SPAN class="keyword">#</SPAN>BA<BR> <SPAN class="keyword">elseif</SPAN> BA<SPAN class="keyword">.</SPAN>answer<SPAN class="keyword">==</SPAN>reject <SPAN class="keyword">then</SPAN> BA<SPAN class="keyword">#</SPAN>A<BR> <SPAN class="keyword">elseif</SPAN> A<SPAN class="keyword">.</SPAN>answer<SPAN class="keyword">></SPAN>BA<SPAN class="keyword">.</SPAN>answer <SPAN class="keyword">then</SPAN> A<SPAN class="keyword">#</SPAN>BA<BR> <SPAN class="keyword">else</SPAN> BA<SPAN class="keyword">#</SPAN>A<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> RA<SPAN class="keyword">.</SPAN>reply=reject {FindBest Ar KA}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Contract</SPAN> <BR> <SPAN class="keyword">feat</SPAN> MySlaves<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN> <BR> <SPAN class="keyword">self.</SPAN>MySlaves = {Dictionary<SPAN class="keyword">.</SPAN>new}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">add</SPAN>(Name Slave)<BR> {Dictionary<SPAN class="keyword">.</SPAN>put <SPAN class="keyword">self.</SPAN>MySlaves Name Slave}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">remove</SPAN>(Name)<BR> Slave = {Dictionary<SPAN class="keyword">.</SPAN>get <SPAN class="keyword">self.</SPAN>MySlaves Name}<BR> <SPAN class="keyword">in</SPAN> <BR> {Dictionary<SPAN class="keyword">.</SPAN>remove <SPAN class="keyword">self.</SPAN>MySlaves Name}<BR> {Slave close}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">announce</SPAN>(<SPAN class="keyword">...</SPAN>) = M<BR> <SPAN class="keyword">case</SPAN> {SendSlaves {Dictionary<SPAN class="keyword">.</SPAN>items <SPAN class="keyword">self.</SPAN>MySlaves} M}<BR> <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> M<SPAN class="keyword">.</SPAN>answer=reject<BR> <SPAN class="keyword">[]</SPAN> A<SPAN class="keyword">|</SPAN>Ar <SPAN class="keyword">then</SPAN> M={FindBest Ar A}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">get</SPAN>(Name $)<BR> {Dictionary<SPAN class="keyword">.</SPAN>get <SPAN class="keyword">self.</SPAN>MySlaves Name}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN> <BR> {ForAll {Dictionary<SPAN class="keyword">.</SPAN>items <SPAN class="keyword">self.</SPAN>MySlaves}<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> E}<BR> {E close}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node26.html#code.transportation.main"><< Prev</A></TD><TD><A href="transportation.html">- Up -</A></TD><TD><A href="node28.html#code.transportation.agents">Next >></A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|