/test/language/gc/aux_agent_gc1.e

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