classwork.ppIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers Classes hierarchy graph
|
Class AnObjectListItem
Unit
classwork
Declaration
type AnObjectListItem = class(ANode)
Description
This class represents a single entry in AnObjectList. It extends ANode to allow it to hold an instance of TObject or one of its descendants. It also provides a flag that allows the list entry to free the object to which it refers when the entry itself is freed.
Hierarchy
Overview
Fields
Methods
Description
Fields
|
MyReference: TObject; |
Refers to the object referenced by the item
|
|
myOwnReference: boolean; |
Indicates whether or not the item owns its reference
|
Methods
|
constructor withReference(const ThisReference: TObject; const takeOwnershipOfReference: boolean = false); virtual; |
Construct a new list item that refers to the specified object.
If takeOwnershipOfObject is True , then the list item will assume ownership of ThisReference and, when the list item is freed, it will call TObject.free on ThisReference .
|
|
function init: boolean; override; |
Initializer
|
|
destructor destroy; override; |
Destroy the list item.
If Self.ownsReference is True and Self.Reference refers to a valid instance of TObject , then this method will free that reference before calling the inherited routine.
|
|
function Find(const ThisReference: TObject): AnObjectListItem; virtual; |
Search the node, its children, and its older siblings for the specified value.
This method performs a sequential search through each node and so can be inefficient for large lists. It begins by recursively calling itself on any older siblings. If the value is not found, then it searches the current node and its children.
If this method is called on the last item in APointerList, it will result in the entire list being searched.
Returns
A reference to the first node that contains the specified pointer value, if found; Nil if the value was not found. |
|
function selfStreamingLength: TStreamIOSize; override; |
Calculate the number of bytes required to stream the node, and just the node.
This method builds upon the behavior inherited from ANode.selfStreamingLength: it calls the inherited routine, then checks to see whether Self.Reference is valid (not Nil ) and whether it implements CanStream. If both are true, this method calls Self.Reference.streamingLength and adds the result of that call to the total returned.
|
|
function writeSelfTo(const Dest: AStream): TStreamIOSize; override; |
Write the node, and just the node, to the specified stream. For more information on this method, see ANode.writeSelfTo.
This method checks to see whether Self.Reference is valid (not Nil ) and whether it implements CanStream. If both are true, then it calls Self.Reference.writeTo.
The inherited routine is called in any case.
Returns
The total number of bytes written to Dest . |
|
function shallowCopyFrom(const Other: AnObject): boolean; override; |
Construct a shallow copy of the other object.
This method overrides the behavior inherited from AnObject.shallowCopyFrom: it calls that method, then checks to see whether Other is an instance of AnObjectListItem. If so, it copies the value of AnObjectListItem.ownsReference from Other to Self , overwriting the value in Self .
Note that this method does NOT copy any sibling or child nodes and so cannot be used to create a full copy of any descendant of ANode. The copy will NOT be automatically placed in the list to which Other belongs, if any, but the caller is free to do so.
|
|
function toString: AnsiString; override; |
Construct and return a string representation of the node.
If AnObjectListItem.Reference Self.Reference is not Nil , and the object indicated by the reference implements CanPrint, then this method will call Self.Reference.toString and return the result. Otherwise, it returns a string representation of Self.Reference, using plitStringRepresentation to control the format of the string.
|
|
function Reference: TObject; virtual; overload; |
Retrieve the object reference associated with the node.
|
|
function SetReference(const NewReference: TObject): TObject; virtual; overload; |
Set the object reference associated with the node.
Returns
The old reference associated with the node. |
|
function ownsReference: boolean; virtual; |
Determine whether or not the list item assumes ownership of its reference.
If this method returns True , then the list item will call TObject.free to free its reference when the item itself is destroyed. This behavior can be changed by calling AnObjectListItem.setOwnsReference.
|
|
function setOwnsReference(const flag: boolean): boolean; virtual; |
Set whether or not the list item assumes ownership of its reference.
If flag is True , then the list item will call TObject.free to free its reference when the item itself is destroyed. Otherwise, the object will not be freed when the list item is freed.
Returns
The previous value of AnObjectListItem.ownsReference. |
Generated by PasDoc 0.13.0 on 2015-06-23 19:40:11
|