Skip to content

TPersistent

[Properties (by Name)][Methods (by Name)][Events (by Name)]

Base class for streaming system and persistent properties.

Declaration

Source position: classesh.inc line 430

Type
  TPersistent = class (TObject, IFPObserved)
  private
    FObservers : TFPList;
    procedure AssignError(Source: TPersistent);
  protected
    procedure AssignTo(Dest: TPersistent);  Virtual;
    procedure DefineProperties(Filer: TFiler);  Virtual;
    function GetOwner : TPersistent;  Dynamic;
  public
    destructor Destroy;  Override;
    procedure Assign(Source: TPersistent);  Virtual;
    procedure FPOAttachObserver(AObserver: TObject);
    procedure FPODetachObserver(AObserver: TObject);
    procedure FPONotifyObservers(ASender: TObject; 
                                AOperation: TFPObservedOperation; 
                                Data: Pointer);
    function GetNamePath : string;  Virtual;
  end
  ;

Description

TPersistent is the basic class for the streaming system. Since it is compiled in the {$M+} state, the compiler generates RTTI (Run-Time Type Information) for it and all classes that descend from it. This information can be used to stream all properties of classes.

It also introduces functionality to assign the contents of 2 classes to each other.

TPersistent implements the IFPObserved interface for the benefit of descendant classes, but does not call IFPObserved.FPONotifyObservers . Descendants such as TStrings and TCollection and TCollectionItem do use it.

Members

Member Type Visibility Description
Assign Method public Assign the contents of one class to another.
AssignError Method private Raises an EConvertError when an error occurs during assignment.
AssignTo Method protected Generic assignment function.
DefineProperties Method protected Declare non-published properties that need to be streamed.
Destroy Method public Destroys the TPersistent instance.
FObservers Field private
FPOAttachObserver Method public Add an observer to the list of observers.
FPODetachObserver Method public Remove an observer from the list of observers
FPONotifyObservers Method public Notify observers of changes.
GetNamePath Method public Returns a string that can be used to identify the class instance.
GetOwner Method protected Returns the owner of the component.

Inheritance

Class Description
TPersistent(IFPObserved) Base class for streaming system and persistent properties.

See also

Name Description
IFPObserved Interface implemented by an object that can be observed.
TCollection Base class to manage collections of named objects.
TCollectionItem Basic object that is managed by a TCollection class.
TComponent Base class for all components that need owner-owned functionality.
TFPList Class to manage collections of pointers.
TStrings Class to manage arrays or collections of strings