|
Boost : |
From: Brock Peabody (brock.peabody_at_[hidden])
Date: 2003-08-01 17:13:20
> -----Original Message-----
> From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]]
> On Behalf Of E. Gladyshev
> Sent: Friday, August 01, 2003 3:31 PM
> To: Boost mailing list
> Subject: RE: [boost] GUI/GDI template library
>
> > Even if the implementation is parameterized by a
> > traits or other class,
> > we could still use a non template class in the
> > implementation to reduce
> > compile times, which is what I though the original
> > poster was trying to
> > say.
> >
> > template <... typename ImplTraits> class
> > some_edit_class :
> > edit_control_wrapper {};
>
> Sorry, I don't understand how will this code reduce
> the compile time?
There may be code in some_edit_class<> that does not directly depend on
the template parameters. You should be able to find a way to put that
code into a non template class so you can hide it in a source file.
>
> >
> > Also, I wonder if we can delay specifying the
> > traits. It might be nice
> > to not have to mention it everywhere.
>
> It'd be nice but how can you do that? The only way I
> can see is using a default template parameter.
Here is a very simplified version of how this can happen.
template <typename Traits> struct edit_imp {...};
struct edit {
template <typename Traits> edit_imp<Traits> make_gui() {...}
};
template <typename Traits> struct gui_wrapper_base {
//some pure virtual functions
};
template <typename Traits, typename Control> struct gui_wrapper :
gui_wrapper_base<Traits> {
gui_wrapper(const Control& imp);
//implements virtual functions by forwarding to Control
private:
Control imp;
};
template <typename Traits> struct gui_application {
template <typename Control> gui_application(const Control&
control)
: pimpl(new gui_wrapper<Traits,Control>(control) {
}
//also assignment operator, etc...
//forward operations to pimpl
private:
boost::shared_ptr<gui_wrapper_base<Traits> > pimpl;
};
then your code might look something like:
gui_application<my_traits> gui = edit();
I'm kind of doing something like this in my code, but not for traits.
The virtual functions are unpleasant but hidden from the user. You
could get rid of the need for them if there were a typeof mechanism in
the language.
>
> I'd like to look at it. Where is it? You mentioned
> some yahoo thing. What is it?
I just learned aboutit today after my attachment was rejected for being
too large and I gave up on the sandbox :) It's at:
http://groups.yahoo.com/group/boost/files/
The name is boost_gui.zip. There is a ton of code, but the interface
example is in boost_gui_test/dialog.cpp. Some of the supporting code
has been evolved rather than designed and I would throw it out, I really
just want to show that the interface is viable. I'd love some feedback
even if you just want to tell me that my idea is bad :) I did look at
your program too, you could connect two controls with my code like:
set_manager( row( edit(&employee::name), edit(&employee::name)));
I kind of like another poster's (Mr. Bouchard I think) idea of default
control types. You might be able to simplify the above to:
set_manager( row( &employee::name, &employee::name));
I doubt if I could do this with VC 6 though!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk