Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
Re: XML-Struktur in Objekte verwalten
24. Aug 2008, 00:00

Zitat von Yheeky:
...wenn ich die beiden Klassen ... in zwei Units auslagere, dass ich "keine Zirkuläre Unit-Referenz" haben darf ...
NodeTypeU:
Delphi-Quellcode:
unit NodeTypeU;
interface
type
TNodeCustom = class
end;
implementation
end.
NodeListU:
Delphi-Quellcode:
unit NodeListU;
interface
uses Classes, NodeTypeU;
type
TNodeList = class
private
FNodes: TList;
public
constructor create;
destructor destroy; override;
procedure Clear;
procedure addNode(Node:TNodeCustom);
end;
implementation
{ TNodeList }
constructor TNodeList.create;
begin
FNodes:=TList.Create;
end;
destructor TNodeList.destroy;
begin
Clear;
FNodes.free;
inherited;
end;
procedure TNodeList.Clear;
var i:integer;
ItemObject:TObject;
begin
for i:=1 to FNodes.Count do begin
ItemObject:=FNodes[i-1];
ItemObject.free;
end;
FNodes.Clear;
end;
procedure TNodeList.addNode(Node: TNodeCustom);
begin
FNodes.Add(Node);
end;
end.
NodeU:
Delphi-Quellcode:
unit NodeU;
interface
uses NodeTypeU, NodeListU;
type
TNode = class(TNodeCustom)
private
FChildNodes:TNodeList;
public
constructor create;
destructor destroy; override;
procedure addChild(Node:TNode);
end;
implementation
{ TNode }
constructor TNode.create;
begin
FChildNodes:=TNodeList.create;
end;
destructor TNode.destroy;
begin
FChildNodes.free;
inherited;
end;
procedure TNode.addChild(Node: TNode);
begin
FChildNodes.addNode(Node);
end;
end.
|
|
Zitat
|