[OpenWalnut-Dev] WItemSelection & friends improvement
Sebastian Eichelbaum
eichelbaum at informatik.uni-leipzig.de
Mon May 14 15:56:56 CEST 2012
Hi
This is a nice idea. But technically, there are several things to do to achieve this:
You will need to derive a new templatized class from WItemSelectionItem AND simultanously derive from the template type T. With this, you can use a queried WItemSelectorItem as your own type directly:
template< typename T >
class WIteSelectionItemTyped: public WItemSelectionItem,
public T
Luckily, these items are handled using pointers. If they would be handles as copies throughout the WItemSelection, your explicitly derived typing would be lost. Now, you can provide a method to WItemSelectionItem:
const T& getValue() const;
and
T& getValue()
{
return *dynamic_cast< T* >( this );
}
.. Then you would be able to use the item you query with WItemSelector::at
mySelector->at( someIndex )->getValue< MyType >().MyFunction();
Even nicer would be to also provide WItemSelector::at and atAll with some template type to directly return a pointer to the WItemSelectionItemTyped instance ... awesome :-)
If you implement something like this, we would be very happy to get a patch from you. You can create such a patch via hg export:
$ hg pull -u
$ edit files
$ hg commit -m "[ADD] our nice feature"
$ hg export
The exported patch can be added by us to the upstream code and next time you do a hg pull, you can merge the stuff in.
Thank you for your idea!
If you have any problems when doing this, just drop a mail to the list!
Sebastian
On Mon, 14 May 2012, Christof Pieloth wrote:
> Hello everybody,
>
> we are using a "WItemSelection" & friends very often in our project
> and missing a feature.
> In most of our cases we fill a "WItemSelection" with an enum and
> have to code our own mapper to get the corresponding enum value for
> the selected "WItemSelectionItem", which we get from
> "WItemSelector.at()". We may can extend "WItemSelectionItem" to a
> template to hold a value of a generic type and a method like "T
> WItemSelectionItem.getValue()". So you can use a switch-case
> straight away.
> What are you thinking of this idea?
>
> Best regards
> Christof
>
> --
> HTWK Leipzig, University of Applied Sciences
> Faculty of Electrical Engineering and Information Technology
> Laboratory for Biosignal Processing (LaBP)
>
> fon: +49 (0) 341 3076 3133
> fax: +49 (0) 341 3076 853133
> mail: pieloth 'at' labp.htwk-leipzig.de
>
>
> _______________________________________________
> OpenWalnut-Dev mailing list
> OpenWalnut-Dev at lists.informatik.uni-leipzig.de
> http://lists.informatik.uni-leipzig.de/mailman/listinfo/openwalnut-dev
>
> Archive: http://lists.informatik.uni-leipzig.de/pipermail/openwalnut-dev/
>
--
Dipl.-Inf. Sebastian Eichelbaum
Universität Leipzig
Institut für Informatik
Abteilung Bild- und Signalverarbeitung
PF 100920
D-04009 Leipzig
More information about the OpenWalnut-Dev
mailing list