|
Boost : |
From: Jesse Jones (jesjones_at_[hidden])
Date: 2001-05-02 20:15:11
[Hit the wrong key while I was composing this so a half written draft
slipped out. Sorry about that.]
I haven't looked at the new stuff closely but I do have a couple of comments:
1) I really want to be able to use operator== to test if two
callbacks have the same value. I have a lot of code that does stuff
like this:
class ITimer {
public:
virtual void AddTimer(function<void> callback, MilliSecond interval) = 0;
virtual void RemoveTimer(function<void> callback) = 0;
};
This is nice and simple, but requires support for equality tests...
2) The API is a bit more awkward than I would like. For example, I
have lots of code that looks sort of like this:
// About
function<void> action(this, &CApp::DoAbout);
handler->RegisterCommand(kAboutCmd, action, kDisabledIfDialog);
// Delete Formula
action = function<void> (this, &CApp::DoDeleteFormula);
function<SCommandStatus> enabler(this,
&CAppMenuHandler::DoEnableDeleteFormula);
handler->RegisterCommand(kDeleteFormulaCmd, action, enabler);
// Delete Palette
action = function<void> this, &CApp::DoDeletePalette);
enabler = function<SCommandStatus> (this, &CApp::DoEnableDeletePalette);
handler->RegisterCommand(kDeletePaletteCmd, action, enabler);
All of this boiler-plate is pretty annoying (and the real version
would be worse since I'd have to create some temporary functors to
bind the member function pointers). One thing that would help is to
get rid of all those temporary function objects. If the API directly
supported member functions you could do this with a set() method:
// About
function<void> action(this, &CApp::DoAbout);
handler->RegisterCommand(kAboutCmd, action, kDisabledIfDialog);
// Delete Formula
action.set(this, &CApp::DoDeleteFormula);
function<SCommandStatus> enabler(this,
&CAppMenuHandler::DoEnableDeleteFormula);
handler->RegisterCommand(kDeleteFormulaCmd, action, enabler);
// Delete Palette
action.set(this, &CApp::DoDeletePalette);
enabler.set(this, &CApp::DoEnableDeletePalette);
handler->RegisterCommand(kDeletePaletteCmd, action, enabler);
-- Jesse
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk