uData.pas
type
TOccupiedDataEvent =
procedure (Sender: TObject; aODE:integer;
const aMessage:
string)
of Object;
type
TOccupiedData =
Class(TObject)
...
protected
FOccupiedGrids : TStringList;
FOccupiedDataEvent: TOccupiedDataEvent;
procedure OccupiedDataEventSend(aODE:integer;
const aMessage:
string);
...
public
function OccupiedDataEventConnect(aODE:TOccupiedDataEvent):integer;
function OccupiedDataEventDisconnect(aODE:TOccupiedDataEvent):integer;
function TOccupiedData.OccupiedDataEventConnect
{ >>>>>>>>>>>>>>>>>>>>>>>>>>>> }
(aODE:TOccupiedDataEvent):integer;
var
i1:integer;
p2:^TOccupiedDataEvent;
p3:^TMethod;
begin
// local init
Result := 0;
i1 := 0;
p2 :=
Nil;
p3 :=
Nil;
// local main
if Assigned(aODE)
then
begin
// Suchen ob GUI-Element bereits verlinkt ist
For i1 := 0
to FOccupiedGrids.Count-1
do
begin
p3 := Pointer(FOccupiedGrids.Objects[i1]);
if (p3<>
NIL)
then
begin
if (p3^.Code = TMethod(aODE).Code)
and (p3^.Data = TMethod(aODE).Data)
then
begin
// bereits vorhanden
p2 := @aODE;
break;
end;
end;
end;
if (p2=Nil)
then
begin
New(p3);
p3^ := TMethod(aODE);
FOccupiedGrids.AddObject('
S',TObject(p3));
aODE(Self, odeConnected, '
Connected');
end;
end;
end;
{ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< }
function TOccupiedData.OccupiedDataEventDisconnect
{ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> }
(aODE:TOccupiedDataEvent):integer;
var
i1:integer;
p2:^TOccupiedDataEvent;
p3:^TMethod;
begin
// local init
Result := 0;
i1 := 0;
p2 :=
Nil;
p3 :=
Nil;
// local main
if Assigned(aODE)
then
begin
// Suchen ob GUI-Element bereits verlinkt ist
For i1 := FOccupiedGrids.Count-1
downto 0
do
begin
p3 := Pointer(FOccupiedGrids.Objects[i1]);
if (p3<>
NIL)
then
begin
if (p3^.Code = TMethod(aODE).Code)
and (p3^.Data = TMethod(aODE).Data)
then
begin
// gefunden!
// ... aus liste entfernen
FOccupiedGrids.Delete(i1);
// ... dynamischen speicher wieder freigeben
Dispose(p3);
p3 :=
NIL;
// notification an ODE senden
aODE(Self, odeDisConnected, '
DisConnected');
break;
end;
end;
end;
end;
end;
{ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< }
procedure TOccupiedData.OccupiedDataEventSend
{ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> }
(aODE:integer;
const aMessage:
string);
var
i1:integer;
p2:^TOccupiedDataEvent;
p3:^TMethod;
begin
// local init
i1 := 0;
p2 :=
Nil;
p3 :=
Nil;
// local main
// Entfernte ObjectMethode aufrufen
For i1 := 0
to FOccupiedGrids.Count-1
do
begin
p3 := Pointer(FOccupiedGrids.Objects[i1]);
if (p3<>
NIL)
then
begin
Pointer(p2) := p3;
p2^(Self, aODE,aMessage);
end;
end;
end;
{ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< }