/src/wrappers/glib/library/g_freezable.e

http://github.com/tybor/Liberty · Specman e · 82 lines · 55 code · 15 blank · 12 comment · 2 complexity · d44301d0a8bbd46906c7440c164a158e MD5 · raw file

  1. indexing
  2. description: "An object that can be made ."
  3. copyright: "[
  4. Copyright (C) 2007 Paolo Redaelli
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. deferred class G_FREEZABLE
  19. -- An object that can be made temporary or permanently
  20. -- unchangable.
  21. -- Note for the developer: this behaviour is
  22. -- currently only a hint to the end-user and
  23. -- it is not enforced throught an invariant.
  24. -- TODO: implement an invariant.
  25. insert ANY undefine copy, is_equal, fill_tagged_out_memory end
  26. feature
  27. freeze is
  28. -- Forbid further changes to Current until thaw is invoked
  29. do
  30. state := state.max(freezed_state)
  31. end
  32. thaw is
  33. -- Allow changes to Current
  34. require can_be_thawed
  35. do
  36. state := mutable_state
  37. end
  38. petrify is
  39. do
  40. state := petrified_state
  41. end
  42. is_mutable: BOOLEAN is
  43. do
  44. Result := state=mutable_state
  45. end
  46. is_freezed: BOOLEAN is
  47. do
  48. Result := state>=freezed_state
  49. end
  50. can_be_thawed: BOOLEAN is
  51. do
  52. Result := not is_petrified
  53. end
  54. is_petrified: BOOLEAN is
  55. do
  56. Result := state>=petrified_state
  57. end
  58. feature {}
  59. state: INTEGER_8
  60. mutable_state: INTEGER_8 is 0
  61. -- The object can be changed
  62. freezed_state: INTEGER_8 is 1
  63. -- The object cannot currently be changed but can be
  64. -- made changeable
  65. petrified_state: INTEGER_8 is 2
  66. -- The object cannot be changed anymore
  67. end -- class G_FREEZABLE