TObject: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TObject
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **`TObject`** is the base [[Class|class]] for any other `class`, whether you declare it or not. It provides only some very generic [[Method|methods]], mostly [[virtual]]. The rationale for `TObject` is that in [[Object Pascal]] every `class` must be derived from another, `TObject` being the exception that ends the derivation chain. | |
| 2 | + | ||
| 3 | + | The [[Constructor|constructor]] `TObject.Create()`, inherited by every other `class` by default, can be hidden declaring another `constructor` with the same name in the derived `class`, with or without parameters. This come handy implementing the [[Singleton pattern]]. | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | { Defined in objpash.inc } | |
| 7 | + | ||
| 8 | + | constructor Create; | |
| 9 | + | destructor Destroy; virtual; | |
| 10 | + | class function newinstance : tobject; virtual; | |
| 11 | + | procedure CleanupInstance; | |
| 12 | + | procedure FreeInstance; virtual; | |
| 13 | + | ||
| 14 | + | function SafeCallException(exceptobject : tobject; exceptaddr : codepointer) : HResult; virtual; | |
| 15 | + | procedure DefaultHandler(var message);virtual; | |
| 16 | + | procedure Free; | |
| 17 | + | ||
| 18 | + | class function InitInstance(instance : pointer) : tobject; | |
| 19 | + | class function ClassType : tclass; | |
| 20 | + | class function ClassInfo : pointer; | |
| 21 | + | class function ClassName : shortstring; | |
| 22 | + | class function ClassNameIs(const name : string) : boolean; | |
| 23 | + | class function ClassParent : tclass; | |
| 24 | + | class function InstanceSize : SizeInt; | |
| 25 | + | class function InheritsFrom(aclass : tclass) : boolean; | |
| 26 | + | class function StringMessageTable : pstringmessagetable; | |
| 27 | + | class function MethodAddress(const name : shortstring) : codepointer; | |
| 28 | + | class function MethodName(address : codepointer) : shortstring; | |
| 29 | + | function FieldAddress(const name : shortstring) : pointer; | |
| 30 | + | ||
| 31 | + | procedure AfterConstruction;virtual; | |
| 32 | + | procedure BeforeDestruction;virtual; | |
| 33 | + | ||
| 34 | + | procedure DefaultHandlerStr(var message);virtual; | |
| 35 | + | ||
| 36 | + | procedure Dispatch(var message);virtual; | |
| 37 | + | procedure DispatchStr(var message);virtual; | |
| 38 | + | ||
| 39 | + | function GetInterface(const iid : tguid; out obj) : boolean; | |
| 40 | + | function GetInterface(const iidstr : shortstring;out obj) : boolean; | |
| 41 | + | function GetInterfaceByStr(const iidstr : shortstring; out obj) : boolean; | |
| 42 | + | function GetInterfaceWeak(const iid : tguid; out obj) : boolean; | |
| 43 | + | ||
| 44 | + | class function GetInterfaceEntry(const iid : tguid) : pinterfaceentry; | |
| 45 | + | class function GetInterfaceEntryByStr(const iidstr : shortstring) : pinterfaceentry; | |
| 46 | + | class function GetInterfaceTable : pinterfacetable; | |
| 47 | + | ||
| 48 | + | class function UnitName : ansistring; | |
| 49 | + | function Equals(Obj: TObject) : boolean; virtual; | |
| 50 | + | function GetHashCode: PtrInt; virtual; | |
| 51 | + | function ToString: ansistring; virtual; | |
| 52 | + | ``` | |
| 53 | + | ||
| 54 | + | --- | |
| 55 | + | *From the Free Pascal wiki, page "TObject", as it stood on 2019-11-13 after a change by Djzepi, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
