/src/lib/storage/internal/repository_transient_object.e

http://github.com/tybor/Liberty · Specman e · 104 lines · 67 code · 14 blank · 23 comment · 1 complexity · c8cb762d58d83906d0955fadfcab9140 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class REPOSITORY_TRANSIENT_OBJECT
  5. inherit
  6. HASHABLE
  7. COMPARABLE
  8. redefine is_equal
  9. end
  10. insert
  11. RECYCLABLE
  12. redefine is_equal
  13. end
  14. INTERNALS_HANDLER
  15. redefine is_equal
  16. end
  17. create {REPOSITORY_TRANSIENT}
  18. make, set
  19. feature {ANY}
  20. hash_code: INTEGER
  21. do
  22. if internals /= Void then
  23. Result := internals.object_as_pointer.hash_code
  24. end
  25. end
  26. infix "<" (other: like Current): BOOLEAN
  27. do
  28. Result := hash_code < other.hash_code
  29. end
  30. is_equal (other: like Current): BOOLEAN
  31. do
  32. Result := hash_code = other.hash_code
  33. end
  34. feature {REPOSITORY_TRANSIENT}
  35. set (a_internals: like internals; a_key: like key)
  36. require
  37. not a_internals.type_is_expanded
  38. a_internals.object_as_pointer /= default_pointer
  39. a_key /= Void
  40. do
  41. internals := a_internals
  42. key := a_key
  43. ensure
  44. internals = a_internals
  45. key = a_key
  46. end
  47. internals: INTERNALS
  48. key: STRING
  49. reset
  50. do
  51. internals := Void
  52. key := Void
  53. ensure
  54. internals = Void
  55. key = Void
  56. end
  57. feature {RECYCLING_POOL}
  58. recycle
  59. do
  60. reset
  61. end
  62. feature {}
  63. make
  64. do
  65. end
  66. invariant
  67. internals /= Void implies not internals.type_is_expanded
  68. internals /= Void implies internals.object_as_pointer /= default_pointer
  69. internals /= Void = (key /= Void)
  70. end -- class REPOSITORY_TRANSIENT_OBJECT
  71. --
  72. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  73. --
  74. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  75. -- of this software and associated documentation files (the "Software"), to deal
  76. -- in the Software without restriction, including without limitation the rights
  77. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  78. -- copies of the Software, and to permit persons to whom the Software is
  79. -- furnished to do so, subject to the following conditions:
  80. --
  81. -- The above copyright notice and this permission notice shall be included in
  82. -- all copies or substantial portions of the Software.
  83. --
  84. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  85. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  86. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  87. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  88. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  89. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  90. -- THE SOFTWARE.