1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| {================================================================
TMFiler +
================================================================}
constructor TMFiler.Create(AList:TCustomList);
begin
if Assigned(AList) then
FMParams := AList;
end;
procedure TMFiler.Read(var AItem);
begin
with FMParams do
System.Move(Pointer(List[FIndex])^, AItem, Alloc);
end;
procedure TMFiler.Write(const AItem);
begin
with FMParams do
System.Move(AItem, Pointer(List[FIndex])^, Alloc);
end;
{================================================================
TMethodeParams +
================================================================}
constructor TCustomList.Create(AllocBy :integer);
begin
if AllocBy in [1..255] then
FAlloc :=AllocBy
else
raise Exception.Create('');
FMFiler :=TMFiler.Create(Self);
FList:=TList.Create;
end;
destructor TCustomList.Destroy();
begin
Clear();
FList.Free;
inherited;
end;
procedure TCustomList.Change();
begin
if not FUpdate then
try
if Assigned(FOnChange) then
FOnChange(Self);
finally
FChanged :=false;
end
else
FChanged :=true;
end;
procedure TCustomList.BeginUpdate();
begin
FUpdate:=true;
end;
procedure TCustomList.EndUpdate();
begin
FUpdate:=false;
Change();
end;
procedure TCustomList.Delete(idx:integer);
begin
dispose(FList[idx]);
FList.Delete(idx);
Change();
end;
procedure TCustomList.Add(const AItem);
var
NewItem:Pointer;
begin
GetMem(NewItem,FAlloc);
System.Move(AItem, Pointer(NewItem)^, FAlloc);
FList.Add(NewItem);
Change();
end;
procedure TCustomList.Clear();
var
i:integer;
begin
for i:= 0to FList.Count-1 do
try
FreeMem(FList[i]);
except
end;
if FList.Count <>0 then
FList.Clear();
Change();
end;
function TCustomList.Count:Integer;
begin
result:=FList.Count;
end
;
function TCustomList.Get(idx:integer):TMFiler;
begin
FMFiler.Idx:=idx;
result:= FMFiler;
end; |
Partager