unit Analyse.Implementations;
interface
uses
System.sysutils,
System.classes,
Analyse.Interfaces,
Analyse.Defaults;
// Hier definieren wir 2 Wrapper Kalssen für die Interfaces
type
TIMesswert =
class(TInterfacedObject, IMesswert)
private
FMesswert : TMesswert;
function GetBelastung: Double;
stdcall;
function GetInfo: WideString;
stdcall;
function GetStrom: Double;
stdcall;
procedure SetBelastung(
const Value: Double);
stdcall;
procedure SetInfo(
const Value: WideString);
stdcall;
procedure SetStrom(
const Value: Double);
stdcall;
protected
function getMesswert : TMesswert;
public
constructor Create(aMesswert : TMesswert);
destructor Destroy;
override;
end;
TIMesswertListWrapper =
class(TInterfacedObject, IMesswertList)
private
Flist : TMesswertListe;
function AddItem: IMesswert;
stdcall;
function GetCount: Integer;
stdcall;
function GetItem(
index : Integer): IMesswert;
stdcall;
function GetItemIndex( item : IMesswert): integer;
stdcall;
public
constructor Create(
const aList : TMesswertListe );
destructor Destroy;
override;
end;
implementation
function TIMesswert.GetBelastung: Double;
begin
Result := FMesswert.Belastung;
end;
function TIMesswert.GetStrom: Double;
begin
Result := FMesswert.Strom;
end;
procedure TIMesswert.SetBelastung(
const Value: Double);
begin
Fmesswert.Belastung := Value;
end;
procedure TIMesswert.SetStrom(
const Value: Double);
begin
FMesswert.Strom := Value;
end;
function TIMesswert.getMesswert: TMesswert;
begin
result := FMesswert;
end;
constructor TIMesswert.Create(aMesswert: TMesswert);
begin
inherited create;
FMesswert := aMesswert;
end;
destructor TIMesswert.Destroy;
begin
FMesswert :=
nil;
inherited;
end;
function TIMesswert.GetInfo: WideString;
begin
result := FMesswert.Info;
end;
procedure TIMesswert.SetInfo(
const Value: WideString);
begin
FMesswert.Info := Value;
end;
{ TIMesswertListWrapper }
constructor TIMesswertListWrapper.Create(
const aList: TMesswertListe);
begin
inherited Create;
Assert(Flist =
nil,'
Liste muss übergeben werden');
Flist := aList;
end;
destructor TIMesswertListWrapper.Destroy;
begin
flist :=
nil;
inherited;
end;
function TIMesswertListWrapper.AddItem: IMesswert;
var lMesswert : TMesswert;
begin
lMesswert := TMesswert.create;
Flist.add(lMesswert);
result := TIMesswert.Create(lMesswert);
end;
function TIMesswertListWrapper.GetCount: Integer;
begin
result := Flist.count;
end;
function TIMesswertListWrapper.GetItem(
index : Integer): IMesswert;
begin
// TODO -cMM: index prüfen
result := TIMesswert.Create(flist[
index]);
end;
function TIMesswertListWrapper.GetItemIndex(item : IMesswert): integer;
begin
// TODO -cMM: Gültigkeit von item prüfen
result := Flist.IndexOf((item
as TIMesswert).getmesswert);
end;
end.