31 #include <boost/signals2.hpp>
32 namespace cinder {
namespace signals {
33 using namespace boost::signals2;
44 template<
typename SIG>
47 typedef typename std::vector<std::pair<CallbackId,std::function<SIG> > >
collection;
48 typedef typename collection::iterator
iterator;
53 if( ! mCallbacks.empty() )
54 cbId = mCallbacks.rbegin()->first + 1;
55 mCallbacks.push_back( std::make_pair( cbId, cb ) );
62 if( ! mCallbacks.empty() )
63 cbId = mCallbacks.rbegin()->first + 1;
64 mCallbacks.insert( position, std::make_pair( cbId, cb ) );
71 template<
typename A1,
typename A2>
73 template<
typename A1,
typename A2,
typename A3>
74 void call( A1 a1, A2 a2, A3 a3 ) {
for(
iterator it =
begin(); it !=
end(); ++it ) it->second( a1, a2, a3 ); }
75 template<
typename A1,
typename A2,
typename A3,
typename A4>
76 void call( A1 a1, A2 a2, A3 a3, A4 a4 ) {
for(
iterator it =
begin(); it !=
end(); ++it ) it->second( a1, a2, a3, a4 ); }
77 template<
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
78 void call( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ) {
for(
iterator it =
begin(); it !=
end(); ++it ) it->second( a1, a2, a3, a4, a5 ); }
82 bool empty()
const {
return mCallbacks.empty(); }
collection & getCallbacks()
Definition: Function.h:88
Implements a utility class for maintaining a list of callbacks.
Definition: Function.h:45
void call(A1 a1)
Definition: Function.h:70
CallbackId registerCb(iterator position, std::function< SIG > cb)
Definition: Function.h:59
uint32_t CallbackId
Represents a unique identifier for a callback.
Definition: Function.h:41
iterator begin()
Definition: Function.h:85
CallbackId registerCb(std::function< SIG > cb)
Definition: Function.h:50
std::vector< std::pair< CallbackId, std::function< SIG > > > collection
Definition: Function.h:47
void call(A1 a1, A2 a2, A3 a3)
Definition: Function.h:74
bool empty() const
Definition: Function.h:82
collection::iterator iterator
Definition: Function.h:48
iterator end()
Definition: Function.h:86
void unregisterCb(CallbackId cbId)
Definition: Function.h:80
void call(A1 a1, A2 a2)
Definition: Function.h:72
void call(A1 a1, A2 a2, A3 a3, A4 a4)
Definition: Function.h:76
void call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
Definition: Function.h:78
void call()
Definition: Function.h:68
iterator find(CallbackId cbId)
Definition: Function.h:84