TCollection

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

Base class to manage collections of named objects.

Declaration

Source position: classesh.inc line 523

Type
  TCollection = class (TPersistent)
  private
    FItemClass : TCollectionItemClass;
    FItems : TFPList;
    FUpdateCount : Integer;
    FNextID : Integer;
    FPropName : string;
    function GetCount : Integer;
    function GetPropName : string;
    procedure InsertItem(Item: TCollectionItem);
    procedure RemoveItem(Item: TCollectionItem);
    procedure DoClear;
  protected
    function GetAttrCount : Integer;  Dynamic;
    function GetAttr(Index: Integer) : string;  Dynamic;
    function GetItemAttr(Index: Integer; ItemIndex: Integer) : string
                        ;  Dynamic;
    procedure Changed;
    function GetItem(Index: Integer) : TCollectionItem;
    procedure SetItem(Index: Integer; Value: TCollectionItem);
    procedure SetItemName(Item: TCollectionItem);  Virtual;
    procedure SetPropName;  Virtual;
    procedure Update(Item: TCollectionItem);  Virtual;
    procedure Notify(Item: TCollectionItem; Action: TCollectionNotification)
                    ;  Virtual;
    PropName : string;
    UpdateCount : Integer;
  public
    constructor Create(AItemClass: TCollectionItemClass);
    destructor Destroy;  Override;
    function Owner : TPersistent;
    function Add : TCollectionItem;
    procedure Assign(Source: TPersistent);  Override;
    procedure BeginUpdate;  Virtual;
    procedure Clear;
    procedure EndUpdate;  Virtual;
    procedure Delete(Index: Integer);
    function GetEnumerator : TCollectionEnumerator;
    function GetNamePath : string;  Override;
    function Insert(Index: Integer) : TCollectionItem;
    function FindItemID(ID: Integer) : TCollectionItem;
    procedure Exchange(const Index1: Integer; const index2: Integer);
    procedure Move(const Index1: Integer; const index2: Integer);
    procedure Sort(const Compare: TCollectionSortCompare);
    Count : Integer;
    ItemClass : TCollectionItemClass;
    Items[Index: Integer]: TCollectionItem;
  end
  ;

Description

TCollection implements functionality to manage a collection of named objects. Each of these objects needs to be a descendant of the TCollectionItem class. Exactly which type of object is managed can be seen from the TCollection.ItemClass property.

Normally, no TCollection is created directly. Instead, a descendants of TCollection and TCollectionItem are created as a pair.

Members

Member Type Visibility Description
Add Method public Creates and adds a new item to the collection.
Assign Method public Assigns one collection to another.
BeginUpdate Method public Start an update batch.
Changed Method protected Procedure called if an item is added to or removed from the collection.
Clear Method public Removes all items from the collection.
Count Property public Number of items in the collection.
Create Method public Creates a new collection.
Delete Method public Delete an item from the collection.
Destroy Method public Destroys the collection and frees all the objects it manages.
DoClear Method private
EndUpdate Method public Ends an update batch.
Exchange Method public Exchange 2 items in the collection
FindItemID Method public Searches for an Item in the collection, based on its TCollectionItem.ID property.
FItemClass Field private
FItems Field private
FNextID Field private
FPropName Field private
FUpdateCount Field private
GetAttr Method protected Returns an attribute of the collection.
GetAttrCount Method protected Returns the count of attributes associated with each item.
GetCount Method private
GetEnumerator Method public Create an IEnumerator instance
GetItem Method protected Read handler for the TCollection.Items property.
GetItemAttr Method protected Returns the attributes of an item.
GetNamePath Method public Overrides TPersistent.GetNamePath to return a proper pathname.
GetPropName Method private
Insert Method public Insert an item in the collection.
InsertItem Method private
ItemClass Property public Class pointer for each item in the collection.
Items Property public Indexed array of items in the collection.
Move Method public
Notify Method protected
Owner Method public Owner of the collection.
PropName Property protected Name of the property that this collection represents.
RemoveItem Method private
SetItem Method protected Write handler for the TCollection.Items property.
SetItemName Method protected Virtual method to set the name of the specified item
SetPropName Method protected Write handler for the TCollection.PropName]() property
Sort Method public Sort the items in the collection
Update Method protected Handler called when an item in the collection has changed.
UpdateCount Property protected

Inheritance

Class Description
TCollection Base class to manage collections of named objects.

See also

Name Description
Integer A signed 16-bits integer
Integer A signed 16-bits integer
Integer A signed 16-bits integer
Integer A signed 16-bits integer
TCollectionItem Basic object that is managed by a TCollection class.
TCollectionItem Basic object that is managed by a TCollection class.
TCollectionItemClass Class reference for TCollectionItem .
TCollectionItemClass Class reference for TCollectionItem .
TFPList Class to manage collections of pointers.