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