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