![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
||||
|
||||
|
No acabo de comprenderlo del todo, al incluir lo del polimorfismo es cuando me he perdido.
¿tendrías algún problema con este código?
En principio y suponiendo que TactionsList hereda de Taction, no habría ninguno. Para Crear las clases en ejecución mira este hilo y este Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente, se lo volveré a explicar hasta que no lo entienda, Gracias. |
|
#2
|
|||
|
|||
|
Hola de nuevo, TActionList no hereda de nadie, esta es la lista de acciones, el tiene un campo que es un TStringList el cual almacena los objetos que heredan de TAction.
aqui te pongo la interface: Código:
TActionList = class
private
FPath : string;
FList : TStringList;
public
constructor Create(aPath : string); reintroduce;
destructor Destroy; override;
procedure Add(action : TAction);
function Delete(IdTask : string): Boolean;
function Count: Integer;
function IsEmpty: Boolean;
function getAction(aIndex : integer): TAction; overload;
function getAction(aIdTask : string): TAction; overload;
procedure DefineProperty(aFiler : TFiler);
procedure LoadActions(aReader : TReader);
procedure SaveActions(aWriter : TWriter);
end;
Código:
procedure TActionList.DefineProperty(aFiler: TFiler);
begin
inherited;
aFiler.DefineProperty('Action', LoadActions, SaveActions, true);
end;
Código:
procedure TActionList.LoadActions(aReader: TReader);
var
StrId : string;
aAction : TAction;
begin
aReader.ReadListBegin;
While not aReader.EndOfList Do
begin
StrId := aReader.ReadStr;
aAction := (aReader.ReadComponent(nil) as TAction);
FList.AddObject(StrId, aAction);
end;
aReader.ReadListEnd;
end;
procedure TActionList.SaveActions(aWriter: TWriter);
var
i : integer;
begin
aWriter.WriteListBegin;
For i := 0 to FList.Count - 1 Do
begin
aWriter.WriteString(FList[i]);
aWriter.WriteComponent(FList.Objects[i] as TAction);
end;
aWriter.WriteListEnd;
end;
entonces la preguntas concretas serian: - De quien deberia heredar TActionList??? - Donde se le dice que salve y que carge, o lo hace automatico?????? - Existe otra manera de resolver mi problema??? - Cuando cargo del fichero voy a agregando a la lista objetos tipo TActions, no habra problema al llamar a estos objetos, ya que no reconoceran el tipo especializado que eran anteriormente salu2 miguel_e |
|
#3
|
||||
|
||||
|
Este hilo te aclarará más las cosas.
Fíjate en especial como funciona el método ReadPoints, primero agranda el array FPoints, después lee de archivo y asigna esos valores. En realidad el problema no es la clase TActionsList, sino más bien TAction, que es la que se quiere guardar y rescatar. Quizás los tiros vayan por redefinir el Reader y Writer de TAction y ahora si implementamos:
Visto así, quien tiene que implementar el reader y Writer es el propio Action (que hereda de Tcomponent) para que delphi sepa como debe guardarlo en un archivo y como debe "reconstruir el Taction desde archivo". Cita:
Cita:
Cita:
Cita:
__________________
Si usted entendió mi comentario, contácteme y gustosamente, se lo volveré a explicar hasta que no lo entienda, Gracias. |
|
#4
|
|||
|
|||
|
OK, todo funcionando muy bien, MUCHASS GRACIASSSSSS
salu2 miguel_e |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Instacias de los objetos en asp.net | karocs | .NET | 1 | 30-09-2006 08:38:30 |
| ¿Mejor heredar de una Lista o mejor introducir la Lista en un campo? | Jome | OOP | 8 | 24-11-2005 17:11:16 |
| Una lista de Objetos en .NET | bustio | .NET | 1 | 11-10-2004 15:23:08 |
| uso de objetos en CORBA | zuriel_zrf | Providers | 0 | 11-12-2003 07:20:14 |
| Objetos | jfontane | Varios | 1 | 04-07-2003 15:39:04 |
|