Sign in Join
FPDoc Onlineexperiment

TAbstractResource class

In unit resource

Base abstract resource class

Declaration

pascal
TAbstractResource = class

Descends from it: TAcceleratorsResource TBitmapResource TGenericResource TGroupResource TStringTableResource TVersionResource

Description

This is the base class that represents a resource.

A resource is identified by its type, name and language ID even if some file formats or operating systems don't consider the latter.

There are also additional properties that aren't always present in all file formats, so their values aren't always meaningful: however, they can be used to display detailed information when possible.

Every resource has a RawData stream that holds resource data. This stream uses a copy-on-write mechanism: if the resource has been read from a stream or file, RawData redirects read operations to the original stream. This is particularly useful when a resource file must be converted from a format to another, or when more resource files must be merged, since (potentially large) resource data is directly copied from the original to the destination stream without the need of allocating a lot of memory.

When resource data is encoded in a resource-specific format, RawData can be uncomfortable: it's often better to use a more specialized descendant class that provides additional properties and methods.

Resources cannot be read or written alone from/to a stream: they need to be contained in a TResources object, which represents an abstract view of a resource file.

Usually each descendant registers itself with TResourceFactory class in the initialization section of the unit in which it is implemented: this way TResourceFactory class can know which class to use to instantiate a resource of a given type.

An object of this class should never be directly instantiated: use a descendant class instead.

See also

Properties

_TypepublicThe type of the resource
NamepublicThe name of the resource
LangIDpublicThe language ID of the resource
DataSizepublicThe size of resource raw data
HeaderSizepublicThe size of resource header
DataVersionpublicThe version of the resource data
MemoryFlagspublicThe memory flags of the resource
VersionpublicA user defined version number
CharacteristicspublicA user defined piece of data
DataOffsetpublicThe offset of resource data from the beginning of the stream
CodePagepublicThe code page of the resource
RawDatapublicThe raw resource data stream
CacheDatapublicControls the copy-on-write behaviour of the resource
OwnerListpublicThe resource list that owns this resource
OwnerpublicThe owner of this resource

Methods

SetDescOwnerprotectedSets this resource as the owner of the given TResourceDesc
SetOwnerListprotectedProtected method to let a resource list set itself as the owner of the resource
SetChildOwnerprotectedProtected method to let a resource set itself as the owner of a sub-resource
GetTypeprotectedReturns the type of the resource
GetNameprotectedReturns the name of the resource
ChangeDescTypeAllowedprotectedReports whether changing the type of resource type or name is allowed
ChangeDescValueAllowedprotectedReports whether changing the value of resource type or name is allowed
NotifyResourcesLoadedprotectedTells the resource that all resources have been loaded
CreateprotectedCreates a new resource
DestroypublicDestroys the object
CompareContentspublicCompares the contents of the resource to the contents of another one
UpdateRawDatapublicUpdates RawData stream.
SetCustomRawDataStreampublicSets a custom stream as the underlying stream for RawData

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.