Class AnObject

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AnObject = class(TObject)

Description

This class extends TObject to provide some additional functionality reminiscent of that provided by the base Object class in Objective C.

Hierarchy

  • TObject
  • AnObject

Overview

Methods

Public constructor new; virtual;
Public constructor alloc; virtual;
Public class function shallowCopyOf(const Other: AnObject): AnObject; virtual;
Public function init: boolean; virtual;
Public destructor destroy; override;
Public function isKindOf(ClassObject: TClass): boolean; virtual;
Public class function isKindOf(thisClassName: string): boolean; virtual;
Public class function respondsTo(thisMethodName: string): boolean; virtual;
Public class function implements(interfaceName: string): boolean; virtual;
Public function shallowCopyFrom(const Other: AnObject): boolean; virtual;
Public function name: string; virtual;

Description

Methods

Public constructor new; virtual;

Create and initialize new instance of the object.

This method is called after the instance is constructed. It automatically calls AnObject.init to perform initialization of the object. If AnObject.init returns False, indicating that initialization failed, then this routine will throw an exception.

Exceptions raised
AnException
if AnObject.init returns False when called from this method.
Public constructor alloc; virtual;

Create a new instance of the object.

This method is called after the instance is constructed. It does not call AnObject.init to perform initialization of the new instance. In fact, in the base implementation, it does nothing. Descendant classes may override this method – but probably won't.

Public class function shallowCopyOf(const Other: AnObject): AnObject; virtual;

Construct a shallow copy of the given object.

This method calls TObject.ClassType on Other, then uses the class reference returned to construct a new instance that is of the same type as Other. It then calls AnObject.shallowCopyFrom on the new instance.

If Other is Nil, this method does nothing and returns Nil.

Exceptions raised
AnException
if AnObject.init returns False when called from this method.
Public function init: boolean; virtual;

Initialize a new instance of the class.

This method will be overridden by descendants of AnObject, where it will be used to initialize the various members of the class. If one or more of these methods cannot be initialized for some reason, the method may return False to indicate failure. If the method was called by AnObject.new, then an exception will be raised because of this failure.

The default implementation of this method always returns True.

Public destructor destroy; override;

Destroy the instance.

This method is automatically called by TObject.free and need never be called directly. It is included here for the sake of completeness.

Public function isKindOf(ClassObject: TClass): boolean; virtual;

Determine whether the class is an instance of the one specified.

Internally, this method simply uses the is operator to determine whether the present instance is related to the specified ClassObject. It will return True if the instance is a descendant of ClassObject or one of ClassObject's descendants; otherwise, it returns False.

Public class function isKindOf(thisClassName: string): boolean; virtual;

Determine whether the class is an instance of the one specified.

This method allows you to determine whether the current instance is related to the one specified by specifying the name of the class as a string rather than a type. Internally, the method searches backwards through the class hierarchy, beginning with the present class instance. If one of the parent classes encountered has thisClassName, then the method will return True. Otherwise, it returns False.

Public class function respondsTo(thisMethodName: string): boolean; virtual;

Determine whether the class implements the given method.

This method simply calls TObject.methodAddress to determine whether the method table contains a valid method with thisMethodName. If so, it returns True; otherwise, it returns False.

Public class function implements(interfaceName: string): boolean; virtual;

Determine whether the class implements the given interface.

This method allows you to determine whether the current instance is part of a class that implements a given interface. Internally, the method searches backwards through the class hierarchy, beginning with the current instance, and searches for interfaceName within the interface table of each class. If interfaceName is found, then the method returns True; otherwise, it returns False.

interfaceName will represent the canonical name of the interface, if you are compiling code using Free Pascal's INTERFACES CORBA directive; otherwise, it must be the GUID of the interface that is sought.

Public function shallowCopyFrom(const Other: AnObject): boolean; virtual;

Make a shallow copy of the data from Other, assigning it to the current object.

The base implementation of this method does nothing except compare whether Self and Other are compatible. Descendant classes may override this method to allow certain data to be copied between object instances.

Returns

True if the data was copied successfully; False if not. Both Self and Other must be descendants of the same class in order for the copy to succeed.

Public function name: string; virtual;

Retrieves the name of the class.

The base implementation of this method simply calls TObject.className and returns the resulting string. Descendant classes may override this method to produce different results; for instance, AFileStream overrides it to return the name of the file being streamed.


Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18