/src/wrappers/common/library/enum.e

http://github.com/tybor/Liberty · Specman e · 57 lines · 43 code · 10 blank · 4 comment · 2 complexity · b0759911a1c0ee2784cee3f3eb755a1e MD5 · raw file

  1. note
  2. description:
  3. "Generic enumeration"
  4. copyright:
  5. "[
  6. Copyright (C) 2008-2017: Paolo Redaelli
  7. This library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public License
  9. as published by the Free Software Foundation; either version 2.1 of
  10. the License, or (at your option) any later version.
  11. This library is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. 02110-1301 USA
  19. ]"
  20. deferred class ENUM
  21. -- A wrapper for an enumeration
  22. insert
  23. ANY
  24. undefine default_create
  25. end
  26. feature {ANY}
  27. is_valid_state: BOOLEAN
  28. -- Is the value of the enumeration valid?
  29. do
  30. Result := is_valid_value(value)
  31. end
  32. feature {WRAPPER_HANDLER}
  33. value: INTEGER
  34. -- The current value of the enumeration.
  35. set, change_value (a_value: INTEGER)
  36. require
  37. is_valid_value(a_value)
  38. do
  39. value := a_value
  40. end
  41. is_valid_value (a_value: INTEGER): BOOLEAN
  42. -- Can `a_value' be used in a `set_value' feature call?
  43. deferred
  44. end
  45. invariant
  46. is_valid_state
  47. end -- class ENUM