/src/lib/backtracking/low_level/abstract_backtracking_sequence.e

http://github.com/tybor/Liberty · Specman e · 77 lines · 24 code · 6 blank · 47 comment · 0 complexity · 89340fea4bd53fbacfbe5e30d0471248 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. deferred class ABSTRACT_BACKTRACKING_SEQUENCE
  5. --
  6. -- Abstract realisation of a sequence iterator
  7. -- for the ABSTRACT_BACKTRACKING
  8. --
  9. -- The ABSTRACT_BACKTRACKING uses the fields
  10. -- continuation to record the continuation path
  11. -- and calls the feature 'next_sequence' to let
  12. -- the current object choose how to continue the
  13. -- exploration.
  14. --
  15. inherit
  16. ABSTRACT_BACKTRACKING_POOLABLE
  17. rename pool_link as previous,
  18. set_pool_link as set_previous
  19. export {ABSTRACT_BACKTRACKING_POOL, ABSTRACT_BACKTRACKING} set_previous
  20. redefine previous
  21. end
  22. feature {ABSTRACT_BACKTRACKING_POOL, ABSTRACT_BACKTRACKING}
  23. previous: ABSTRACT_BACKTRACKING_SEQUENCE
  24. -- For the linked stack of sequences.
  25. -- Managed by ABSTRACT_BACKTRACKING.
  26. feature {ABSTRACT_BACKTRACKING}
  27. continuation: ABSTRACT_BACKTRACKING_SEQUENCE
  28. -- The sequence to continue after a success in
  29. -- exploration of the current sequence.
  30. -- Managed by ABSTRACT_BACKTRACKING.
  31. set_continuation (value: like continuation)
  32. do
  33. continuation := value
  34. ensure
  35. definition: continuation = value
  36. end
  37. next_sequence (explorer: ABSTRACT_BACKTRACKING)
  38. -- Called by ABSTRACT_BACKTRACKING to let
  39. -- the current object switch to the next state
  40. -- to explore.
  41. -- Two actions must be performed by that feature:
  42. -- - make iteration actions and then call
  43. -- 'pop_sequence' if this is the last state
  44. -- to be explored.
  45. -- - select the state to be evaluated or
  46. -- call 'continue' or call 'backtrack'.
  47. require
  48. is_on_top: Current = explorer.top_sequence
  49. deferred
  50. end
  51. end -- class ABSTRACT_BACKTRACKING_SEQUENCE
  52. --
  53. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  54. --
  55. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  56. -- of this software and associated documentation files (the "Software"), to deal
  57. -- in the Software without restriction, including without limitation the rights
  58. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59. -- copies of the Software, and to permit persons to whom the Software is
  60. -- furnished to do so, subject to the following conditions:
  61. --
  62. -- The above copyright notice and this permission notice shall be included in
  63. -- all copies or substantial portions of the Software.
  64. --
  65. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  66. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  68. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  69. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  70. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  71. -- THE SOFTWARE.