| Autor |
Beitrag |
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: So 21.01.07 22:31
Also ich habe einen Fehler in meinem Konzept entdeckt. Ich möchte z.B. folgendes machen können:
Delphi-Quelltext 1:
| MyClass.Attributes[index].DataType := 'bool'; |
Ich hatte mir schon die Klassen TParameter, TParameterlist, TAttribute und TAttributelist entwickelt. In Planung waren noch TMethod, TMethodlist und TObjectClass.
Nun jedoch habe ich ein Problem:
Laut meinem Konzept würde der Code von oben so lauten:
Delphi-Quelltext 1:
| MyClass.Attributes.Attributes[index].DataType := 'bool'; |
Ich war erst der Meinung, ich könnte z.B. die Verwaltung der Attribute (TAttribute) in die Unit Attributelist (TAttributelist) auslagern. Wenn ich nun aber TObjectClass definiere:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| unit ObjectClass;
interface
type
TObjectClass = class private public property Attributes: TAttributelist end;
implementation
end. |
dann habe ich ein Problem, weil:
Delphi-Quelltext 1: 2: 3: 4: 5:
| property Attribute[index: integer]: TAttribute read GetAttribute write SetAttribute;
MyClass.Attributes.Attributes[index].DataType := 'bool'; |
Da ich aber nicht zweimal Attributes haben will, müsste die Verwaltung von TAttribute, die eigentlich TAttributelist übernehmen sollte, direkt in TObjectClass implementiert werden. Da es aber auch noch MyClass.Methods[index] geben soll, kann ich das nicht so machen, da die Verwaltung auf einer verketteten Liste basiert und ich diese nicht zweimal in die gleiche Klasse einbauen will.
Was kann man jetzt tun?
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: So 21.01.07 22:39
Du kannst Array-Properties als Default deklarieren ... Dann würde das 2. Attributes implizit von Delphi ergänzt werden.
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
tommie-lie
      
Beiträge: 4373
Ubuntu 7.10 "Gutsy Gibbon"
|
Verfasst: So 21.01.07 22:41
Ich bin mir nicht sicher, ob ich verstanden habe, wie deine Klassen aussehen. Ist TAttributeList.Attributes ein Array Property (property Attributs[index: Integer]: TAttribute;)? Wenn ja, dann interessierst du dich vielleicht für den Modifier default.
_________________ Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: So 21.01.07 22:43
BenBE hat folgendes geschrieben: | | Du kannst Array-Properties als Default deklarieren ... Dann würde das 2. Attributes implizit von Delphi ergänzt werden. |
Öhm wie würde das im Code genau aussehen? So?
Delphi-Quelltext 1:
| property Attribute[index: integer]: TAttribute read GetAttribute write SetAttribute; default; |
Oder muss das in TObjectClass?
tommie-lie hat folgendes geschrieben: | | Ich bin mir nicht sicher, ob ich verstanden habe, wie deine Klassen aussehen. Ist TAttributeList.Attributes ein Array Property (property Attributs[index: Integer]: TAttribute;)? Wenn ja, dann interessierst du dich vielleicht für den Modifier default. |
BenBe war schneller.  Du hast aber Recht! 
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
tommie-lie
      
Beiträge: 4373
Ubuntu 7.10 "Gutsy Gibbon"
|
Verfasst: So 21.01.07 22:46
_________________ Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Di 23.01.07 18:31
Ich habe jetzt das gleiche Problem, nur analog mit TMethod in das die Property Parameters hinein soll.
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| unit Method;
interface
uses Parameterlist,main,Objectclass;
type
TMethod = class
property Parameters: TParameterlist
property Parameter[index: integer]: TParameter read GetParameter write SetParameter; default; |
Was muss ich in der Unit Method hinzufügen?
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
tommie-lie
      
Beiträge: 4373
Ubuntu 7.10 "Gutsy Gibbon"
|
Verfasst: Di 23.01.07 20:17
Marco D. hat folgendes geschrieben: | | Was muss ich in der Unit Method hinzufügen? |
Das gleiche, was du auch in der Unit ObjectClass hinzugefügt hast. Wenn mich meine Erinnerungen nicht im Stich lassen war das exakt "nichts".
_________________ Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
|
|
|