/tutorial/backtracking/logigram/description.e

http://github.com/tybor/Liberty · Specman e · 131 lines · 93 code · 20 blank · 18 comment · 1 complexity · e0cc68beb4131f32df49340b1b703354 MD5 · raw file

  1. -- See the Copyright notice at the end of this file.
  2. --
  3. class DESCRIPTION
  4. creation {ANY}
  5. make
  6. feature {ANY}
  7. group: GROUP
  8. group_array: FAST_ARRAY[like group]
  9. group_dictionary: AVL_DICTIONARY[like group, STRING]
  10. constraints: CONSTRAINT_SET
  11. make is
  12. do
  13. create group_array.with_capacity(10)
  14. create group_dictionary.make
  15. create constraints.make
  16. end
  17. add_group_atomic (name: STRING) is
  18. do
  19. create group.make_atomic(name, 1 + group_array.upper)
  20. add_group
  21. end
  22. add_group_numeric (name: STRING) is
  23. do
  24. create group.make_numeric(name, 1 + group_array.upper)
  25. add_group
  26. end
  27. add_group_ordered (name: STRING) is
  28. do
  29. create group.make_ordered(name, 1 + group_array.upper)
  30. add_group
  31. end
  32. get_item (group_name, item_name: STRING): ITEM_ITEM is
  33. do
  34. goto_name(group_name)
  35. group.goto_name(item_name)
  36. Result := group.item
  37. end
  38. get_group (group_name: STRING): GROUP is
  39. do
  40. goto_name(group_name)
  41. Result := group
  42. end
  43. goto_name (group_name: STRING) is
  44. do
  45. group := group_dictionary.at(group_name)
  46. end
  47. goto_index (group_index: INTEGER) is
  48. do
  49. group := group_array.item(group_index)
  50. end
  51. group_count: INTEGER is
  52. do
  53. Result := group_array.count
  54. end
  55. is_valid: BOOLEAN is
  56. local
  57. i: INTEGER
  58. do
  59. if not group_array.is_empty then
  60. from
  61. Result := True
  62. i := group_array.lower + 1
  63. until
  64. i > group_array.upper
  65. loop
  66. Result := group_array.first.item_count = group_array.item(i).item_count
  67. i := i + 1
  68. end
  69. end
  70. end
  71. dimension: INTEGER is
  72. require
  73. is_valid
  74. do
  75. Result := group_array.first.item_count
  76. end
  77. get_var (group_name, var_name: STRING): ITEM_VAR is
  78. do
  79. goto_name(group_name)
  80. group.get_var(var_name)
  81. Result := group.var
  82. end
  83. get_anonymous_var (group_name: STRING): ITEM_VAR is
  84. do
  85. goto_name(group_name)
  86. group.get_anonymous_var
  87. Result := group.var
  88. end
  89. feature {}
  90. add_group is
  91. do
  92. group_array.add_last(group)
  93. group_dictionary.add(group, group.name)
  94. end
  95. end -- class DESCRIPTION
  96. --
  97. -- ------------------------------------------------------------------------------------------------------------------------------
  98. -- Copyright notice below. Please read.
  99. --
  100. -- This file is free software, which comes along with SmartEiffel. This software is distributed in the hope that it will be
  101. -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  102. -- You can modify it as you want, provided this footer is kept unaltered, and a notification of the changes is added.
  103. -- You are allowed to redistribute it and sell it, alone or as a part of another product.
  104. --
  105. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  106. -- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  107. --
  108. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  109. --
  110. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  111. -- ------------------------------------------------------------------------------------------------------------------------------