[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: koffice/lib/kofficecore
From:       Werner Trobin <trobin () kde ! org>
Date:       2004-07-06 5:15:11
Message-ID: 200407060715.11950.trobin () kde ! org
[Download RAW message or body]

On Tuesday 06 July 2004 02:01, David Faure wrote:
> CVS commit by faure: 
> 
> Dug up Werner's generic command, to make it easier to write undo/redo 
commands that
> simply set a property on an object. In order to make it work with methods 
taking
> a bool I had to write another version of it (otherwise it was looking for 
setFoo(const bool&)).
> Any way to do this better?

Yes. The solution would be to use type traits for the Property template 
parameter to determine the "OptimalParamType". This would also fix some other 
problems with the code (e.g. that you can't use a reference as property type 
as it would result in a reference to a reference inside the template).

You can find an example at: 
http://courses.iicm.edu/ak_swent/examples_20040622.tar.gz (from a course I 
attended this semester :-)

The interesting files are:
- type_traits.h
- type_traits_test.cpp
- select_type.h

You might also want to look at the generalized functor which is way more 
flexible than our solution (generalized_functor.h, typelist.h, 
hook_example.cpp,...). This version is different from Alexandrescu's original 
solution and IMHO it's a better solution in some areas.

Another nice idea can be found in the mks_unit* files, but that's totally 
unrelated to our problem.

Please contact me if there are problems with German comments in the code (they 
should be English, but you never know). There also would be a (German) text 
and slides for all those examples, so in case you need more context please 
send a mail. Some details in the generalized functor code are weird :-)

Ciao,
Werner
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic