TAbstractResource class
Base abstract resource class
Declaration
TAbstractResource = classDescends 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.
See also
- TGenericResource
- TAcceleratorsResource
- TBitmapResource
- TGroupCursorResource
- TGroupIconResource
- TStringTableResource
- TVersionResource
- TResources
- TResourceFactory
Properties
_Type | public | The type of the resource |
Name | public | The name of the resource |
LangID | public | The language ID of the resource |
DataSize | public | The size of resource raw data |
HeaderSize | public | The size of resource header |
DataVersion | public | The version of the resource data |
MemoryFlags | public | The memory flags of the resource |
Version | public | A user defined version number |
Characteristics | public | A user defined piece of data |
DataOffset | public | The offset of resource data from the beginning of the stream |
CodePage | public | The code page of the resource |
RawData | public | The raw resource data stream |
CacheData | public | Controls the copy-on-write behaviour of the resource |
OwnerList | public | The resource list that owns this resource |
Owner | public | The owner of this resource |
Methods
SetDescOwner | protected | Sets this resource as the owner of the given TResourceDesc |
SetOwnerList | protected | Protected method to let a resource list set itself as the owner of the resource |
SetChildOwner | protected | Protected method to let a resource set itself as the owner of a sub-resource |
GetType | protected | Returns the type of the resource |
GetName | protected | Returns the name of the resource |
ChangeDescTypeAllowed | protected | Reports whether changing the type of resource type or name is allowed |
ChangeDescValueAllowed | protected | Reports whether changing the value of resource type or name is allowed |
NotifyResourcesLoaded | protected | Tells the resource that all resources have been loaded |
Create | protected | Creates a new resource |
Destroy | public | Destroys the object |
CompareContents | public | Compares the contents of the resource to the contents of another one |
UpdateRawData | public | Updates RawData stream. |
SetCustomRawDataStream | public | Sets a custom stream as the underlying stream for RawData |
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
