59 unsigned long m_ref_count ;
69 G_EXCEPTION( AlreadyConnected ,
"signal already connected to a slot" ) ;
101 SlotImp0( T &
object ,
void (T::*fn)() ) : m_object(object) , m_fn(fn) {}
108 template <
typename T>
129 Slot0(
const Slot0 & other ) : m_imp(other.m_imp) , m_op(other.m_op) {
if(m_imp) m_imp->
up() ; }
145 explicit Signal0(
bool once =
false ) : m_emitted(false) , m_once(once) {}
146 void emit() {
if(!m_once||!m_emitted) { m_emitted = true ; m_slot.
callback() ; } }
149 void reset() { m_emitted = false ; }
155 template <
typename T>
166 template <
typename T,
typename P>
171 void (T::*m_fn)( P ) ;
173 SlotImp1( T &
object ,
void (T::*fn)(P) ) : m_object(object) , m_fn(fn) {}
180 template <
typename T,
typename P>
191 template <
typename P>
201 void callback( P p ) {
if( m_imp ) (*m_op)( m_imp , p ) ; }
202 Slot1(
const Slot1<P> & other ) : m_imp(other.m_imp) , m_op(other.m_op) {
if(m_imp) m_imp->
up() ; }
211 template <
typename P>
219 explicit Signal1(
bool once =
false ) : m_emitted(false) , m_once(once) {}
220 void emit( P p ) {
if(!m_once||!m_emitted) { m_emitted = true ; m_slot.
callback( p ) ; } }
223 void reset() { m_emitted = false ; }
229 template <
typename T,
typename P>
240 template <
typename T,
typename P1,
typename P2>
245 void (T::*m_fn)( P1 , P2 ) ;
247 SlotImp2( T &
object ,
void (T::*fn)(P1,P2) ) : m_object(object) , m_fn(fn) {}
248 void callback( P1 p1 , P2 p2 ) { (m_object.*m_fn)(p1,p2) ; }
254 template <
typename T,
typename P1 ,
typename P2>
265 template <
typename P1,
typename P2>
270 void (*m_op)(
SlotBase * , P1 , P2 ) ;
275 void callback( P1 p1 , P2 p2 ) {
if( m_imp ) (*m_op)( m_imp , p1 , p2 ) ; }
285 template <
typename P1,
typename P2>
293 explicit Signal2(
bool once =
false ) : m_emitted(false) , m_once(once) {}
294 void emit( P1 p1 , P2 p2 ) {
if(!m_once||!m_emitted) { m_emitted = true ; m_slot.
callback( p1 , p2 ) ; } }
297 void reset() { m_emitted = false ; }
303 template <
typename T,
typename P1,
typename P2>
314 template <
typename T,
typename P1,
typename P2,
typename P3>
319 void (T::*m_fn)( P1 , P2 , P3 ) ;
321 SlotImp3( T &
object ,
void (T::*fn)(P1,P2,P3) ) : m_object(object) , m_fn(fn) {}
322 void callback( P1 p1 , P2 p2 , P3 p3 ) { (m_object.*m_fn)(p1,p2,p3) ; }
328 template <
typename T,
typename P1 ,
typename P2,
typename P3>
339 template <
typename P1,
typename P2,
typename P3>
344 void (*m_op)(
SlotBase * , P1 , P2 , P3 ) ;
349 void callback( P1 p1 , P2 p2 , P3 p3 ) {
if( m_imp ) (*m_op)( m_imp , p1 , p2 , p3 ) ; }
359 template <
typename P1,
typename P2,
typename P3>
367 explicit Signal3(
bool once =
false ) : m_emitted(false) , m_once(once) {}
368 void emit( P1 p1 , P2 p2 , P3 p3 ) {
if(!m_once||!m_emitted) { m_emitted = true ; m_slot.
callback( p1 , p2 , p3 ) ; }}
371 void reset() { m_emitted = false ; }
377 template <
typename T,
typename P1,
typename P2,
typename P3>
380 return Slot3<P1,P2,P3>(
new SlotImp3<T,P1,P2,P3>(object,fn) ,
SlotOp3<T,P1,P2,P3>::callback ) ;
Slot1(const Slot1< P > &other)
const SlotBase * base() const
SlotImp2(T &object, void(T::*fn)(P1, P2))
A noncopyable base class (a la boost).
void connect(Slot1< P > slot)
Part of the slot/signal system.
Part of the slot/signal system.
Part of the slot/signal system.
SlotImp3(T &object, void(T::*fn)(P1, P2, P3))
Slot1(SlotBase *imp, void(*op)(SlotBase *, P))
const SlotBase * base() const
const SlotBase * base() const
Part of the slot/signal system.
void swap(Slot1< P > &rhs)
Part of the slot/signal system.
void connect(Slot3< P1, P2, P3 > slot)
void swap(Slot3< P1, P2, P3 > &rhs)
Slot0 slot(T &object, void(T::*fn)())
Part of the slot/signal system.
SlotImp0(T &object, void(T::*fn)())
Part of the slot/signal system.
Part of the slot/signal system.
Part of the slot/signal system.
static void callback(SlotBase *imp, P p)
Slot0(const Slot0 &other)
Part of the slot/signal system.
void operator=(const Slot3< P1, P2, P3 > &rhs)
void callback(P1 p1, P2 p2)
static void check(const SlotBase *p)
static void callback(SlotBase *imp, P1 p1, P2 p2)
Part of the slot/signal system.
SlotBase()
Default constuctor.
Slot3(SlotBase *imp, void(*op)(SlotBase *, P1, P2, P3))
void operator=(const Slot0 &rhs)
Slot2(SlotBase *imp, void(*op)(SlotBase *, P1, P2))
const SlotBase * base() const
static void callback(SlotBase *imp)
void swap_(T &t1, T &t2)
Part of the slot/signal system.
Slot0(SlotBase *imp, void(*op)(SlotBase *))
void callback(P1 p1, P2 p2, P3 p3)
Part of the slot/signal system.
void callback(P1 p1, P2 p2, P3 p3)
Part of the slot/signal system.
Part of the slot/signal system.
Slot2(const Slot2< P1, P2 > &other)
void operator=(const Slot2< P1, P2 > &rhs)
Part of the slot/signal system.
void emit(P1 p1, P2 p2, P3 p3)
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
virtual ~SlotBase()
Destructor.
void down()
Decrements the reference count and does "delete this" on zero.
void operator=(const Slot1< P > &rhs)
void swap(Slot2< P1, P2 > &rhs)
Part of the slot/signal system.
static void callback(SlotBase *imp, P1 p1, P2 p2, P3 p3)
void up()
Increments the reference count.
Slot3(const Slot3< P1, P2, P3 > &other)
Part of the slot/signal system.
void connect(Slot2< P1, P2 > slot)
Part of the slot/signal system.
SlotImp1(T &object, void(T::*fn)(P))
void callback(P1 p1, P2 p2)
Part of the slot/signal system.