Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #14045

Re: Event handler in c++

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Event handler in c++
Date 2012-02-15 07:17 +1300
Message-ID <9pvmq7FaapU1@mid.individual.net> (permalink)
References (1 earlier) <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>

Show all headers | 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


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