1 #ifndef __pbd_shiva_h__
2 #define __pbd_shiva_h__
4 #include <sigc++/sigc++.h>
8 template<typename ObjectWithGoingAway, typename ObjectToBeDestroyed>
10 /* named after the Hindu god Shiva, The Destroyer */
14 Shiva (ObjectWithGoingAway& emitter, ObjectToBeDestroyed& receiver) {
16 /* if the emitter goes away, destroy the receiver */
18 _connection1 = emitter.GoingAway.connect
19 (sigc::bind (sigc::mem_fun
20 (*this, &Shiva<ObjectWithGoingAway,ObjectToBeDestroyed>::destroy),
23 /* if the receiver goes away, forget all this nonsense */
25 _connection2 = receiver.GoingAway.connect
26 (sigc::mem_fun (*this, &Shiva<ObjectWithGoingAway,ObjectToBeDestroyed>::forget));
34 sigc::connection _connection1;
35 sigc::connection _connection2;
37 void destroy (ObjectToBeDestroyed* obj) {
43 _connection1.disconnect ();
44 _connection2.disconnect ();
51 #endif /* __pbd_shiva_h__ */