Re: [fpc-pascal] How to get a data module to notify of events?

2011-09-15 Thread Martin Schreiber
On Thursday 15 September 2011 17:43:22 Frank Church wrote:
>
> Where is the  tmethodlist itself defined?

Oh, sorry.

http://svn.berlios.de/viewvc/mseide-msegui/trunk/lib/common/kernel/mselist.pas?view=markup

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get a data module to notify of events?

2011-09-15 Thread Frank Church
On 15 September 2011 16:26, Martin Schreiber  wrote:

> On Thursday 15 September 2011 16:53:35 Frank Church wrote:
> > Are there some examples of that somewhere?
>
> or
>
> http://svn.berlios.de/viewvc/mseide-msegui/trunk/lib/common/kernel/msegui.pas?view=markup
> tmethodlist.
> Warning, tmethodlist.remove() must be called before destroying the
> registered objects. There is no automatic unliking as in tobjectlinker.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


Where is the  tmethodlist itself defined?

-- 
Frank Church

===
http://devblog.brahmancreations.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to get a data module to notify of events?

2011-09-15 Thread Martin Schreiber
On Thursday 15 September 2011 16:53:35 Frank Church wrote:
> Are there some examples of that somewhere?

or
http://svn.berlios.de/viewvc/mseide-msegui/trunk/lib/common/kernel/msegui.pas?view=markup
tmethodlist.
Warning, tmethodlist.remove() must be called before destroying the registered 
objects. There is no automatic unliking as in tobjectlinker.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get a data module to notify of events?

2011-09-15 Thread Martin Schreiber
On Thursday 15 September 2011 16:53:35 Frank Church wrote:

> Are there some examples of that somewhere?
> 
http://svn.berlios.de/viewvc/mseide-msegui/trunk/lib/common/kernel/mseclasses.pas?view=markup
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get a data module to notify of events?

2011-09-15 Thread Frank Church
On 15 September 2011 15:48, Martin Schreiber  wrote:

> On Thursday 15 September 2011 16:28:29 Frank Church wrote:
> > I have a form with some threaded objects that notify another form of
> events
> > by calling one of that forms events.
> >
> > I want to convert to a data module and any interested object to register
> > for those notifications.
> >
> > My idea is for each thread to have some kind of list of procedure types
> and
> > each interested object registers its routine eg.
> >
> > This is the data module. It is a rough sketch and may have some syntax
> > errors
> >
> > Type TOneArg = Procedure (Var X : integer);
> >
> > > type
> > >
> > >   TMonitorObject = class(TThread)
> > >   private
> > >
> > > InterestedObjects: TList
> > > procedure DispatchOutput;
> > > procedure DisplayRawOutput;
> > >
> > >   protected
> > >
> > > procedure Execute; override;
> > >
> > >   public
> > >
> > > constructor Create(CreateSuspended: Boolean);
> > > RegisterInterest(interestedProc:TOneArg);
> > >
> > >   end;
> > >
> > > TMonitorObject.RegisterInterest(TOneArg);
> > > begin
> > >
> > >InterestedObjects.Add(interestedProc);
> > >
> > > end;
> > >
> > > procedure TMonitorObject.DispatchOutput;
> > > begin
> > >
> > >foreach InterestedObject do
> > >
> > > InterestedObject.Procedure.Execute;
> > >
> > > end;
> > >
> > > constructor TMonitorObject.Create(CreateSuspended: Boolean);
> > > begin
> > >
> > >   inherited Create(CreateSuspended);
> > >   InterestedObjects := TList.Create
> > >   FCycleComplete := True;
> > >
> > > end;
> >
> > Do the procedures for the objects which require notification need to be
> > constructed in some way?
> >
> MSEgui has such a notification mechanism with automatic unlinking by
> destroying the objects, see tobjectlinker in
> lib/common/kernel/mseclasses.pas.
> Another possibility is to use a tobjectevent descendant and
> application.postevent.
>
> > Am I on the right track here? I am particularly interested in what
> happens
> > when the objects passing the routines are destroyed without the data
> module
> > knowing about it.
>
> The program most likely will crash. :-)
>
>

I want to know if my approach is a workable one and what the right syntax
should be, handling the destroyed objects I believe I can deal with by
checking for the existence of the object before notifying it.
Are there some examples of that somewhere?


> Martin
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



-- 
Frank Church

===
http://devblog.brahmancreations.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to get a data module to notify of events?

2011-09-15 Thread Martin Schreiber
On Thursday 15 September 2011 16:28:29 Frank Church wrote:
> I have a form with some threaded objects that notify another form of events
> by calling one of that forms events.
> 
> I want to convert to a data module and any interested object to register
> for those notifications.
> 
> My idea is for each thread to have some kind of list of procedure types and
> each interested object registers its routine eg.
> 
> This is the data module. It is a rough sketch and may have some syntax
> errors
> 
> Type TOneArg = Procedure (Var X : integer);
> 
> > type
> > 
> >   TMonitorObject = class(TThread)
> >   private
> >   
> > InterestedObjects: TList
> > procedure DispatchOutput;
> > procedure DisplayRawOutput;
> >   
> >   protected
> >   
> > procedure Execute; override;
> >   
> >   public
> >   
> > constructor Create(CreateSuspended: Boolean);
> > RegisterInterest(interestedProc:TOneArg);
> >   
> >   end;
> > 
> > TMonitorObject.RegisterInterest(TOneArg);
> > begin
> > 
> >InterestedObjects.Add(interestedProc);
> > 
> > end;
> > 
> > procedure TMonitorObject.DispatchOutput;
> > begin
> > 
> >foreach InterestedObject do
> >
> > InterestedObject.Procedure.Execute;
> > 
> > end;
> > 
> > constructor TMonitorObject.Create(CreateSuspended: Boolean);
> > begin
> > 
> >   inherited Create(CreateSuspended);
> >   InterestedObjects := TList.Create
> >   FCycleComplete := True;
> > 
> > end;
> 
> Do the procedures for the objects which require notification need to be
> constructed in some way?
> 
MSEgui has such a notification mechanism with automatic unlinking by 
destroying the objects, see tobjectlinker in lib/common/kernel/mseclasses.pas.
Another possibility is to use a tobjectevent descendant and 
application.postevent.

> Am I on the right track here? I am particularly interested in what happens
> when the objects passing the routines are destroyed without the data module
> knowing about it.

The program most likely will crash. :-)

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal