|
Boost Users : |
From: Pau Garcia i Quiles (pgquiles_at_[hidden])
Date: 2008-04-10 18:24:44
Hello,
(There were some errors in the parametrized.cpp source file in my
original submission, they are fixed now)
I'm trying to implement something like the registerField/field methods
of QWizard from Qt (
http://doc.trolltech.com/4.4beta/qwizard.html#registering-and-using-fields )
but without Qt.
Long story short, what I'm trying to do is to have a list of member
functions I should call to get a value from an instance of a class.
There will be *hundreds* of different classes with different accessor
methods (sometimes it will be called "value()", others "text()", yet
in other cases it may be "isEnabled()"). Return types will also be
different, but that's already solved by boost::any.
I'm attaching two examples of what I want to achieve:
* nonparametrized.cpp: it works fine but it's not parametrized
* parametrized.cpp: it's essentially the nonparametrized.cpp code
but introducing a new class called "Proxy" which has a "field" method
which should receive the parameters boost::function needs.
Problem is, for parametrized.cpp I cannot figure what the signature of
the "field" method (line 27) should be in order to call it for
different objects (see lines 48, 61 and 74). I'm not even sure I need
to specify those three parameters! Can you help me?
Code can be compiled against Boost 1.34.1 (not tested against 1.35.0) with:
g++ -o nonparametrized nonparametrized.cpp -lboost_signals
Thank you.
-- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net