1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \----------------------------------------------------------------------/
10 * This file contains private API, this might break at any time between releases.
11 * You have been warned!
14 #ifndef ZYPP_NG_BASE_SIGNALS_H_INCLUDED
15 #define ZYPP_NG_BASE_SIGNALS_H_INCLUDED
17 #include <sigc++/trackable.h>
18 #include <sigc++/signal.h>
19 #include <sigc++/connection.h>
24 using sigc::connection;
25 using sigc::trackable;
27 template <class R, class... T>
31 * Hides the signals emit function from external code.
33 * \note based on Glibmms SignalProxy code
35 template <class R, class... T>
36 class SignalProxy<R(T...)>
39 using SlotType = sigc::slot<R(T...)>;
40 using SignalType = sigc::signal<R(T...)>;
42 SignalProxy ( SignalType &sig ) : _sig ( sig ) {}
44 /** Connects a signal handler to a signal.
46 * For instance, connect(sigc::mem_fun(*this, &TheClass::on_something));
48 * @param slot The signal handler, usually created with sigc::mem_fun() or sigc::ptr_fun().
49 * @return A sigc::connection.
51 connection connect( const SlotType& slot )
53 return _sig.connect( slot );
56 /** Connects a signal handler to a signal.
57 * @see connect(const SlotType& slot).
59 connection connect( SlotType&& slot )
61 return _sig.connect( std::move( slot ) );
71 #endif // ZYPP_NG_CORE_SIGNALS_H_INCLUDED