Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 26.01.07 18:54 
Habe eine Klasse ObjectClass die wiederum die Klassen TAttributelist und TMethodlist kapselt:
ausblenden Delphi-Quelltext
1:
2:
property Methods: TMethodlist read GetMethodlist;
property Attributes: TAttributelist read GetAttributelist;

Ich möchte nun, dass wenn eine der beiden Listen geändert wird (Add/Delete etc.), dass dann ObjectClass davon etwas mitbekommt. Man könnte vielleicht ein Ereignis auslösen. Auf jeden Fall soll dann eine private Variable in ObjectClass auf true gesetzt werden.
Wie macht man so etwas?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
ich1506
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 49

Win XP, Win 98, Win 2000, Eisfair
Delphi 5 Enterp
BeitragVerfasst: Sa 27.01.07 00:38 
Hallo,

Wenn du oop programmieren möchtest, dann muss es auch von Anfang an gut durchdacht sein. Du greifst auf die Listen dann im Programm nur "von Außen" zu - alles läuft über das Kapselnde Objekt - deshalb heißt es auch Kapselung. Wenn du nun etwas änderst, läuft ja sicherlich eine Prozedur ab, in die du dann alles weitere hineinschreiben kannst.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 27.01.07 11:40 
user profile iconich1506 hat folgendes geschrieben:
Hallo,

Wenn du oop programmieren möchtest, dann muss es auch von Anfang an gut durchdacht sein. Du greifst auf die Listen dann im Programm nur "von Außen" zu - alles läuft über das Kapselnde Objekt - deshalb heißt es auch Kapselung. Wenn du nun etwas änderst, läuft ja sicherlich eine Prozedur ab, in die du dann alles weitere hineinschreiben kannst.

Dein Post hilft mir überhaupt nicht weiter. :(
Ja na sicher habe ich eine Prozedur. Aber die ist in TAttributelist definiert. Bloß wie greife ich von der auf TObjcetClass zu?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Sa 27.01.07 12:56 
komplettes Edit:

Du kannst ja in deinen von TList (oder so) abgeleiteten Klassen die Prozeduren Add, Delete usw. überschreiben. Du führst dann zwar noch das Add (via inherited) aus, aber tust zusätzlich noch deine Unterklasse benachrichtigen. Und zwar übergibst du deiner Liste beim erstellen einfach die Instanz der ObjectKlasse, die du dann in ner privaten Variable speicherst. Die Objectklasse muss dann halt eine Methode bereitstellen, bei der auf die Änderung reagiert wird.

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 27.01.07 13:31 
user profile iconalias5000 hat folgendes geschrieben:
komplettes Edit:

Du kannst ja in deinen von TList (oder so) abgeleiteten Klassen die Prozeduren Add, Delete usw. überschreiben. Du führst dann zwar noch das Add (via inherited) aus, aber tust zusätzlich noch deine Unterklasse benachrichtigen. Und zwar übergibst du deiner Liste beim erstellen einfach die Instanz der ObjectKlasse, die du dann in ner privaten Variable speicherst. Die Objectklasse muss dann halt eine Methode bereitstellen, bei der auf die Änderung reagiert wird.

Gruß alias5000

Es ist nichts von TList abgeleitet. Aller selbst gemacht.
Habs jetzt in TAttributelist so versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
uses ObjectClass;
private
  FObjectClass: ^TObjectClass;


Da ObjectClass aber bei uses auch Attributelist zu stehen hat, kommt wieder diese gruselige :motz: Fehlermeldung :motz: "Überkreuzender Bezug zweier Units auf Objectclass" :motz: Was kann man gegen diese tun? :motz:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Sa 27.01.07 14:22 
Dann übergibst du halt ein TObject und im Code machste dann ein Typecast (bla as TObjectClass).Tunochwas;

Gruß alias5000

PS.:
Warum schreibst du das hier?
ausblenden Delphi-Quelltext
1:
FObjectClass: ^TObjectClass;					


Damit erzeugst du einen Pointer auf den Pointer auf die Objektinstanz...
FObjectClass an sich ist ja schon ein Zeiger ;)

_________________
Programmers never die, they just GOSUB without RETURN
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Sa 27.01.07 18:30 
Bei TStrins gibt es ein Ereignis OnChange, das wird ausgelöst, wenn eben die Stringliste geändert wird. Sowas könntest du auch machen.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 27.01.07 21:40 
user profile iconJakob Schöttl hat folgendes geschrieben:
Bei TStrins gibt es ein Ereignis OnChange, das wird ausgelöst, wenn eben die Stringliste geändert wird. Sowas könntest du auch machen.

Joah in Ordnung -> hat funktioniert. ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot