Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Singleton/Delphi/singleton.delphi
Normal file
40
Task/Singleton/Delphi/singleton.delphi
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