/usr/share/mozart/doc/demo/node28.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>Agent definitions: Agents.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="node27.html#code.transportation.agentabstractions"><< Prev</A></TD><TD><A href="transportation.html">- Up -</A></TD><TD><A href="node29.html#code.transportation.country">Next >></A></TD></TR></TABLE><DIV class="unnumbered" id="code.transportation.agents"><H3><A name="code.transportation.agents">Agent definitions: <CODE>Agents.oz</CODE></A></H3><P class="margin"><A href="Transport/Agents.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR> <BR><SPAN class="keyword">import</SPAN> <BR> Tk<BR> <BR> Plan(make: MakePlan)<BR> Widgets(history: History<BR> truck: Truck)<BR> AgentAbstractions(new: NewAgent<BR> contract: Contract)<BR> <BR><SPAN class="keyword">export</SPAN> <BR> Broker<BR> Company<BR> Driver<BR> <BR><SPAN class="keyword">define</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Broker</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> Contract History</SPAN> <BR> <SPAN class="keyword">prop</SPAN> final<BR> <SPAN class="keyword">feat</SPAN> toplevel map<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(toplevel:T)<BR> Contract<SPAN class="keyword">,</SPAN> init<BR> History<SPAN class="keyword">,</SPAN> init(master:T suffix:<SPAN class="string">'Broker'</SPAN>)<BR> <SPAN class="keyword">self.</SPAN>toplevel = T<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">announce</SPAN>(<SPAN class="keyword">...</SPAN>) = M<BR> A R<BR> <SPAN class="keyword">in</SPAN> <BR> Contract<SPAN class="keyword">,</SPAN> {Adjoin M announce(answer:?A reply:R)}<BR> <SPAN class="keyword">if</SPAN> A<SPAN class="keyword">\=</SPAN>reject <SPAN class="keyword">then</SPAN> <BR> R=grant<BR> <SPAN class="keyword">end</SPAN> <BR> History<SPAN class="keyword">,</SPAN> M<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">add</SPAN>(company:C driver:D<SPAN class="keyword"><=unit</SPAN> <SPAN class="keyword">...</SPAN>) = M<BR> <SPAN class="keyword">if</SPAN> D<SPAN class="keyword">==unit</SPAN> <SPAN class="keyword">then</SPAN> <BR> Contract<SPAN class="keyword">,</SPAN>add(C {NewAgent Company<BR> init(name:C toplevel:<SPAN class="keyword">self.</SPAN>toplevel)})<BR> <SPAN class="keyword">else</SPAN> <BR> {Contract<SPAN class="keyword">,</SPAN>get(C $) add(driver:D city:M<SPAN class="keyword">.</SPAN>city)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">remove</SPAN>(company:C driver:D<SPAN class="keyword"><=unit</SPAN>)<BR> <SPAN class="keyword">if</SPAN> D<SPAN class="keyword">==unit</SPAN> <SPAN class="keyword">then</SPAN> Contract<SPAN class="keyword">,</SPAN>remove(C) <SPAN class="keyword">else</SPAN> <BR> {Contract<SPAN class="keyword">,</SPAN>get(C $) remove(D)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN> <BR> History<SPAN class="keyword">,</SPAN> tkClose<BR> Contract<SPAN class="keyword">,</SPAN> close<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Company</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> Contract History</SPAN> <BR> <SPAN class="keyword">prop</SPAN> final<BR> <SPAN class="keyword">feat</SPAN> toplevel<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(toplevel:T name:C)<BR> Contract<SPAN class="keyword">,</SPAN> init<BR> History<SPAN class="keyword">,</SPAN> init(master:T suffix:C)<BR> <SPAN class="keyword">self.</SPAN>toplevel = T<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">announce</SPAN>(answer:A reply:R <SPAN class="keyword">...</SPAN>) = Announcement<BR> Contract<SPAN class="keyword">,</SPAN> Announcement<BR> History<SPAN class="keyword">,</SPAN> Announcement<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">add</SPAN>(driver:D city:C)<BR> T = <SPAN class="keyword">self.</SPAN>toplevel<BR> ThisDriver = {NewAgent Driver init(toplevel:T name:D city:C<BR> truck:ThisTruck)}<BR> ThisTruck = {NewAgent Truck init(parent:T<SPAN class="keyword">.</SPAN>map city:C<BR> driver:ThisDriver)}<BR> <SPAN class="keyword">in</SPAN> <BR> Contract<SPAN class="keyword">,</SPAN> add(D ThisDriver)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN> <BR> History<SPAN class="keyword">,</SPAN> tkClose<BR> Contract<SPAN class="keyword">,</SPAN> close<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Driver</SPAN> <BR> <SPAN class="keyword">from</SPAN><SPAN class="type"> History</SPAN> <BR> <SPAN class="keyword">prop</SPAN> final<BR> <BR> <SPAN class="keyword">feat</SPAN> truck<BR> <BR> <SPAN class="keyword">attr</SPAN> plan:nil status:idle<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(toplevel:M name:N truck:T city:C)<BR> History<SPAN class="keyword">,</SPAN> init(master:M suffix:N)<BR> plan <SPAN class="keyword"><-</SPAN> [act(city:C load:0 lift:nil drop:nil)]<BR> %% <SPAN class="comment">Create the truck<BR></SPAN> <SPAN class="keyword">self.</SPAN>truck = T<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">deiconify</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>send wm(deiconify <SPAN class="keyword">self</SPAN>)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">announce</SPAN>(answer:A reply:R <SPAN class="keyword">...</SPAN>) = Announce<BR> NewPlan <BR> <SPAN class="keyword">in</SPAN> <BR> {MakePlan <SPAN class="keyword">@</SPAN>plan Announce ?A ?NewPlan}<BR> <SPAN class="keyword">case</SPAN> R<BR> <SPAN class="keyword">of</SPAN> reject <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> grant <SPAN class="keyword">then</SPAN> plan <SPAN class="keyword"><-</SPAN> NewPlan<BR> <SPAN class="keyword">end</SPAN> <BR> History<SPAN class="keyword">,</SPAN> Announce<BR> Driver<SPAN class="keyword">,</SPAN> check<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">check</SPAN> <BR> <SPAN class="keyword">case</SPAN> <SPAN class="keyword">@</SPAN>status<BR> <SPAN class="keyword">of</SPAN> closed <SPAN class="keyword">then</SPAN> {<SPAN class="keyword">self.</SPAN>truck close}<BR> <SPAN class="keyword">[]</SPAN> idle <SPAN class="keyword">then</SPAN> <BR> N={Length <SPAN class="keyword">@</SPAN>plan}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> N<SPAN class="keyword">></SPAN>1 <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> <SPAN class="keyword">@</SPAN>plan <SPAN class="keyword">of</SPAN> <BR> act(load:Load <SPAN class="keyword">...</SPAN>)<SPAN class="keyword">|</SPAN>act(load:NewLoad city:Dst <SPAN class="keyword">...</SPAN>)<SPAN class="keyword">|</SPAN>_<BR> <SPAN class="keyword">then</SPAN> <BR> plan <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>plan<SPAN class="keyword">.</SPAN>2<BR> <SPAN class="keyword">if</SPAN> N<SPAN class="keyword">></SPAN>2 <SPAN class="keyword">then</SPAN> status <SPAN class="keyword"><-</SPAN> active<BR> <SPAN class="keyword">end</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>truck drive(Dst Load NewLoad)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> active <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getMessage</SPAN>($)<BR> <SPAN class="keyword">case</SPAN> <SPAN class="keyword">@</SPAN>status<BR> <SPAN class="keyword">of</SPAN> closed <SPAN class="keyword">then</SPAN> close<BR> <SPAN class="keyword">[]</SPAN> idle <SPAN class="keyword">then</SPAN> <BR> History<SPAN class="keyword">,</SPAN> print(<SPAN class="string">'idle.'</SPAN>)<BR> load(0)<BR> <SPAN class="keyword">[]</SPAN> active <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> <SPAN class="keyword">@</SPAN>plan <SPAN class="keyword">of</SPAN> <BR> act(load:Load <SPAN class="keyword">...</SPAN>)<SPAN class="keyword">|</SPAN>act(load:NewLoad city:Dst <SPAN class="keyword">...</SPAN>)<SPAN class="keyword">|</SPAN>_<BR> <SPAN class="keyword">then</SPAN> <BR> plan <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>plan<SPAN class="keyword">.</SPAN>2<BR> <SPAN class="keyword">if</SPAN> {Length <SPAN class="keyword">@</SPAN>plan}<SPAN class="keyword">=<</SPAN>1 <SPAN class="keyword">then</SPAN> <BR> status <SPAN class="keyword"><-</SPAN> idle<BR> <SPAN class="keyword">end</SPAN> <BR> drive(Dst Load NewLoad)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN> <BR> History<SPAN class="keyword">,</SPAN> tkClose<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>status<SPAN class="keyword">==</SPAN>idle <SPAN class="keyword">then</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>truck close}<BR> <SPAN class="keyword">else</SPAN> <BR> status <SPAN class="keyword"><-</SPAN> closed<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> <BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node27.html#code.transportation.agentabstractions"><< Prev</A></TD><TD><A href="transportation.html">- Up -</A></TD><TD><A href="node29.html#code.transportation.country">Next >></A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|