TObject/fi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TObject/fi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **`TObject`** on kantaluokka kaikille [[Class/fi|luokille ( class )]] , riippumatta siitä onko niin määritelty tai ei. Siinä on erittäin yleisiä [[Method/fi|metodeita]], pääosin [[virtual/fi|virtuaalisia (virtual )]]. Peruste `TObject`:lle on, että [[Object Pascal/fi|Object Pascalissa]] jokainen luokka on johdettu toisesta luokasta, ja `TObject` on poikkeus, joka päättää tämän ketjun. | |
| 2 | + | ||
| 3 | + | [[Constructor/fi|Rakentaja constructor]] `TObject.Create()`, on kaikkien muiden luokkien oletuksena perimä. Se voidaan piilottaa tekemällä toinen rakentaja, jolla on sama nimi johdetussa luokassa joko parametreilla tai ilman niitä. Tämä on kätevä [[Singleton pattern|Singleton-mallin]] toteuttamisessa. | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | { Määritelty tiedostossa 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/fi", as it stood on 2019-11-15 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).* |
