Defines a TCollectionItem descendant that can refer to other collection items (TGCollectionItem) and notify them when it is destroyed. This class can only notify other TGCollectionItem classes. This class is similar to TComponent, which allows other TComponents to be informed when a component is removed.
Namespace: Structures
TCollectionItem
Structures.TGCollectionItem
|
Delphi
|
type
TGCollectionItem = class(TCollectionItem)
end;
|
|
Name
|
Description
|
|
Notifications
|
Contains the list of collection item objects that need to be notified when this item is freed
|
Top
|
|
Name
|
Description
|
|
FreeNotification(TGCollectionItem)
|
Ensures that Item is notified that the collection item is going to be destroyed. Use FreeNotification to register Item as a collection item that should be notified when the current collection item is about to be destroyed.
|
|
Notification(TGCollectionItem)
|
The Notification method is called when the object specified by the Item parameter is being destroyed.
Do not call the Notification method in an application. Notification is called automatically when the collection item specified by Item is about to be deleted.
A collection item can, if needed, act on the notification that a collection item is being removed. For example, if a collection has object fields or properties that contain references to other collection items, it can check the notifications of collection item removals and invalidate those references as needed.
|
|
NotifyAll
|
Notify all other TGCollectionItem objects that this object is being freed
|
|
RemoveFreeNotification(TGCollectionItem)
|
Disables destruction notification that was enabled by FreeNotification. RemoveFreeNotification removes the collection item specified by the Item parameter from the internal list of objects to be notified that the collection item is about to be destroyed. Item is added to this list by a previous call to the FreeNotification method.
|
|
RemoveNotification(TGCollectionItem)
|
Remove the collection item from the list of items to be notified if this object is freed.
|
Top
|
To use the class, descend from TGCollectionItem:
Delphi
|
TIEESFactSlotItem = class(TGCollectionItem)
{ Purpose: To define a fact slot item, for either a fact or rule pattern }
private
{ Private declarations }
protected
{ Protected declarations }
procedure Notification( Item: TGCollectionItem ); override;
public
{ Public declarations }
published
{ Published declarations }
end; { TIEESFactSlotItem }
|
To be informed if another TGCollectionItem is freed, call the FreeNotification method of the other collection item:
Delphi
if SlotType <> nil then SlotType.FreeNotification(Self);
If you don't wish to be informed anymore, call the RemoveFreeNotification method:
Delphi
if SlotType <> nil then SlotType.RemoveFreeNotification(Self);
Finally, you need to override the Notification method to respond when the other collection item is freed. (The Notification method is protected):
Delphi
procedure TIEESTemplateSlotItem.Notification(Item: TGCollectionItem);
begin
inherited Notification(Item);
if Item = FSlotType then
SlotType := nil;
end;