unit fwObjectlist;

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

interface

uses ContNrs,

     fwObject;

type
  TfwObjectList    = class(TObjectlist)
  protected
    function  GetItem(aIndex : Integer) : TfwObject;
    procedure SetItem(aIndex : Integer; aItem : TfwObject);
  public
    constructor Create; overload;
    constructor Create(AOwnsObjects: Boolean); overload;
    procedure Init; virtual;
    function FindByID(aID : Integer) : TfwObject;
    property Items[aIndex : Integer] : TfwObject read GetItem write SetItem; default;
  end;

implementation

// -----------------------------------------------------------------------
// fwObjectList
// -----------------------------------------------------------------------
function TfwObjectList.GetItem(aIndex : Integer) : TfwObject;
begin
  Result := (inherited Items[aIndex] as TfwObject);
end;

procedure TfwObjectList.SetItem(aIndex : Integer; aItem : TfwObject);
begin
  inherited Items[aIndex] := aItem;
end;

constructor TfwObjectList.Create;
begin
  inherited Create;

  Init();
end;

constructor TfwObjectList.Create(AOwnsObjects: Boolean);
begin
  inherited Create(AOwnsObjects);

  Init();
end;

procedure TfwObjectList.Init;
begin
end;

function TfwObjectList.FindByID(aID : Integer) : TfwObject;
var
  iLoop            : Integer;
begin
  Result := nil;

  for iLoop := 0 to Pred(Count) do begin
    if (Items[iLoop].ID = aID) then begin
      Result := Items[iLoop];
      Break;
    end;
  end;
end;

end.
