unit class_model;

interface

uses class_source, class_basics, Contnrs;

{$REGION 'ÊËÀÑÑ "ÌÎÄÅËÜ"'}
type
  TRDModel = class (TRD_Something)
    private

    public
      sources: TRDSource;

      constructor Create ( in_model_name, in_model_desc:string); override;
      destructor Destroy; override;
end;
{$ENDREGION}

type
  TRDModelList = class (TRD_List)
    private
      function set_current_model (in_model_index: integer): boolean;
    public
      function Find_by_name( in_object_name: string ): TRDModel;
      function Next_model: TRDModel;
      function Prev_model: TRDModel;
      function First_model: TRDModel;
      function Last_model: TRDModel;
      function Get_current_model: TRDModel;
      function Find_by_index (in_index: integer): TRDModel;
      function Add (in_model: TRDModel):integer; virtual;
end;


implementation
{$REGION 'ÊËÀÑÑ "ÌÎÄÅËÜ" ÐÅÀËÈÇÀÖÈß'}
constructor TRDModel.Create ( in_model_name, in_model_desc: string);
begin
Assert( ( in_model_name <> '' ),
        'Âõîäíîå ïîëå ÈÌß ÌÎÄÅËÈ êëàññà RDMODEL ïóñòîå!'+'{BC114396-B595-4724-A9F7-CD8141188280}');
  inherited Create(in_model_name, in_model_desc);
  self.sources := TRDSource.Create;
end;

destructor TRDModel.Destroy;
begin
  self.sources.Free;
  inherited Destroy;
end;

{$ENDREGION}

{ TRDModelList }

function TRDModelList.Add(in_model: TRDModel): integer;
var inserted_num: integer;
begin
  inserted_num := inherited add(in_model);
  self.set_current_model( inserted_num );
  result := inserted_num;
end;

function TRDModelList.Find_by_index(in_index: integer): TRDModel;
begin
  result := inherited Find_by_index( in_index ) as TRDModel;
end;

function TRDModelList.Find_by_name(in_object_name: string): TRDModel;
begin
result := inherited Find_by_name(in_object_name) as TRDModel;
end;

function TRDModelList.First_model: TRDModel;
begin
  result := inherited First_item as TRDModel;
end;

function TRDModelList.Get_current_model: TRDModel;
begin
  result := inherited Get_current_item as TRDModel;
end;

function TRDModelList.Last_model: TRDModel;
begin
  result := inherited Last_item as TRDModel;
end;

function TRDModelList.Next_model: TRDModel;
begin
  result := inherited Next_item as TRDModel;
end;

function TRDModelList.Prev_model: TRDModel;
begin
  result := inherited Prev_item as TRDModel;
end;

function TRDModelList.set_current_model(in_model_index: integer): boolean;
begin
  result := inherited set_current_item ( in_model_index );
end;

end.
