Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #13  
Antiguo 09-04-2015
doctorhd doctorhd is offline
Miembro
NULL
 
Registrado: abr 2013
Posts: 48
Poder: 0
doctorhd Va por buen camino
Bueno finalmente mi diseño quedo de la siguiente forma:
Código Delphi [-]

TEnumTypeData = (tyNone,tyCurrency, tyBoolean, tyDate, tyDateTime, tyFloat, tyInteger, tyString, tyExpandString, tyTime, tyBinaryData);

TClaveValor = record
      private
        FClave:string;
        FValueDefault:Variant;
        FValue:Variant;
        FTipo:TEnumTypeData;
        procedure SetClave(const Value:string);
        procedure SetValueDefault(const Value:variant);
        procedure SetValue(const Value:variant);
        procedure SetTipo(const Value:TEnumTypeData);
      public
        property Clave: string read FClave write SetClave;
        property ValueDefault: Variant read FValueDefault write SetValueDefault;
        property Value:Variant read FValue write SetValue;
        property Tipo: TEnumTypeData read FTipo write SetTipo;
    end;

  procedure TClaveValor.SetClave(const Value:string);
  begin
    FClave:=Value;
  end;

  procedure TClaveValor.SetValueDefault(const Value:variant);
  begin
    FValueDefault:=Value;
  end;

  procedure TClaveValor.SetValue(const Value:variant);
  begin
    FValue:=Value;
  end;

  procedure TClaveValor.SetTipo(const Value:TEnumTypeData);
  begin
    FTipo:=Value;
  end;

 type PClaveValor = ^TClaveValor;{Puntero a TClaveValor }

 type
    TConfigBDRegistro = class
    private
      FTipoServer:TClaveValor;
      FNameServer:TClaveValor;
      FRuta:TClaveValor;
      FProComunicacion:TClaveValor;
      FRutaVendorLib:TClaveValor;
      FListCampos:array of PClaveValor;
      function GetCampo(const Index: Integer): PClaveValor;
      procedure SetCampo(const Index: Integer; const Value: PClaveValor);
      function GetNCampos:Integer;
    public
      constructor Create;
      property TipoServer:TClaveValor read FTipoServer write FTipoServer;
      property NameServer:TClaveValor read FNameServer write FNameServer;
      property Ruta:TClaveValor read FRuta write FRuta;
      property ProComunicacion:TClaveValor read FProComunicacion write FProComunicacion;
      property RutaVendorLib:TClaveValor read FRutaVendorLib write FRutaVendorLib;
      property ListCampos[const Index: Integer]:PClaveValor read GetCampo write SetCampo;
      property NCampos:Integer read GetNCampos;
    end;

  constructor TConfigBDRegistro.Create;
  begin
    Setlength(FListCampos,5);{Dimencionamos el tamaño de la lista de campos}
    FListCampos[0]:=@FTipoServer;
    FListCampos[1]:=@FNameServer;
    FListCampos[2]:=@FRuta;
    FListCampos[3]:=@FProComunicacion;
    FListCampos[4]:=@FRutaVendorLib;
  end;{constructor}

  function TConfigBDRegistro.GetCampo(const Index:Integer):PClaveValor;
  begin
    Result:=FListCampos[Index];
  end;{function}

  procedure TConfigBDRegistro.SetCampo(const Index:Integer; const Value:PClaveValor);
  begin
    FListCampos[Index]:=Value;
  end;{function}

  function TConfigBDRegistro.GetNCampos:Integer;
  begin
    Result:=High(FListCampos);
  end;{function}

Para ser llamado asi:

Código Delphi [-]
  ....
   vFin:=ConfigBDRegistro.NCampos;
   {recorremos la lista de campos}
   for vIndice:=0 to vFin do begin
     ListCampos[vIndice].Value:='un Dato';{Funciona}
   end;{for}
  ....

Un comentario acerca de lo dicho por mamcx
Cita:
1- Estas usando un record como si fuera una clase
Si, pero el lenguaje lo permite y lo implementa como una opción, por tanto porque no utilizarlo...

Creo que mamcx tiene razón en varios de los comentarios que hace, referente a simplificar el diseño utilizando solo record y funciones, ahora la pregunta es cuando programar O.O y cuando programar procedimientalmente... En mi caso mi aprendizaje fue enfocado a este ultimo, pero he ido cambiando de paradigma, por las enormes ventajas que representa programar O.O. herencia, encapsulacion, etc... Quizas utilizar lo mejor de ambos modelos...????

Saludos...
Responder Con Cita
 



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
esta function no me funciona en XE2 y si funciona en D6 darkbits Varios 1 06-11-2012 17:00:45
UDF no funciona en xp GustavoCruz Firebird e Interbase 15 04-10-2011 12:07:00
funciona bien en windows 7 64b pero en XP no funciona ASAPLTDA Varios 5 06-05-2011 16:24:50
$L .Obj no funciona rastafarey Varios 2 09-01-2009 19:47:09
like no funciona ! dmasson Conexión con bases de datos 9 23-03-2004 14:10:50


La franja horaria es GMT +2. Ahora son las 07:48:55.


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