[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [paragui-dev] small fixes and template question
From: |
Alexander Pipelka |
Subject: |
Re: [paragui-dev] small fixes and template question |
Date: |
Mon, 05 Sep 2005 23:04:18 +0200 |
Am Montag, den 05.09.2005, 21:56 +0200 schrieb Martin Bickel:
> Hi,
>
> here are some small improvements for Paragui, which should be
> self-explanatory. I've also replaced the type-cast in
> pglistboxbaseitem.cpp to use RuntimeTypeInformation to make it at least
> return a NULL-Pointer if it goes wrong. I think we can assume to have
> RTTI available, can't we?
Nope. I really cared to make ParaGUI work *without* RTTI and exceptions.
I'm using ParaGUI mainly on embedded devices where i need to squeeze
down the size of the binaries. But it should be perfectly ok to use a
compile time switch.
> But the design should definitly be fixed in that area. I tried changing
> PG_ListBoxItem constructor to only accept PG_ListBox* as parent, but
> this breaks PG_DropDown::AddItem , because it constructs PG_ListBoxItem
> with a PG_DropDown as parent. I think this is a major design error,
> because the current C-style cast will result in complely unpredictable
> behaviour in that case.
Right. My fault. I've never gotten to the point to make myself fixing
this (hmm,.. it works. so i'm lazy).
> And I have a question about the signal definition, which I've been
> wondering about since I've first seen them. What is the purpose of a
> templated signal definition like this:
>
> class Something {
>
> template<class datatype = PG_Pointer> class SignalButtonClick : public
> PG_Signal1<PG_Button*, datatype> {};
> SignalButtonClick<> sigClick;
>
> What's the difference to a non-templated definition like:
>
> typedef PG_Signal1<PG_Button*, PG_Pointer> SignalButtonClick;
> SignalButtonClick sigClick;
>
>
> This first one is obviously a member template, but while I can see the
> purpose of member template functions, I've got real problems
> understanding data member templates.
Basically, there isn't any difference at all :)
It's just for convenience. With the template it's possible to do
something like:
class MyVerySpecialClass {
PG_Button::SignalButtonClick<MyVerySpecialDataType> sigMyButtonClick;
}
Which will emit a "SignalButtonClick" signal with custom datatype bound
to it.
Alex
PS: Patch applied (without the dynamic_cast)