Declaration¶
Source position: resdatastream.pp line 67
type
TResourceDataStream = class(TStream)
protected
function GetPosition : Int64;
procedure SetPosition;
function GetSize : Int64;
procedure SetSize64;
public
constructor Create;
destructor Destroy;
function Compare : Boolean;
procedure SetCustomStream;
function Read : LongInt;
function Write : LongInt;
function Seek : Int64;
property Cached: Boolean; {rw}
end;
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 TResourceDataStream.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 |
|_______________________|_____________|______________________________|
Properties¶
| Member | Visibility | Description |
|---|---|---|
| Cached | public | Controls the copy-on-write behaviour of the stream |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| Compare | public | Compares the stream to another one |
| Create | public | Creates a new object |
| Destroy | public | |
| GetPosition | protected | |
| GetSize | protected | |
| Read | public | |
| Seek | public | |
| SetCustomStream | public | Sets a custom stream as the underlying stream |
| SetPosition | protected | |
| SetSize64 | protected | |
| Write | public |
See also¶
| Name | Description |
|---|---|
| TCachedDataStream | Base cached stream class |
| TResourceDataStream.Create | Creates a new object |
| TResourceDataStream.SetCustomStream | Sets a custom stream as the underlying stream |