{
===============================================================================
  Copyright (©) 2003. Rodax Software.
===============================================================================
  Los contenidos de este fichero son propiedad de Rodax Software titular del
  copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
  en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
  acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
  bajo el que se suministra.
  -----------------------------------------------------------------------------
  Web:  www.rodax-software.com
===============================================================================
  Fecha primera versión: 25-05-2003
  Versión actual: 1.0.0
  Fecha versión actual: 25-05-2003
===============================================================================
  Modificaciones:

    Fecha         Comentarios
    ---------------------------------------------------------------------------
===============================================================================
}
unit Framework;

{$I COMPILE.INC}

interface

uses
  Classes, Contnrs;

type
  TObjeto = class(TPersistent)
  protected
    procedure SalvarDatos; virtual;
    procedure ObtenerDatos; virtual; abstract;
    procedure AssignError(Source: TPersistent);
    procedure AssignTo(Dest: TPersistent); override;
  public
    constructor Create; virtual;
    destructor Destroy; override;
  end;

  TListaObjetos = class(TPersistent)
  protected
    FLista : TObjectList;
    function GetCount : Integer;
    procedure ObtenerLista; virtual; abstract;
    procedure AssignError(Source: TPersistent);
    procedure AssignTo(Dest: TPersistent); override;
  public
    function Add(AObjecto: TObjeto): Integer;
    procedure Clear;
    procedure Delete(Index: Integer);
    property Count : Integer read GetCount;
    constructor Create; virtual;
    destructor Destroy; override;
  end;

implementation

uses
  SysUtils
  {$IFDEF RDX_D5}, Consts{$ENDIF}
  {$IFDEF RDX_D7}, RTLConsts{$ENDIF};

{ TObjeto }

procedure TObjeto.AssignError(Source: TPersistent);
var
  SourceName: string;
begin
  if Source <> nil then
    SourceName := Source.ClassName else
    SourceName := 'nil';
  raise EConvertError.CreateResFmt(@SAssignError, [SourceName, ClassName]);
end;

procedure TObjeto.AssignTo(Dest: TPersistent);
begin
  inherited;
end;

constructor TObjeto.Create;
begin
  //
end;

destructor TObjeto.Destroy;
begin
  inherited;
end;

procedure TObjeto.SalvarDatos;
begin
  //
end;

{ TListaObjetos }

function TListaObjetos.Add(AObjecto: TObjeto): Integer;
begin
  Result := FLista.Add(AObjecto);
end;

procedure TListaObjetos.AssignError(Source: TPersistent);
var
  SourceName: string;
begin
  if Source <> nil then
    SourceName := Source.ClassName else
    SourceName := 'nil';
  raise EConvertError.CreateResFmt(@SAssignError, [SourceName, ClassName]);
end;

procedure TListaObjetos.AssignTo(Dest: TPersistent);
begin
  inherited;
end;

procedure TListaObjetos.Clear;
begin
  FLista.Clear;
end;

constructor TListaObjetos.Create;
begin
  FLista := TObjectList.Create;
end;

procedure TListaObjetos.Delete(Index: Integer);
begin
  FLista.Delete(Index);
end;

destructor TListaObjetos.Destroy;
begin
  FLista.Free;
  FLista := NIL;
  inherited;
end;

function TListaObjetos.GetCount: Integer;
begin
  Result := FLista.Count;
end;

end.
