| destructor Destroy;override;
end;
var
FooMan:TFooManager;
implementation
{ TFooManager }
constructor TFooManager.Create;
begin
FooNum:=0;
end;
function TFooManager.CreateAFoo: IFoo;
begin
inc(FooNum);
if length(FList)<FooNum then
setlength(FList,FooNum*2);
FList[FooNum-1]:=TFoo.Create;
result:=FList[FooNum-1] as IFoo;
end;
procedure TFooManager.DelAFoo(id:integer);
var
i:integer;
begin
if FooNum>0 then
begin
FList[id].Free;
for i:=id to FooNum-2 do
begin
FList[i]:=FList[i+1];
end;
FList[FooNum-1]:=nil;
Dec(FooNum);
end;
end;
destructor TFooManager.Destroy;
//在释放工厂类前释放所有所维护的对象
var
i:integer;
begin
for i:=0 to FooNum-1 do
上一页 [1] [2] [3] 下一页 |