On Tuesday 04 December 2007 05:54:04 pm Ladislav Slezak wrote:
Hello all,
I'm improving callback implementation in pkg-bindings, I'd like to add a total progress and the callbacks should be displayed in the main dialog (instead of popups).
I'm reusing zypp::ProgressData class with zypp::CombinedProgressData class which provides a sub progress for a sub task. That's nice.
But I have a problem, I can register only bool function(const zypp::ProgressData&) as the receiver function, I'd like to register bool MyClass::function(const zypp::ProgressData&)
Hi Ladislav Well, you can't register a function of a class because if the function is not static, you actually need an instance of the class. The solution for this is to use boost::bind, which we use a lot in ZYpp. If you look at the YUM parser code, which uses callbacks a lot for data consuming, you can use boost bind to get a functor object using it like this: bind(&RepoParser::Impl::repomd_CB, this, _1, _2)); That means, use the repomd_CB function of that class, on the this object, and then the parameters order (you can even invert or ignore parameters when binding), the result of that expression is a functor you can use in place of any functor, so you can set the ProgressData progress callback to the result of a bind expression. Don't hesitate to ask again in doubt! boost is tricky, Duncan -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org