Home · All Classes · All Namespaces · Modules · Functions · Files |
Callbacks are used in Telepathy-Qt by the service side high-level APIs to expose methods that may/should be overriden in implementations.
Ideally we would use virtual methods for this, but as new methods can be added freely (when interfaces change), we would not be able to guarantee a stable API/ABI. Other options, such as virtual padding, virtual_hook and Qt slots also have their own drawbacks.
There are 8 Callback classes, Tp::Callback0 to Tp::Callback7, which define a callback with 0 to 7 arguments respectively. The first template argument is always the return value type and the rest template arguments are the types of the callback arguments in the order that they are passed to the callback.
Callback classes can be constructed from a functor. To make it easy to use function pointers as functors, Telepathy-Qt also provides two helper functions, Tp::memFun and Tp::ptrFun.
Here is an example of their usage:
You are also free to use any other mechanism for constructing functors, such as boost::bind, C++11's <functional> module or even C++11 lambda functions.
Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation | Telepathy-Qt 0.9.7 |