TResourceDataStream class
Stream class that provides copy-on-write functionality
Declaration
TResourceDataStream = class(TStream)Inheritance
Description
This class provides the copy-on-write mechanism of TAbstractResource.RawData, via more levels of indirection.
It uses an underlying stream, to which it redirects operations.
The underlying stream can be a TCachedDataStream descendant, a memory stream or a custom stream. Usually when a resource is loaded from a stream, the underlying stream is a 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 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.
As said before, third possibility is to have a custom stream as the underlying stream: a user can set this stream via TAbstractResource.SetCustomRawDataStream method, which in turn calls SetCustomStream
Figure: Levels of indirection
.
TResourceDataStream
|
_______________________|_______________________________
| | |
TMemoryStream TCachedDataStream descendant custom stream
/ \
_______________________|_____________|______________________________
| o r i g|i n a l s t|r e a m |
|_______________________|_____________|______________________________|See also
Properties
Cached | public | Controls the copy-on-write behaviour of the stream |
Methods
GetPosition | protected | |
SetPosition | protected | |
GetSize | protected | Return the size of the stream. |
SetSize64 | protected | |
Create | public | Creates a new object |
Destroy | public | TObject destructor. |
Compare | public | Compares the stream to another one |
SetCustomStream | public | Sets a custom stream as the underlying stream |
Read | public | Read data from stream to buffer. |
Write | public | Write a number of bytes to the stream. |
Seek | public | Set stream position. |
Inherited
From TObject (40)
AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
