unit Programm;
interface
uses
SysUtils, ExtCtrls, Rezept, Schritt,
Vcl.Forms, Observer, KProgrammView, MProgrammView;
type
TProgrammModel<T: TSchritt> =
class
public
Rezept: TRezept<T>;
// Rezept: TKRezept; // So geht es, generisch nicht!
constructor Create
{(AOwner: TComponent)};
End;
TProgrammAdapter<T: TSchritt> =
class(TInterfacedObject, IProgrammAdapter)
private
Model: TProgrammModel<T>;
IView: IProgrammView;
public
Notifier: TObserverSubject;
constructor Create(AOwner: TComponent; IAView: IProgrammView; AModel: TProgrammModel<T>);
procedure WriteToStream(Sender: TObject);
procedure ReadCSV(Filename:
String);
procedure ScaleIngredients(Percent: Integer);
function GetRecipeName:
String;
function GetRecipeFilename:
String;
procedure SetRecipe(ARezept: TRezept<T>);
End;
implementation
constructor TProgrammAdapter<T>.Create(AOwner: TComponent; IAView: IProgrammView; AModel: TProgrammModel<T>);
begin
IView := IAView;
Steps := IView.GetSteps;
Model := AModel;
end;
procedure TProgrammAdapter<T>.ReadCSV(Filename:
String);
begin
// if Model.Rezept <> nil then
// Model.Rezept.Free;
// if TypeInfo(T) = TypeInfo(TKSchritt) then
// Model.Rezept := TRezept<TKSchritt>.Create
// else if TypeInfo(T) = TypeInfo(TMSchritt) then
// Model.Rezept := TRezept<TMSchritt>.Create;
Model.Rezept.ReadCSV(Filename);
// Abstrakter Fehler!
end;