Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #14045
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: Event handler in c++ |
| Date | Wed, 15 Feb 2012 07:17:43 +1300 |
| Lines | 55 |
| Message-ID | <9pvmq7FaapU1@mid.individual.net> (permalink) |
| References | <707d72e5-d35d-412c-bac8-efe54ad365cb@z12g2000yqm.googlegroups.com> <jfh8ub$fmg$1@dont-email.me> <9o2teeFeiaU1@mid.individual.net> <64c600db-1c76-44c3-9b64-41723d68754a@s7g2000vby.googlegroups.com> <66228237-d278-44c6-a491-471b9073dfa9@hb4g2000vbb.googlegroups.com> <30919923.35.1329214493307.JavaMail.geo-discussion-forums@pbbmr9> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net MGHx+Nk9i/oHMDWoH0js0QtL2i5YSqHArNmOG9jC3LEsxnRkG2 |
| Cancel-Lock | sha1:uOpU30MkrHEfgvPcaodojfC+y0w= |
| User-Agent | Mozilla/5.0 (X11; SunOS i86pc; rv:6.0.2) Gecko/20111003 Thunderbird/6.0.2 |
| In-Reply-To | <30919923.35.1329214493307.JavaMail.geo-discussion-forums@pbbmr9> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:14045 |
Show key headers only | View raw
On 02/14/12 11:14 PM, 88888 Dihedral wrote:
> 在 2012年2月13日星期一UTC+8下午7时52分44秒,Robin Tucker写道:
>> I'm using a templated method to describe, dispatch and handle events
>> in an intuitive manner. For example, describing an event can be done
>> with something like this:
>>
>> Event<void(std::shared_ptr<Observable>, double, double, double)>
>> MyEvent;
>>
>> , for an event that takes 4 parameters (the "sender" and three
>> doubles). The handler looks like this:
>>
>> void OnEventHandler(std::shared_ptr<Observable> sender, double x,
>> double y, double z)
>> {
>> // Handle the event.
>> }
>>
>> And the event is dispatched in the following intuitive way:
>>
>> MyEvent(shared_from_this(), 3, 2, 1);
>>
>> It's type-safe and you can dispatch any number of parameters (up to 9
>> actually, in the absence of variadic templates in VS2010!). Anyway the
>> code and blog about it can be found here:
>>
>> http://drrobsjournal.blogspot.com/
>>
>> I hope this is useful to someone.
>
> C++ is not very good to be usd as a language to
> write device drives to be called by the OS.
Yes it is, you just have to provide the OS hooks as extern "C" functions.
> People working on the linux kernal talked about this
> problem for so long.
They are somewhat bigoted.
> Unless functions in the C++ container and template libraries are incorporated into the OS kernal library
> or system shared linked libraries, otherwise C++ compiled programs are too fat in the heap, too.
"too fat in the heap" ?
In kernel space you have two choices:
1) Use C++ as a better C and avoid the parts that require runtime support.
2) Use a statically linked run time library.
I use one where resources are tight and 2 where they are not.
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Event handler in c++ pratik lala <pratik3558@gmail.com> - 2012-01-22 06:42 -0800
Re: Event handler in c++ "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-01-22 16:11 +0100
Re: Event handler in c++ "osmium" <r124c4u102@comcast.net> - 2012-01-22 10:56 -0600
Re: Event handler in c++ Robert Wessel <robertwessel2@yahoo.com> - 2012-01-22 21:32 -0600
Re: Event handler in c++ Christopher <cpisz@austin.rr.com> - 2012-01-24 08:25 -0800
Re: Event handler in c++ Robin Tucker <robinmjtucker@gmail.com> - 2012-02-13 03:52 -0800
Re: Event handler in c++ 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-14 02:14 -0800
Re: Event handler in c++ Ian Collins <ian-news@hotmail.com> - 2012-02-15 07:17 +1300
Re: Event handler in c++ 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-14 11:51 -0800
Re: Event handler in c++ Ian Collins <ian-news@hotmail.com> - 2012-02-15 16:59 +1300
Re: Event handler in c++ MiB <michael.boehnisch@gmail.com> - 2012-02-15 02:11 -0800
Re: Event handler in c++ Ian Collins <ian-news@hotmail.com> - 2012-02-16 07:46 +1300
Re: Event handler in c++ Robert Wessel <robertwessel2@yahoo.com> - 2012-02-15 15:32 -0600
Re: Event handler in c++ MiB <michael.boehnisch@gmail.com> - 2012-02-16 17:56 -0800
Re: Event handler in c++ Rui Maciel <rui.maciel@gmail.com> - 2012-02-15 23:11 +0000
Re: Event handler in c++ pratik lala <pratik3558@gmail.com> - 2012-01-22 16:14 -0800
Re: Event handler in c++ "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-01-23 03:54 +0100
csiph-web