Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 20-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
Types Incompatibles

Tengo este error
[Error] clsListValidator.pas(106): Incompatible types: 'TDocumentoNovo' and 'IDocument'Esta es la procedure
Código:
procedure TListValidator.Validate(Documento: IDocument);
var
  IntNum: integer;
begin
  for intNum := 0 to Self.Count - 1 do
  begin
    try
      Self[intNum].Validate(Documento);
    except
      On E:EPluginException do
        Raise EPluginException.Create(E.ErrorCode, E.Message);
      On E:Exception do
        Raise Exception.Create(E.Message);
    end; // Try..Except
  end; // For
  
end;
Pero en una Interface que tengo, la declaracion es asi:
procedure Validate(Documento: TDocumentoNovo');overload;
O sea, la declaracion es Overload y si es Overload, ella deberia aceptar otros tipos de parametros o cantidad o mismo retorno diferente(si es una funcion). Entonce, porque el error?
Responder Con Cita
  #2  
Antiguo 20-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
Un amigo me lo dijo que puede ser que no ha hecho la implementacion de Interface IDocument en la classe TDocumentoNovo. Si es esto, como lo hago, o sea, implementar una Interface en una Classe en Delphi: En Java seria:
public class Nombre implements INombre....

Pero en Delphi no lo se.
Responder Con Cita
  #3  
Antiguo 20-07-2011
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Poder: 23
maeyanes Va por buen camino
Hola...

Código Delphi [-]
type
  TDocumentoNovo = class(TObject, IDocument)
    // ...
  private
    // Declaras métodos de la interfaz a implementar
  end;


Saludos...
__________________
Lee la Guía de Estilo antes que cualquier cosa. - Twitter
Responder Con Cita
  #4  
Antiguo 20-07-2011
Avatar de Chris
[Chris] Chris is offline
Miembro Premium
 
Registrado: abr 2007
Ubicación: Jinotepe, Nicaragua
Posts: 1.678
Poder: 19
Chris Va por buen camino
Primero que todo: Creo que estás mal interpretando la instrucción OVERLOAD. Overload no quiere decir que una rutina acepta cualquier tipo de dato. Overload significa que pueden haber un polimorfismo de una rutina.

Segundo: En la declaración de Validate indicas que esperas un dato de tipo TDocumentoNovo. Pero en la implementación indicas que es de IDocument. Sin embargo algo está faltando aquí, pues antes que todo el compilador te debería indicar que hay una diferencia entre la declaración e implementación de la unidad al ser distinto el tipo de dato de **Documento**.

Podrías empezar declarando otra forma de Validate, una que trabaje con IDocument, si es que aún no la tienes.

Saludos,
Chris
__________________
Perfil Github - @chrramirez - Delphi Blog - Blog Web
Responder Con Cita
  #5  
Antiguo 20-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
Bueno, este procedimento estas en una Unit llamada de: clsLisValidator y la procedure Validator es esta:
procedure Validate(Documento: IDocument)
y su implementacion es la que puzo en primer post. Ahora hay una Interface la Pocedure Validator estas declarada asi:
procedure Validate(Documento: TDocumentoNovo);overload;
Ahora, tengo percebido que puede estar en un componente, pues tengo uno aca llamado INTERFACE.
Responder Con Cita
  #6  
Antiguo 21-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
La interface IDocument
Código:
type
  IDocument = interface(IInterfaceBase)
    ['{D48CBFA8-3292-44A2-89DD-BD7BA5823F6C}']
    function GetComplemento: String;
    function GetDataFinal: TDate;
    function GetDataInicial: TDate;
    function GetDescricao: String;
    function GetSequencialFinal: Integer;
    function GetSequencialInicial: Integer;
    function getQuantidadeDigitacao: Integer;
    procedure SetCod_Caixa(Value: Integer);
    procedure SetCod_Documento(Value: Integer);
    procedure SetCod_Usuario(Value: Integer);
    procedure SetComplemento(const Value: String);
    procedure SetDataFinal(Value: TDate);
    procedure SetDataInicial(Value: TDate);
    procedure SetData_Digitacao(Value: TDate);
    procedure SetDescricao(const Value: String);
    procedure SetPrevisaoExpurgo(Value: TDate);
    procedure SetSequencialFinal(Value: Integer);
    procedure SetSequencialInicial(Value: Integer);
    procedure SetCodTipoDocumento(Value: Integer);
    function GetCodTipoDocumento: Integer;
    function GetCodDocumento: Integer;
    procedure SetCodDocumento(Value: Integer);
    function  GetHasAutoComplete: Boolean;
    procedure SetHasAutoComplete(Value: Boolean);
    function GetCliente: ICliente;
    function GetDepartamento: IDepartamento;
    function GetLocal: ILocal;
    procedure SetCaixa(const Value: ICaixa);
    function GetCaixa: ICaixa;
    procedure SetAuditoria_Interna(const Value: String);
    function GetAnomalias: IListBase;
    procedure SetAnomalias(Value: IListBase);
    function GetStatus: String;
    procedure SetStatus(const Value: String);
    function getValorIndices(): IListBase;
    function getTipoDocumento: ITipoDocumento;
    procedure setTipoDocumento(const value: ITipoDocumento);
    procedure SetCod_Status(const Value: Integer);
    function GetCod_Status: Integer;
    function GetAuditoria_Interna: String;
    function GetCod_Caixa: Integer;
    function GetCod_Etiqueta: Integer;
    function GetCod_Usuario: Integer;
    function GetData_Digitacao: TDate;
    function GetPrevisaoExpurgo: TDate;
    procedure SetCod_Etiqueta(const Value: Integer);
    function GetCod_xSolicitante: Integer;
    procedure SetCod_xSolicitante(Value: Integer);

    property Cliente: ICliente read GetCliente;
    property Local: ILocal read GetLocal;
    property Departamento: IDepartamento read GetDepartamento;
    property TipoDocumento: ITipoDocumento read GetTipoDocumento write SetTipoDocumento;
    property Caixa: ICaixa read GetCaixa write SetCaixa;
    property Cod_Caixa: Integer read GetCod_Caixa write SetCod_Caixa;
    property CodDocumento: Integer read GetCodDocumento write SetCod_Documento;
    property Cod_Etiqueta: Integer read GetCod_Etiqueta write SetCod_Etiqueta;
    property Cod_Usuario: Integer read GetCod_Usuario write SetCod_Usuario;
    property Complemento: String read GetComplemento write SetComplemento;
    property DataFinal: TDate read GetDataFinal write SetDataFinal;
    property DataInicial: TDate read GetDataInicial write SetDataInicial;
    property Data_Digitacao: TDate read GetData_Digitacao write SetData_Digitacao;
    property Descricao: String read GetDescricao write SetDescricao;
    property PrevisaoExpurgo: TDate read GetPrevisaoExpurgo write
        SetPrevisaoExpurgo;
    property SequencialFinal: Integer read GetSequencialFinal write
        SetSequencialFinal;
    property SequencialInicial: Integer read GetSequencialInicial write
        SetSequencialInicial;
    property CodTipoDocumento: Integer read GetCodTipoDocumento write SetCodTipoDocumento;
    property HasAutoComplete: Boolean read GetHasAutoComplete write SetHasAutoComplete;
    property Auditoria_Interna: String read GetAuditoria_Interna write SetAuditoria_Interna;
    property Anomalias: IListBase read GetAnomalias write SetAnomalias;
    property Status: String read GetStatus write SetStatus;
    property ValorIndices: IListBase read GetValorIndices;
    property Cod_Status: Integer read GetCod_Status write SetCod_Status;
    property QuantidadeDigitacao: Integer read GetQuantidadeDigitacao;
    property Cod_xSolicitante: Integer read GetCod_xSolicitante write SetCod_xSolicitante;
  end;
implementation
end.
La Unit que me lo da el error
Código:
ype
  TListValidator = class(TObject)
  private
    FListValidator: TListPlugins;
    FOnAfterValidate: TNotifyValidate;
    FOnBeforeValidate: TNotifyValidate;
    FOnErrorValidate: TOnErrorValidate;
    function GetItems(Index: integer): IValidator;
    procedure SetItems(Index: integer; const Value: IValidator);
    procedure SetOnBeforeValidate(EventHandle: TNotifyValidate);
    procedure SetonAfterValidate(EventHandle: TNotifyValidate);
    procedure SetOnErrorValidate(EventHandle: TOnErrorValidate);

  public
    constructor Create;
    destructor Destroy; override;
    function Add(Validator: IValidator): Integer;
    function Count: Integer;
    procedure Delete(Index: integer); overload;
    procedure Delete(GUID: string); overload;
    procedure Clear;
    procedure Validate(Documento: IDocument);
    property Items[Index: integer]: IValidator read GetItems write SetItems;
        default;
    property OnErrorValidate: TOnErrorValidate read FOnErrorValidate write SetOnErrorValidate;
    property OnBeforeValidate: TNotifyValidate read FOnBeforeValidate write SetOnBeforeValidate;
    property OnAfterValidate:  TNotifyValidate read FOnAfterValidate write SetOnAfterValidate;

  end;

implementation

uses
  SysUtils, Exceptions;

{ TListValidator }

constructor TListValidator.Create;
begin
  FListValidator := TListPlugins.Create;
end;
destructor TListValidator.Destroy;
begin
  FreeAndNil(FListValidator);
  inherited;
end;
function TListValidator.Add(Validator: IValidator): Integer;
begin

  Result := FListValidator.Add(Validator);
  // Se houverem eventos de validações associados, associa a cada elemento inserido
  if Assigned(Self.OnBeforeValidate) then
    Validator.OnBeforeValidate := Self.OnBeforeValidate;

  if Assigned(Self.OnAfterValidate) then
    Validator.OnAfterValidate  := Self.OnAfterValidate;

  if Assigned(Self.OnErrorValidate) then
    Validator.OnErrorValidate  := Self.OnErrorValidate;
end;
function TListValidator.Count: Integer;
begin
  Result := FListValidator.Count();
end;
procedure TListValidator.Delete(Index: integer);
begin
  FListValidator.Delete(Index);
end;
procedure TListValidator.Delete(GUID: string);
begin
  FListValidator.Delete(GUID);
end;
function TListValidator.GetItems(Index: integer): IValidator;
begin
  Result := IValidator(FListValidator[Index]);
end;
procedure TListValidator.SetItems(Index: integer; const Value: IValidator);
begin
  FListValidator[Index] := Value;
end;
procedure TListValidator.Validate(Documento: IDocument);
var
  IntNum: integer;
begin
  for intNum := 0 to Self.Count - 1 do
  begin
    try
      Self[intNum].Validate(Documento);//Aca estas el error
    except
      On E:EPluginException do
        Raise EPluginException.Create(E.ErrorCode, E.Message);

      On E:Exception do
        Raise Exception.Create(E.Message);
    end; // Try..Except
  end; // For  
end;
procedure TListValidator.Clear;
begin
  FListValidator.Clear;
end;
procedure TListValidator.SetOnAfterValidate(EventHandle: TNotifyValidate);
var
  intNum: integer;
begin
  FOnAfterValidate := EventHandle;
  for intNum := 0 to Self.FListValidator.Count - 1 do
    IValidator(Self.FListValidator[intNum]).OnAfterValidate := FOnAfterValidate;  
end;
procedure TListValidator.SetOnBeforeValidate(
  EventHandle: TNotifyValidate);
var
  IntNum: integer;
begin
  FOnBeforeValidate := EventHandle;
  // Seta o evento de validação para todos os elementos da lista
  for intNum := 0 to Self.FListValidator.Count - 1 do
    IValidator(Self.FListValidator[intNum]).OnBeforeValidate := EventHandle;
end;
procedure TListValidator.SetOnErrorValidate(EventHandle: TOnErrorValidate);
var
  intNum: integer;
begin
  FOnErrorValidate := EventHandle;
  for intNum := 0 to Self.FListValidator.Count - 1 do
    IValidator(Self.FListValidator[intNum]).OnErrorValidate := FOnErrorValidate;
end;
end.

Última edición por Paulao fecha: 21-07-2011 a las 15:57:09.
Responder Con Cita
  #7  
Antiguo 21-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
A Unit com a Interface IValidator
Código:
interface
uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
  clsDocumento, IPluginUnit;
type
  TOnErrorValidate  = procedure (FieldName: String) of object;
  TNotifyValidate   = procedure (Documento: TDocumentoNovo) of object;

  IValidator = interface(IPlugin)
    ['{A9688CA1-4117-42D7-A790-60B950B2D264}']
    function GetOnAfterValidate:   TNotifyValidate;
    function GetOnBeforeValidate: TNotifyValidate;
    function GetOnErrorValidate: TOnErrorValidate;
    procedure SetOnBeforeValidate(const Value: TNotifyValidate);
    procedure SetOnAfterValidate(const Value: TNotifyValidate);
    procedure SetOnErrorValidate(const Value: TOnErrorValidate);
    procedure Validate(Documento: TDocumentoNovo);{overload;
    procedure Validate(Documento: IDocument);overload;//Criado por Paulo }
    property OnAfterValidate: TNotifyValidate read GetOnAfterValidate write
        SetOnBeforeValidate;
    property OnBeforeValidate: TNotifyValidate read GetOnBeforeValidate write
        SetOnBeforeValidate;
    property OnErrorValidate: TOnErrorValidate read GetOnErrorValidate write
        SetOnErrorValidate;
  end;
  IteratorValidator = interface
    ['{33D0C0ED-91A4-468E-AF5B-A7E5B5C5DAC7}']
    procedure First();
    procedure Next();
    function IsDone(): Boolean;
    function CurrentItem: IValidator;
  end;
  IListValidator = interface
    ['{8F2F5645-3BC1-427D-89AC-A39C370AD957}']
    function  CreateIterator(): IteratorValidator;
    procedure Add(Validator: IValidator);
    procedure Delete(Index: Integer);
    function  Item(Index: integer): IValidator;
    function  Count(): integer;
  end;
implementation
end.
A Unit onde está a classe TDocumentoNovo

Código:
type
  TDocumentoNovo = class(TClassBase, IDocument)
  private
    FCod_Caixa: Integer;
    FCodDocumento: Integer;
    FCod_Etiqueta: Integer;
    FCod_Usuario: Integer;
    FComplemento: String;
    FDataFinal: TDate;
    FDataInicial: TDate;
    FData_Digitacao: TDate;
    FDescricao: String;
    FPrevisaoExpurgo: TDate;
    FSequencialFinal: Integer;
    FSequencialInicial: Integer;
    FDestroyTipoDocumento: Boolean;
    FTipoDocumento: TTipoDocumento;
    FDestroyCaixa: Boolean;
    FCaixa: TCaixa;
    FCodTipoDocumento: Integer;
    FHasAutoComplete: Boolean;
    FAuditoria_Interna: String;
    FAnomalias: TListBase;
    FListValor: TListBase;
    FStatus: String;
    FCod_Status: Integer;
    FCod_xSolicitante: Integer;
    FCarga: TCarga;
    //Preferimos usar o Cod_Auditoria ao inves da Classe FAuditoria por quetão de tempo devido a urgencia de entrega
    // que se se faz presente nesta data
    //FAuditoria:TAuditoria;
    //FDestroyAuditoria: Boolean;
    FCod_Auditoria : integer;
    FHashRegistro: String;
    function GetCliente(): TCliente;
    function GetLocal(): TLocal;
    function GetDepartamento(): TDepartamento;
    function GetComplemento: String;
    function GetDataFinal: TDate;
    function GetDataInicial: TDate;
    function GetDescricao: String;
    function GetSequencialFinal: Integer;
    function GetSequencialInicial: Integer;
    function getQuantidadeDigitacao: Integer;
    procedure SetCod_Caixa(Value: Integer);
    procedure SetCod_Documento(Value: Integer);
    procedure SetCod_Usuario(Value: Integer);
    procedure SetComplemento(const Value: String);
    procedure SetDataFinal(Value: TDate);
    procedure SetDataInicial(Value: TDate);
    procedure SetData_Digitacao(Value: TDate);
    procedure SetDescricao(const Value: String);
    procedure SetPrevisaoExpurgo(Value: TDate);
    procedure SetSequencialFinal(Value: Integer);
    procedure SetSequencialInicial(Value: Integer);
    //procedure SetCodTipoDocumento(Value: Integer);
    function GetCodTipoDocumento: Integer;
    function GetCodDocumento: Integer;
    procedure SetCodDocumento(Value: Integer);
    function  GetHasAutoComplete: Boolean;
    procedure SetHasAutoComplete(Value: Boolean);
    procedure SetCaixa(const Value: TCaixa);
    function GetCaixa: TCaixa;
    procedure SetAuditoria_Interna(const Value: String);
    function GetAnomalias: TListBase;
    procedure SetAnomalias(Value: TListBase);
    function GetStatus: String;
    procedure SetStatus(const Value: String);
    function getValorIndices(): TListBase;
    function getTipoDocumento: TTipoDocumento;
    procedure setTipoDocumento(const value: TTipoDocumento);
    procedure SetCod_Status(const Value: Integer);
    function GetCod_Status: Integer;
    function GetAuditoria_Interna: String;
    function GetCod_Caixa: Integer;
    function GetCod_Etiqueta: Integer;
    function GetCod_Usuario: Integer;
    function GetData_Digitacao: TDate;
    procedure SetCod_Etiqueta(const Value: Integer);
    function GetCod_xSolicitante: Integer;
    procedure SetCod_xSolicitante(Value: Integer);
    function GetPrevisaoExpurgo: TDate;
    function GetCarga: TCarga;
    //function GetAuditoria: TAuditoria;
    //procedure SetAuditoria(const Value: TAuditoria);
    function GetCod_Auditoria: integer;
    procedure SetCod_Auditoria(const Value: integer);
    function getHashRegistro: String;
    procedure setHashRegistro(const Value: String);
    function QuantidadeDigitacaoCustomizavel: Integer;
  public
    constructor Create; override;
    destructor Destroy; override;
    procedure PopularValorIndice();
    //Colocados aqui para nao serem lidas em tempo de execucao usando o metodo AssignPropertys
    //pois causa Access Violation.
    property Carga: TCarga read GetCarga;
    property Cliente: TCliente read GetCliente;
    property Local:   TLocal read GetLocal;
    property Departamento: TDepartamento read GetDepartamento;
    property QuantidadeDigitacao: Integer read GetQuantidadeDigitacao;
    property CodTipoDocumento: Integer read GetCodTipoDocumento;
  published
    property TipoDocumento: TTipoDocumento read GetTipoDocumento write SetTipoDocumento;
    property Caixa: TCaixa read GetCaixa write SetCaixa;
    property Cod_Caixa: Integer read GetCod_Caixa write SetCod_Caixa;
    property CodDocumento: Integer read GetCodDocumento write SetCod_Documento;
    property Cod_Etiqueta: Integer read GetCod_Etiqueta write SetCod_Etiqueta;
    property Cod_Usuario: Integer read GetCod_Usuario write SetCod_Usuario;
    property Complemento: String read GetComplemento write SetComplemento;
    property DataFinal: TDate read GetDataFinal write SetDataFinal;
    property DataInicial: TDate read GetDataInicial write SetDataInicial;
    property Data_Digitacao: TDate read GetData_Digitacao write SetData_Digitacao;
    property Descricao: String read GetDescricao write SetDescricao;
    property PrevisaoExpurgo: TDate read GetPrevisaoExpurgo write
        SetPrevisaoExpurgo;
    property SequencialFinal: Integer read GetSequencialFinal write
        SetSequencialFinal;
    property SequencialInicial: Integer read GetSequencialInicial write
        SetSequencialInicial;
    property HasAutoComplete: Boolean read GetHasAutoComplete write SetHasAutoComplete;
    property Auditoria_Interna: String read GetAuditoria_Interna write SetAuditoria_Interna;
    property Anomalias: TListBase read GetAnomalias write SetAnomalias;
    property Status: String read GetStatus write SetStatus;
    property ValorIndices: TListBase read GetValorIndices;
    property Cod_Status: Integer read GetCod_Status write SetCod_Status;
    property Cod_xSolicitante: Integer read GetCod_xSolicitante write SetCod_xSolicitante;
    //Preferimos usar o Cod_Auditoria ao inves da Classe FAuditoria por quetão de tempo devido a urgencia de entrega
    // que se se faz presente nesta data
    property Cod_Auditoria : integer read GetCod_Auditoria write SetCod_Auditoria;
    property HashRegistro: String read getHashRegistro write setHashRegistro;
  end;
Responder Con Cita
  #8  
Antiguo 21-07-2011
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Poder: 23
maeyanes Va por buen camino
Hola...

Paulao, usa la etiqueta [delphi] en lugar de [code] cuando publiques código fuente en Delphi.

Según leo en el código, tienes comentada la declaración del procedimiento Validate(Documento: IDocument);. ¿Así estás tratando de compilar tú código? Por que si es así, es por eso que obtienes el error.



Saludos...
__________________
Lee la Guía de Estilo antes que cualquier cosa. - Twitter
Responder Con Cita
  #9  
Antiguo 21-07-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Poder: 21
Paulao Va por buen camino
No, no estas. Yo hizo esto para un teste aca y si quedo quando hizo una copia para postar aca, pero todo estas cierto, nada comentado.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Error de Incompatibles Types Paulao Varios 4 18-07-2011 15:45:19
Error de tipos incompatibles jorgegetafe Varios 2 03-10-2007 00:12:08
Tipos Incompatibles? RJNewbyte Conexión con bases de datos 4 28-12-2006 18:56:24
Libertad y negocios, incompatibles? marcoszorrilla Noticias 6 14-06-2005 22:01:35
TPanel y bucle incompatibles JoseQ Varios 1 03-03-2005 19:30:02


La franja horaria es GMT +2. Ahora son las 18:12:38.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi