83 lines
1.9 KiB
ObjectPascal
83 lines
1.9 KiB
ObjectPascal
unit Myc.Data.Types.Void;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils,
|
|
Myc.Data.Types;
|
|
|
|
type
|
|
// Implements a singleton data value representing void.
|
|
TImplDataVoidValue = class(TInterfacedObject, IDataVoidValue)
|
|
private
|
|
class var
|
|
FSingleton: IDataVoidValue;
|
|
class constructor CreateSingleton;
|
|
public
|
|
// IDataValue
|
|
function GetDataType: IDataType;
|
|
function GetAsString: string;
|
|
|
|
class property Singleton: IDataVoidValue read FSingleton;
|
|
end;
|
|
|
|
// Implements a singleton data type representing void.
|
|
TImplDataVoidType = class(TInterfacedObject, IDataVoidType)
|
|
private
|
|
class var
|
|
FSingleton: IDataVoidType;
|
|
class constructor CreateSingleton;
|
|
public
|
|
// IDataType
|
|
function GetName: String;
|
|
function GetKind: TDataKind;
|
|
|
|
// IDataVoidType
|
|
function GetValue: IDataVoidValue;
|
|
|
|
class property Singleton: IDataVoidType read FSingleton;
|
|
end;
|
|
|
|
implementation
|
|
|
|
class constructor TImplDataVoidValue.CreateSingleton;
|
|
begin
|
|
// Singleton instance created for the void value
|
|
FSingleton := TImplDataVoidValue.Create;
|
|
end;
|
|
|
|
function TImplDataVoidValue.GetAsString: string;
|
|
begin
|
|
Result := '(void)';
|
|
end;
|
|
|
|
function TImplDataVoidValue.GetDataType: IDataType;
|
|
begin
|
|
Result := TImplDataVoidType.Singleton;
|
|
end;
|
|
|
|
{ TImplDataVoidType }
|
|
|
|
function TImplDataVoidType.GetValue: IDataVoidValue;
|
|
begin
|
|
Result := TImplDataVoidValue.Singleton;
|
|
end;
|
|
|
|
class constructor TImplDataVoidType.CreateSingleton;
|
|
begin
|
|
// Singleton instance created for the void type
|
|
FSingleton := TImplDataVoidType.Create;
|
|
end;
|
|
|
|
function TImplDataVoidType.GetKind: TDataKind;
|
|
begin
|
|
Result := dkVoid;
|
|
end;
|
|
|
|
function TImplDataVoidType.GetName: String;
|
|
begin
|
|
Result := 'Void';
|
|
end;
|
|
|
|
end.
|