resdatastream.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <fpdoc-descriptions>
  3. <package name="fcl-res">
  4. <!--
  5. ====================================================================
  6. resdatastream
  7. ====================================================================
  8. -->
  9. <module name="resdatastream">
  10. <short>Contains stream classes to provide copy-on-write functionality</short>
  11. <descr>
  12. <p>This unit contains various streams that are used to provide copy-on-write mechanism for <link id="resource.TAbstractResource.RawData">TAbstractResource.RawData</link>, via more levels of indirection.</p>
  13. <p>Main class is <link id="TResourceDataStream"/>, which is the stream used for <link id="resource.TAbstractResource.RawData">TAbstractResource.RawData</link>. This class uses an underlying stream, to which it redirects operations.</p>
  14. <p>At a lower level, a <link id="TCachedDataStream"/> descendant provides a layer between the original stream and the <link id="TResourceDataStream"/>.</p>
  15. </descr>
  16. <!-- unresolved type reference Visibility: default -->
  17. <element name="Classes">
  18. </element>
  19. <!-- unresolved type reference Visibility: default -->
  20. <element name="SysUtils">
  21. </element>
  22. <!-- unresolved type reference Visibility: default -->
  23. <element name="resource">
  24. </element>
  25. <!-- object Visibility: default -->
  26. <element name="TCachedDataStream">
  27. <short>Base cached stream class</short>
  28. <descr>
  29. <p>This abstract class provides basic cached stream functionalities.</p>
  30. <p>A cached stream is a read-only stream that operates on a portion of another stream. That is, it creates a "window" on the original stream from which to read data. Since it is a read-only stream, trying to write to the stream or to set its size cause an EInvalidOperation exception to be raised.</p>
  31. <p>This class is used by <link id="TResourceDataStream"/> to access the raw data of a resource. When an attempt to write to the stream is detected, <link id="TResourceDataStream"/> replaces it with a memory stream and copies the contents of the cached stream to the memory one, thus providing a copy-on-write mechanism.</p>
  32. <remark>An object of this class should never be directly instantiated: use a descendant class instead.</remark>
  33. </descr>
  34. <seealso>
  35. <link id="TResourceDataStream"/>
  36. <link id="TCachedResourceDataStream"/>
  37. </seealso>
  38. </element>
  39. <!-- variable Visibility: protected -->
  40. <element name="TCachedDataStream.fStream">
  41. <short>The original stream</short>
  42. <descr>
  43. <p>This protected member is provided to let descendant classes access the original stream.</p>
  44. </descr>
  45. </element>
  46. <!-- variable Visibility: protected -->
  47. <element name="TCachedDataStream.fSize">
  48. <short>The size of the cached stream</short>
  49. <descr>
  50. <p>This protected member is provided to let descendant classes access the size of the cached stream.</p>
  51. </descr>
  52. </element>
  53. <!-- variable Visibility: protected -->
  54. <element name="TCachedDataStream.fPosition">
  55. <short>The position from the cached stream perspective</short>
  56. <descr>
  57. <p>This protected member is provided to let descendant classes access the position of the cached stream.</p>
  58. </descr>
  59. </element>
  60. <!-- constructor Visibility: public -->
  61. <element name="TCachedDataStream.Create">
  62. <short>Creates a new object</short>
  63. <descr>
  64. <p>A new cached stream is created on top of the <var>aStream</var> stream.</p>
  65. </descr>
  66. <seealso>
  67. <link id="TCachedDataStream"/>
  68. <link id="TResourceDataStream"/>
  69. <link id="TResourceDataStream.Create"/>
  70. </seealso>
  71. </element>
  72. <!-- argument Visibility: default -->
  73. <element name="TCachedDataStream.Create.aStream">
  74. <short>The stream from which to read data</short>
  75. </element>
  76. <!-- argument Visibility: default -->
  77. <element name="TCachedDataStream.Create.aResource">
  78. <short>The resource whose data must be read</short>
  79. </element>
  80. <!-- argument Visibility: default -->
  81. <element name="TCachedDataStream.Create.aSize">
  82. <short>The size of the resource data</short>
  83. </element>
  84. <!-- object Visibility: default -->
  85. <element name="TCachedResourceDataStream">
  86. <short>An implementation of a cached stream</short>
  87. <descr>
  88. <p>This class provides an implementation of <link id="TCachedDataStream"/>.</p>
  89. <p>Usually resource readers create a <link id="TResourceDataStream"/> with a TCachedResourceDataStream as the underlying stream.</p>
  90. </descr>
  91. <seealso>
  92. <link id="TCachedDataStream"/>
  93. <link id="TResourceDataStream"/>
  94. </seealso>
  95. </element>
  96. <!-- "class of" type Visibility: default -->
  97. <element name="TCachedStreamClass">
  98. <short>Cached stream metaclass</short>
  99. </element>
  100. <!-- enumeration type Visibility: default -->
  101. <element name="TUnderlyingStreamType">
  102. <short>The type of the underlying stream of TResourceDataStream</short>
  103. <seealso>
  104. <link id="TResourceDataStream"/>
  105. </seealso>
  106. </element>
  107. <!-- enumeration value Visibility: default -->
  108. <element name="TUnderlyingStreamType.usCached">
  109. <short>The underlying stream is a TCachedResourceDataStream descendant</short>
  110. </element>
  111. <!-- enumeration value Visibility: default -->
  112. <element name="TUnderlyingStreamType.usMemory">
  113. <short>The underlying stream is a memory stream</short>
  114. </element>
  115. <!-- enumeration value Visibility: default -->
  116. <element name="TUnderlyingStreamType.usCustom">
  117. <short>The underlying stream is a custom stream</short>
  118. </element>
  119. <!-- object Visibility: default -->
  120. <element name="TResourceDataStream">
  121. <short>Stream class that provides copy-on-write functionality</short>
  122. <descr>
  123. <p>This class provides the copy-on-write mechanism of <link id="resource.TAbstractResource.RawData">TAbstractResource.RawData</link>, via more levels of indirection.</p>
  124. <p>It uses an underlying stream, to which it redirects operations.</p>
  125. <p>The underlying stream can be a <link id="TCachedDataStream"/> descendant, a memory stream or a custom stream. Usually when a resource is loaded from a stream, the underlying stream is a <link id="TCachedDataStream"/> descendant, which provides a read-only stream-like interface over a portion of the original stream (that is, the part of the original stream where resource data resides). When <link id="TResourceDataStream"/> is requested to write data, it replaces the underlying stream with a memory stream, whose contents are copied from the previous underlying stream: this way, copy-on-write functionality can be achieved.</p>
  126. <p>As said before, third possibility is to have a custom stream as the underlying stream: a user can set this stream via <link id="resource.TAbstractResource.SetCustomRawDataStream">TAbstractResource.SetCustomRawDataStream</link> method, which in turn calls <link id="TResourceDataStream.SetCustomStream"/></p>
  127. <p><b>Figure</b>: Levels of indirection</p>
  128. <pre>
  129. .
  130. TResourceDataStream
  131. |
  132. _______________________|_______________________________
  133. | | |
  134. TMemoryStream TCachedDataStream descendant custom stream
  135. / \
  136. _______________________|_____________|______________________________
  137. | o r i g|i n a l s t|r e a m |
  138. |_______________________|_____________|______________________________|
  139. </pre>
  140. </descr>
  141. <seealso>
  142. <link id="TCachedDataStream"/>
  143. <link id="TResourceDataStream.Create"/>
  144. <link id="TResourceDataStream.SetCustomStream"/>
  145. </seealso>
  146. </element>
  147. <!-- constructor Visibility: public -->
  148. <element name="TResourceDataStream.Create">
  149. <short>Creates a new object</short>
  150. <descr>
  151. <p>A new <link id="TResourceDataStream"/> object is created.</p>
  152. <p>If <var>aStream</var> is <var>nil</var>, the underlying stream is a memory stream. Otherwise, a cached stream of the class specified in <var>aClass</var> is created and set as the underlying stream.</p>
  153. </descr>
  154. <seealso>
  155. <link id="TResourceDataStream"/>
  156. <link id="TCachedDataStream"/>
  157. <link id="TResourceDataStream.SetCustomStream"/>
  158. </seealso>
  159. </element>
  160. <!-- argument Visibility: default -->
  161. <element name="TResourceDataStream.Create.aStream">
  162. <short>The stream which resource data must be read from. It can be <var>nil</var></short>
  163. </element>
  164. <!-- argument Visibility: default -->
  165. <element name="TResourceDataStream.Create.aResource">
  166. <short>The resource whose data must be read</short>
  167. </element>
  168. <!-- argument Visibility: default -->
  169. <element name="TResourceDataStream.Create.aSize">
  170. <short>The size of the resource data</short>
  171. </element>
  172. <!-- argument Visibility: default -->
  173. <element name="TResourceDataStream.Create.aClass">
  174. <short>The class to use to create the underlying cached stream</short>
  175. </element>
  176. <!-- function Visibility: public -->
  177. <element name="TResourceDataStream.Compare">
  178. <short>Compares the stream to another one</short>
  179. <descr>
  180. <p>This methods compares the stream with <var>aStream</var>. If they are of the same length and their contents are the same, <var>true</var> is returned, <var>false</var> otherwise.</p>
  181. </descr>
  182. <seealso>
  183. <link id="resource.TAbstractResource.CompareContents">TAbstractResource.CompareContents</link>
  184. </seealso>
  185. </element>
  186. <!-- function result Visibility: default -->
  187. <element name="TResourceDataStream.Compare.Result">
  188. <short>True if the contents of the two streams are the same</short>
  189. </element>
  190. <!-- argument Visibility: default -->
  191. <element name="TResourceDataStream.Compare.aStream">
  192. <short>The stream to compare to this one. It can be <var>nil</var></short>
  193. </element>
  194. <!-- procedure Visibility: public -->
  195. <element name="TResourceDataStream.SetCustomStream">
  196. <short>Sets a custom stream as the underlying stream</short>
  197. <descr>
  198. <p>This method sets a custom stream as the underlying stream.</p>
  199. <p>If <var>aStream</var> is <var>nil</var>, a new memory stream is used as the underlying stream. This can be used to remove a previously set custom stream as the underlying stream.</p>
  200. <p>Usually it is called by <link id="resource.TAbstractResource.SetCustomRawDataStream">TAbstractResource.SetCustomRawDataStream</link>.</p>
  201. </descr>
  202. <seealso>
  203. <link id="TResourceDataStream"/>
  204. <link id="resource.TAbstractResource.SetCustomRawDataStream">TAbstractResource.SetCustomRawDataStream</link>
  205. </seealso>
  206. </element>
  207. <!-- argument Visibility: default -->
  208. <element name="TResourceDataStream.SetCustomStream.aStream">
  209. <short>The stream to use as the underlying stream. It can be <var>nil</var></short>
  210. </element>
  211. <!-- property Visibility: public -->
  212. <element name="TResourceDataStream.Cached">
  213. <short>Controls the copy-on-write behaviour of the stream</short>
  214. <descr>
  215. <p>When this property is set to <var>true</var>, a cached stream is used as the underlying stream for read operations. If it is set to <var>false</var>, no caching is performed and data is always copied to a memory stream.</p>
  216. <p>Note that this property does nothing if the underlying stream is a custom stream.</p>
  217. <p>By default this property is true.</p>
  218. </descr>
  219. <seealso>
  220. <link id="TResourceDataStream"/>
  221. <link id="resource.TAbstractResource.CacheData">TAbstractResource.CacheData</link>
  222. </seealso>
  223. </element>
  224. </module> <!-- resdatastream -->
  225. </package>
  226. </fpdoc-descriptions>