"Persistent" in English means "stable", "constant". What is so constant in the class of the same name? The answer is this: virtual method procedure Assign(Source: TPersistent);.
This most important method copies the contents of one object (source) to another (self, that is, to the object that called the Assign method). In this case, the consumer object remains itself, which cannot be achieved by simply assigning variables of object type:
FirstObject: = SecondObject;
After all, in this case, a pointer to one region of the address space containing an instance of a class (object) is replaced by a pointer to another region of the address space that contains another object.
The Assign method allows you to duplicate an object by assigning values to one object for all the properties of another. Objects do not have to be of the same class; moreover, they do not have to be in a parent-child relationship. This method is so good that polymorphic assignment allows. Construction:
Allows you to copy the contents of a Picture to a Windows exchange folder (clipboard object). What's the logic here? It is known that in the exchange folder you can put a bitmap, text, metafile, multimedia data, etc. The Assign method of the TClipboard class is rewritten in such a way as to ensure the assignment (that is, the actual movement to the exchange folder) of all this data.
procedure TCiipboard.Assign(Source: TPersistent); begin if Source is TPicture then AssignPicture(TPicture(Source)) else if Source is TGraphic then AssignGraphic(TGraphic(Source)) else inherited Assign(Source); end;
To enable the descendants of the TPersistent class to interact with the development environment, use the following method:
function GetNamePath: string; dynamic;
It returns the name of the object to pass to the Object inspector.
To interact with threads when loading and saving components, use the following method:
procedure DefineProperties(Filer: TFiler); virtual;
The TPersistent class is never used directly, and it gives rise to descendants who must be able to pass the values of their properties to other objects, but are not components.