PageRenderTime 9ms CodeModel.GetById 6ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/storage/repository/xml_stream_repository.e

http://github.com/tybor/Liberty
Specman e | 78 lines | 41 code | 10 blank | 27 comment | 1 complexity | 2f29771d52546676b875361461e494c3 MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4class XML_STREAM_REPOSITORY [O_ -> STORABLE]
 5   --
 6   -- To be used via streams that commit and update the XML repository
 7   --
 8inherit
 9   XML_REPOSITORY_IMPL[O_]
10
11create {ANY}
12   connect_to
13
14feature {ANY} -- Updating and committing
15   commit
16      do
17         write_to_stream(out_stream)
18      end
19
20   is_commitable: BOOLEAN
21      do
22         Result := commit_stream /= Void and then commit_stream.is_connected
23      end
24
25   update
26      do
27         read_from_stream(update_stream)
28      end
29
30   is_updateable: BOOLEAN
31      do
32         Result := update_stream /= Void and then update_stream.is_connected
33      end
34
35   is_connected: BOOLEAN
36      do
37         Result := commit_stream /= Void and then commit_stream.is_connected
38      end
39
40feature {ANY} -- Creation
41   connect_to (a_in_stream: like update_stream; a_out_stream: like commit_stream)
42         -- Connect to a repository with streams as physical store.
43      do
44         make
45         update_stream := a_in_stream
46         commit_stream := a_out_stream
47
48         if a_out_stream /= Void then
49            create out_stream.make(a_out_stream, version)
50         end
51      end
52
53feature {}
54   update_stream: INPUT_STREAM
55   commit_stream: OUTPUT_STREAM
56   out_stream: XML_REPOSITORY_OUTPUT
57
58end -- class XML_STREAM_REPOSITORY
59--
60-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
61--
62-- Permission is hereby granted, free of charge, to any person obtaining a copy
63-- of this software and associated documentation files (the "Software"), to deal
64-- in the Software without restriction, including without limitation the rights
65-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66-- copies of the Software, and to permit persons to whom the Software is
67-- furnished to do so, subject to the following conditions:
68--
69-- The above copyright notice and this permission notice shall be included in
70-- all copies or substantial portions of the Software.
71--
72-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
78-- THE SOFTWARE.