/src/wrappers/gobject/library/freezable.e

http://github.com/tybor/Liberty · Specman e · 67 lines · 46 code · 15 blank · 6 comment · 2 complexity · 22f16c4b16ca533fa78ae0a7800f3bb9 MD5 · raw file

  1. indexing
  2. copyright: "[
  3. Copyright (C) 2007 Paolo Redaelli
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public License
  6. as published by the Free Software Foundation; either version 2.1 of
  7. the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA
  16. ]"
  17. deferred class FREEZABLE
  18. -- An object that can be made temporary or permanently unchangable.
  19. -- Note: this class is currently used only in G_VALUE. It is debatable if
  20. -- the behaviour it provides is actually useful or desiderable.
  21. insert ANY undefine copy, is_equal, fill_tagged_out_memory end
  22. feature
  23. freeze is
  24. -- Forbid further changes to Current until thaw is invoked
  25. do
  26. state := state.bit_set(freezed_bit)
  27. end
  28. thaw is
  29. -- Allow changes to Current
  30. do
  31. state := state.bit_reset(freezed_bit)
  32. end
  33. petrify is
  34. do
  35. state := state.bit_set(freezed_bit)
  36. state := state.bit_set(petrified_bit)
  37. end
  38. is_freezed: BOOLEAN is
  39. do
  40. Result := (state.bit_test(freezed_bit) or
  41. state.bit_test(petrified_bit))
  42. -- Oh yeah it could have been written a-la C.
  43. end
  44. is_petrified: BOOLEAN is
  45. do
  46. Result := state.bit_test(petrified_bit)
  47. end
  48. feature {}
  49. state: INTEGER_8
  50. freezed_bit: INTEGER_8 is 0
  51. petrified_bit: INTEGER_8 is 1
  52. end -- class FREEZABLE