Processor-Result
This commit is contained in:
+15
-10
@@ -30,25 +30,30 @@ type
|
||||
end;
|
||||
|
||||
IMycProcessor<T> = interface
|
||||
procedure ProcessData(const Value: T);
|
||||
function ProcessData(const Value: T): Boolean;
|
||||
end;
|
||||
|
||||
TMycGenericProcessor<T> = class(TInterfacedObject, IMycProcessor<T>)
|
||||
TMycProcessor<T> = class abstract(TInterfacedObject, IMycProcessor<T>)
|
||||
protected
|
||||
function ProcessData(const Value: T): Boolean; virtual; abstract;
|
||||
end;
|
||||
|
||||
TMycGenericProcessor<T> = class(TMycProcessor<T>)
|
||||
type
|
||||
TProc = reference to procedure(const Value: T);
|
||||
TProc = reference to function(const Value: T): Boolean;
|
||||
private
|
||||
FProc: TProc;
|
||||
procedure ProcessData(const Value: T);
|
||||
function ProcessData(const Value: T): Boolean; override;
|
||||
public
|
||||
constructor Create(const AProc: TProc);
|
||||
end;
|
||||
|
||||
TMycContainedProcessor<T> = class(TContainedObject, IMycProcessor<T>)
|
||||
type
|
||||
TProc = procedure(const Value: T) of object;
|
||||
TProc = function(const Value: T): Boolean of object;
|
||||
private
|
||||
FProc: TProc;
|
||||
procedure ProcessData(const Value: T);
|
||||
function ProcessData(const Value: T): Boolean;
|
||||
public
|
||||
constructor Create(const Controller: IInterface; const AProc: TProc);
|
||||
end;
|
||||
@@ -420,9 +425,9 @@ begin
|
||||
FProc := AProc;
|
||||
end;
|
||||
|
||||
procedure TMycGenericProcessor<T>.ProcessData(const Value: T);
|
||||
function TMycGenericProcessor<T>.ProcessData(const Value: T): Boolean;
|
||||
begin
|
||||
FProc(Value);
|
||||
Result := FProc(Value);
|
||||
end;
|
||||
|
||||
constructor TMycContainedProcessor<T>.Create(const Controller: IInterface; const AProc: TProc);
|
||||
@@ -431,9 +436,9 @@ begin
|
||||
FProc := AProc;
|
||||
end;
|
||||
|
||||
procedure TMycContainedProcessor<T>.ProcessData(const Value: T);
|
||||
function TMycContainedProcessor<T>.ProcessData(const Value: T): Boolean;
|
||||
begin
|
||||
FProc(Value);
|
||||
Result := FProc(Value);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@@ -436,7 +436,9 @@ begin
|
||||
DataFile.Chain(
|
||||
function(const Data: TArray<TDataPoint<T>>): TState
|
||||
begin
|
||||
Processor.ProcessData(Data);
|
||||
if not Processor.ProcessData(Data) then
|
||||
exit( TState.Null );
|
||||
|
||||
Result := ProcessFile(nextFileInfo, nextFile, cTerminated, Processor);
|
||||
end
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user