tag:blogger.com,1999:blog-2428374771421713311.post5447796062962794898..comments2024-03-10T12:04:17.661-07:00Comments on The Oracle at Delphi: Multicast Events - the finaleAnonymoushttp://www.blogger.com/profile/10119008505905401707noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-2428374771421713311.post-44783649649089733902008-09-04T17:22:04.000-07:002008-09-04T17:22:04.000-07:00Ouch, the blog engine ate (again) the angular brac...Ouch, the blog engine ate (again) the angular braces. Rewritting the code:<br><br>if Assigned(FDataSource) then<br>if Assigned(FDataSource.FDataSet) then<br>...m. Th.noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-26759863098202008402008-09-04T15:14:14.000-07:002008-09-04T15:14:14.000-07:00disregard "FooComp would rather be a descende...disregard "FooComp would rather be a descendent o TDataSource"danielhttp://sourceware.org/gdb/wiki/STLSupportnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-88528452546004787702008-09-04T17:19:13.000-07:002008-09-04T17:19:13.000-07:00@Daniel:#1:Somewhat but not quite. Let's get o...@Daniel:<br><br>#1:<br>Somewhat but not quite. Let's get out from Windows box. For example see:<br><br>http://en.wikipedia.org/wiki/Erlang_(programming_language)<br><br>and go to "Concurrency and distribution oriented language" chapter. (there, the definition for 'process' is different for a regular OS process, take care).<br><br>Also, you can have a look at<br><br>http://en.wikipedia.org/wiki/Oz_programming_language<br><br>"Message passing concurrency" part.<br><br>And, perhaps, the accolade at:<br><br>http://en.wikipedia.org/wiki/Message_passing<br><br>(especially the "OOP" part)<br><br>...and, yes, my request is somewhat outside of the main topic of Allen's post.<br><br>#2:<br>Yes, nowadays we must use notifications to implement this. And we must do hard-wired/specialized/"premeditated" :-) code to do this, ie.<br><br>if FDataSourcenil then<br>if FDataSet.DataSetnil then<br>begin<br>FOldBeforePost:=FDataSource.DataSet.BeforePost;<br>FDataSource.DataSet.BeforePost:=FNewBeforePost;<br>end; //...to attach<br><br>(and similar code to 'detach' it)<br>...also code (as we both said) "somewhere else" to handle the parts lifetime (eg. wh/if FDataSource dies? wh/if FDataSource.DataSet dies/changes?) so we have a whole bunch of (almost) non-reusable code spreaded through the class in order to handle this.<br><br>What I'm asking is:<br><br>Can I have in TFooComp.SetDataSource(Value: TDataSource) something like TDataSource.DataSet.BeforePost add MyNewHandler?<br><br>...and everything to be managed automatically, preferably /without/ having a TComponentMulticastEvent in each TFooComp instance. Imho, your answer, although quite ok, doesn't address quite well this central (and single) point of my previous post.<br><br>Just my2c & HTH,<br><br>m. Th.m. Th.noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-49664526082392809602008-09-04T15:11:48.000-07:002008-09-04T15:11:48.000-07:00RE_1>This is like saying that we need a window-...RE_1>This is like saying that we need a window-proc in TObject. Allen just posted an example of a (potentially) many to many relation between events and event handlers, implemented via generics (read: c++ templates)<br>RE_2>Since DataSource property is known (as datatype: TDataSource) and you expressed premeditation in delegating events of DataSource.DataSet, you already know "something" (a lot) about the outside world. Since TDataSource makes composition with its DataSet property, the only way to handle what you said you would have to use notifications anyway. How can TFooComp be deployed in an "unknown code" since you already subscribed to ancestor class contract and most like to DataSource and further on to DataSource.DataSet via simple composition? (TFooComp "has a"). Of course, in your example TFooComp would rather be a descendent o TDataSource... If you look at the source of TSimpleDataset (interesting coincidence, from what I remember, Allen baptized that component many years ago...) you will see that composition (with or without delegation) go hand in hand... Generic delegation is brilliant and, since you were wondering, it's "safe" (as in early binding, or compiler front-end checked). In a way, your "business as usual" components are dbAware controls... Just in a way... So, lets not judge the model by assuming that helpers are anything but helpers...<br><br>Allen, Thanks again, Cool!<br><br>Yours,<br>Danieldanielhttp://sourceware.org/gdb/wiki/STLSupportnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-88279291934023840402008-09-03T19:13:26.000-07:002008-09-03T19:13:26.000-07:00Nice thing Allen. I must confess that I didn't...Nice thing Allen. I must confess that I didn't follow very close your posts now due of lack of time but I intend to do it. However some notes:<br><br>1. Imho, a message queue in TObject it is badly needed, not only for having Notification method for the above purposes but this is also a central piece in parallel programming - for ex. Actor model, Erlang, Oz programming languages etc. Having such a structure at root of the class system also gives us new perspectives in expresing inter-object interactions (think only about Windows's messaging system and what was achieved with it...)<br><br>2. A common usage pattern is:<br>- I made my <br>TFooComp = class(TComponent)<br>property DataSource: TDataSource read FDataSource write FDataSource; //or whatever...<br>...<br>end;<br><br>...and I want to hook/add functionality to (some of) the FDataSource.DataSet's events. <br><br>How can be this done in a 'safe' manner with your implementation, a.) without knowing nothing about the 'outside world' (ie. my TFooComp will be deployed/used in an unknown code) b.) allowing the possibility of using many instances of TFooComp class, preferably without having each instance its MultiCast Manager?<br><br>HTH & TIA,<br><br>m. Th.m. Th.noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-32149923778717508572010-04-18T17:22:29.000-07:002010-04-18T17:22:29.000-07:00Great set of articles on Multicasting events. It w...Great set of articles on Multicasting events. It would be immensely helpful if you could make available the source code for your posts to fill in the gaps of understanding. Thanks.Colin Jnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-23139917185942424082010-02-18T13:09:50.000-08:002010-02-18T13:09:50.000-08:00Any source code available ?Any source code available ?Michael Jungnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-80841263369252846472010-10-04T18:37:13.000-07:002010-10-04T18:37:13.000-07:00I join to all the requests for source code, will h...I join to all the requests for source code, will help fill in the gaps and understand, maybe the community could enhance and make a project of it for all to useLiran Shaharnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-19585438766619578282011-04-12T20:59:03.000-07:002011-04-12T20:59:03.000-07:00You'll find a working implementation of the 1s...You'll find a working implementation of the 1st article in <br>http://stackoverflow.com/questions/1225256/getting-allen-bauers-tmulticasteventt-working<br><br>Cheers,<br>RalfRalf Steinhaeussernoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-24613747238684785962009-08-31T03:47:52.000-07:002009-08-31T03:47:52.000-07:00Is the code for these three blog posts available ...Is the code for these three blog posts available as a downloadable demo .zip file? That would be handy. I think it would make an excellent Developer Network posting.<br><br><br>WarrenWarren Postmanoreply@blogger.com