Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
40
Task/Singleton/Delphi/singleton.pas
Normal file
40
Task/Singleton/Delphi/singleton.pas
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
unit Singleton;
|
||||
|
||||
interface
|
||||
|
||||
type
|
||||
TSingleton = class
|
||||
private
|
||||
//Private fields and methods here...
|
||||
|
||||
class var _instance: TSingleton;
|
||||
protected
|
||||
//Other protected methods here...
|
||||
public
|
||||
//Global point of access to the unique instance
|
||||
class function Create: TSingleton;
|
||||
|
||||
destructor Destroy; override;
|
||||
|
||||
//Other public methods and properties here...
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TSingleton }
|
||||
|
||||
class function TSingleton.Create: TSingleton;
|
||||
begin
|
||||
if (_instance = nil) then
|
||||
_instance:= inherited Create as Self;
|
||||
|
||||
result:= _instance;
|
||||
end;
|
||||
|
||||
destructor TSingleton.Destroy;
|
||||
begin
|
||||
_instance:= nil;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue