/[eiffelstudio]/FreeELKS/trunk/library/kernel/storable.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/storable.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91424 - (show annotations)
Tue Oct 26 18:39:32 2004 UTC (15 years, 2 months ago) by manus_eiffel
File size: 5667 byte(s)
Initial revision

1 indexing
2
3 description: "[
4 Objects that may be stored and retrieved along with all their dependents.
5 This class may be used as ancestor by classes needing its facilities.
6 ]"
7
8 status: "See notice at end of class"
9 date: "$Date$"
10 revision: "$Revision$"
11
12 class
13 STORABLE
14
15 inherit
16 EXCEPTIONS
17
18 feature -- Access
19
20 retrieved (medium: IO_MEDIUM): ANY is
21 -- Retrieved object structure, from external
22 -- representation previously stored in `medium'.
23 -- To access resulting object under correct type,
24 -- use assignment attempt.
25 -- Will raise an exception (code `Retrieve_exception')
26 -- if medium content is not a stored Eiffel structure.
27 require
28 medium_not_void: medium /= Void
29 medium_exists: medium.exists
30 medium_is_open_read: medium.is_open_read
31 medium_supports_storable: medium.support_storable
32 do
33 Result := medium.retrieved
34 ensure
35 Result_exists: Result /= Void
36 end
37
38 retrieve_by_name (file_name: STRING): ANY is
39 -- Retrieve object structure, from external
40 -- representation previously stored in a file
41 -- called `file_name'.
42 -- To access resulting object under correct type,
43 -- use assignment attempt.
44 -- Will raise an exception (code `Retrieve_exception')
45 -- if file content is not a stored Eiffel structure.
46 -- Will return Void if the file does not exist or
47 -- is not readable.
48 require
49 file_name_exists: file_name /= Void
50 file_name_meaningful: not file_name.is_empty
51 local
52 file: RAW_FILE
53 do
54 create file.make (file_name)
55 if file.exists and then file.is_readable then
56 file.open_read
57 Result := file.retrieved
58 file.close
59 end
60 end
61
62 feature -- Setting
63
64 set_discard_pointers (v: BOOLEAN) is
65 -- If `v' it will discard POINTER values and replace them by
66 -- the `default_pointer' pointer. Otherwise it keeps the original value.
67 external
68 "C macro signature (EIF_BOOLEAN) use %"eif_retrieve.h%""
69 alias
70 "eif_set_discard_pointer_values"
71 end
72
73 set_new_independent_format (v: BOOLEAN) is
74 -- If `v' it will use ISE Eiffel 5.0 storable format for
75 -- storing.
76 external
77 "C macro signature (EIF_BOOLEAN) use %"eif_store.h%""
78 alias
79 "eif_set_new_independent_format"
80 end
81
82 set_new_recoverable_format (v: BOOLEAN) is
83 -- If `v' it will use ISE Eiffel 5.3 storable format for
84 -- storing with ability to recover when there is a type mismatch.
85 external
86 "C macro signature (EIF_BOOLEAN) use %"eif_store.h%""
87 alias
88 "eif_set_new_recoverable_format"
89 end
90
91 feature -- Element change
92
93 basic_store (medium: IO_MEDIUM) is
94 -- Produce on `medium' an external representation of the
95 -- entire object structure reachable from current object.
96 -- Retrievable within current system only.
97 require
98 medium_not_void: medium /= Void
99 medium_exists: medium.exists
100 medium_is_open_write: medium.is_open_write
101 medium_supports_storable: medium.support_storable
102 do
103 medium.basic_store (Current)
104 end
105
106 general_store (medium: IO_MEDIUM) is
107 -- Produce on `medium' an external representation of the
108 -- entire object structure reachable from current object.
109 -- Retrievable from other systems for same platform
110 -- (machine architecture).
111 --| This feature may use a visible name of a class written
112 --| in the `visible' clause of the Ace file. This makes it
113 --| possible to overcome class name clashes.
114 require
115 medium_not_void: medium /= Void
116 medium_exists: medium.exists
117 medium_is_open_write: medium.is_open_write
118 medium_supports_storable: medium.support_storable
119 do
120 medium.general_store (Current)
121 end
122
123 independent_store (medium: IO_MEDIUM) is
124 -- Produce on `medium' an external representation of the
125 -- entire object structure reachable from current object.
126 -- Retrievable from other systems for the same or other
127 -- platform (machine architecture).
128 require
129 medium_not_void: medium /= Void
130 medium_exists: medium.exists
131 medium_is_open_write: medium.is_open_write
132 medium_supports_storable: medium.support_storable
133 do
134 medium.independent_store (Current)
135 end
136
137 store_by_name (file_name: STRING) is
138 -- Produce on file called `file_name' an external
139 -- representation of the entire object structure
140 -- reachable from current object.
141 -- Retrievable from other systems for same platform
142 -- (machine architecture).
143 require
144 file_name_not_void: file_name /= Void
145 file_name_meaningful: not file_name.is_empty
146 local
147 file: RAW_FILE
148 a: ANY
149 do
150 create file.make (file_name)
151 if (file.exists and then file.is_writable) or else
152 (file.is_creatable) then
153 file.open_write
154 file.independent_store (Current)
155 file.close
156 else
157 a := ("write permission failure").to_c
158 eraise ($a, Io_exception)
159 end
160 end
161
162 indexing
163
164 library: "[
165 EiffelBase: Library of reusable components for Eiffel.
166 ]"
167
168 status: "[
169 Copyright 1986-2001 Interactive Software Engineering (ISE).
170 For ISE customers the original versions are an ISE product
171 covered by the ISE Eiffel license and support agreements.
172 ]"
173
174 license: "[
175 EiffelBase may now be used by anyone as FREE SOFTWARE to
176 develop any product, public-domain or commercial, without
177 payment to ISE, under the terms of the ISE Free Eiffel Library
178 License (IFELL) at http://eiffel.com/products/base/license.html.
179 ]"
180
181 source: "[
182 Interactive Software Engineering Inc.
183 ISE Building
184 360 Storke Road, Goleta, CA 93117 USA
185 Telephone 805-685-1006, Fax 805-685-6869
186 Electronic mail <info@eiffel.com>
187 Customer support http://support.eiffel.com
188 ]"
189
190 info: "[
191 For latest info see award-winning pages: http://eiffel.com
192 ]"
193
194 end -- class STORABLE
195
196

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23