Using C++ Boost libraries for KDevelop
Vladimir Prus
ghost at cs.msu.su
Thu Nov 17 10:45:08 UTC 2005
Hi,
the more I work on debugger, the more I think that using some libraries from
C++ Boost would simplify the code quite a bit.
For example, I send a command to debugger and want to be notified when that
command finished. Currently, there's no such way, at all. All possible
solutions are pretty clumsy.
With C++ Boost, specifically with Boost.Function and Boost.Bind libraries,
things will be improved a lot, I'll be able to write this:
class GDBController {
public:
void queueCmd(const QString& command,
boost::function<void ()> callback);
};
class SomeOtherClass {
public:
void do_operation()
{
controller->queueCmd(
"whatever",
boost::bind(&SomeOtherClass::step_2, this));
}
void step_2()
{
// Continue with the operation.
}
};
Here:
- boost::function<void ()> is a generic functional object taking
no arguments and returning nothing
- boost::bind in the above example takes method pointer, and this,
and binds them together. The resulting class instance can be
called with zero arguments.
The libraries in question are header-only -- they don't require any linking,
so this reduces problems somehow.
So, what is the general opinion about this:
- is it OK to add extra third party dependencies, in general
- any conditions the dependency must fulfill?
- it is best to rely on pre-installed dependency, or package it
with KDevelop?
- Volodya
More information about the KDevelop-devel
mailing list