/test/language/gc/aux_agent_gc1.e
Specman e | 93 lines | 60 code | 12 blank | 21 comment | 1 complexity | 79b252758611ce0897327d3e26d50077 MD5 | raw file
1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries. 2-- See the Copyright notice at the end of this file. 3-- 4class AUX_AGENT_GC1 5 6create {ANY} 7 make_region, make_main 8 9feature {ANY} 10 districts: FAST_ARRAY[AUX_AGENT_GC1] 11 12 hospital: AUX_AGENT_GC2 13 14 Levels: INTEGER 5 15 16 Districts: INTEGER 4 17 18 make_main 19 do 20 make_region(Levels, 0, 42) 21 end 22 23 make_region (level, seed1, seed2: INTEGER) 24 local 25 staff: INTEGER; hr: AUX_AGENT_GC1; i: INTEGER 26 do 27 staff := {INTEGER_32 1} |<< (level - 1).to_integer_8 28 if level = 1 then 29 make(staff, seed1 * seed2, False) 30 else 31 make(staff, seed1 * seed2, level = Levels) 32 from 33 until 34 i = Districts 35 loop 36 create hr.make_region(level - 1, 4 * seed1 + i + 1, seed2) 37 districts.add_last(hr) 38 i := i + 1 39 end 40 end 41 end 42 43 make (staff, seed: INTEGER; is_main: BOOLEAN) 44 do 45 create hospital.make(staff, seed, is_main) 46 create districts.with_capacity(Districts) 47 end 48 49 next_time 50 do 51 districts.for_each(agent {AUX_AGENT_GC1}.next_time_and_transfer_to(hospital)) 52 hospital.triage_examination 53 end 54 55 next_time_and_transfer_to (destination: AUX_AGENT_GC2) 56 do 57 next_time 58 hospital.transfers.for_each(agent destination.new_arrival(?)) 59 end 60 61 accumulate_totals: AUX_AGENT_GC5 62 local 63 i: INTEGER 64 do 65 from 66 Result := hospital.accumulate_totals 67 until 68 i > districts.upper 69 loop 70 Result := Result + districts.item(i).accumulate_totals 71 i := i + 1 72 end 73 end 74 75end -- class AUX_AGENT_GC1 76-- 77-- ------------------------------------------------------------------------------------------------------------------------------ 78-- Copyright notice below. Please read. 79-- 80-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 81-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 82-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 83-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 84-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 85-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 86-- 87-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 88-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 89-- 90-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 91-- 92-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 93-- ------------------------------------------------------------------------------------------------------------------------------