/* Part of this file reproduces source code in sigc++/slot.h, sigc++/object_slot.h and sigc++/bind.h to which Karl Einar Nelson owns the copyright. The remainder of this file is copyright (C) Chris Vine 2004 to 2006 This program is distributed under the General Public Licence, version 2. For particulars of this and relevant disclaimers see the file COPYING distributed with the source files. */ // this file enables the libsigc++-2.0 syntax used in this program to compile with // libsigc++-1.2 #ifndef SIGC_COMPATIBILIY_H #define SIGC_COMPATIBILIY_H #include namespace sigc { //sigc::connection --> SigC::Connection typedef SigC::Connection connection; // sigc::trackable --> Sigc::Object typedef SigC::Object trackable; //sigc::signal0 --> Sigc::Signal0 (with default marshaller) template class signal0 : public SigC::Signal0 {}; //sigc::signal1 --> Sigc::Signal1 (with default marshaller) template class signal1 : public SigC::Signal1 {}; //sigc::signal2 --> Sigc::Signal2 (with default marshaller) template class signal2 : public SigC::Signal2 {}; // this is necessary for the next five template functions // sigc::slot --> SigC::Slot0 (user declared slot taking member function with no argument) template struct slot : public SigC::Slot0 { slot(SigC::SlotNode* s): SigC::Slot0(s) {} slot(R (*f)()): SigC::Slot0(f) {} slot(const SigC::Slot0& s): SigC::Slot0(s) {} }; /* In these bind functions it would be much easier to do it by uncommenting the return statements in each of these functions by calling SigC::bind directly. However although gcc-2.95 and gcc-3 accepts this, for some reason gcc-4 does not. Accordingly the relevant implementations of SigC::bind in sigc++/bind.h are reproduced 'in extenso' */ // sigc::bind --> SigC::bind (for passing one argument to a slot connected // to a signal passing no arguments) template slot bind(const SigC::Slot1& s, A1 a1) { //return SigC::bind (s, a1); typedef typename SigC::AdaptorBindData1_ Data; typedef typename SigC::AdaptorBindSlot0_1_ Adaptor; return reinterpret_cast( new Data((SigC::FuncPtr)(&Adaptor::proxy),s, (SigC::FuncPtr)(&Data::dtor),a1)); } // sigc::bind --> SigC::bind (for passing two arguments to a slot connected // to a signal passing no arguments) template slot bind(const SigC::Slot2& s, A1 a1, A2 a2) { //return SigC::bind (s, a1, a2); typedef typename SigC::AdaptorBindData2_ Data; typedef typename SigC::AdaptorBindSlot0_2_ Adaptor; return reinterpret_cast( new Data((SigC::FuncPtr)(&Adaptor::proxy),s, (SigC::FuncPtr)(&Data::dtor),a1,a2)); } /* The remainder of these templated functions implement sigc::ptr_fun() and sigc::mem_fun() in terms of SigC::slot. For the mem_fun functions it would be much easier to do it by uncommenting the return statements in each of these functions by calling SigC::slot directly. However gcc-2.95 chokes on this with an internal compiler error. Accordingly the relevant implementations of SigC::slot in sigc++/slot.h and sigc++/object_slot.h are reproduced 'in extenso' */ //sigc::ptrfun() --> SigC::slot (for function taking no arguments) template slot ptr_fun(R (*func)()) { return func; } //sigc::memfun() --> SigC::slot (for class member function taking no arguments) template slot mem_fun(O1& obj,R (O2::*method)()) { //return slot (obj, method); typedef typename SigC::ObjectSlot0_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() const --> SigC::slot const (for class member function taking no arguments) template slot mem_fun(O1& obj,R (O2::*method)() const) { //return slot (obj, method); typedef typename SigC::ObjectSlot0_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot (for class member function taking one argument) template SigC::Slot1 mem_fun(O1& obj,R (O2::*method)(P1)) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot1_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() const --> SigC::slot const (for class member function taking one argument) template SigC::Slot1 mem_fun(O1& obj,R (O2::*method)(P1) const) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot1_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot (for class member function taking two arguments) template SigC::Slot2 mem_fun(O1& obj,R (O2::*method)(P1,P2)) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot2_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot const (for class member function taking two arguments) template SigC::Slot2 mem_fun(O1& obj,R (O2::*method)(P1,P2) const) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot2_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot (for class member function taking three arguments) template SigC::Slot3 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3)) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot3_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot const (for class member function taking three arguments) template SigC::Slot3 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3) const) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot3_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot (for class member function taking four arguments) template SigC::Slot4 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3,P4)) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot4_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot const (for class member function taking four arguments) template SigC::Slot4 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3,P4) const) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot4_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot (for class member function taking five arguments) template SigC::Slot5 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3,P4,P5)) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot5_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot const (for class member function taking five arguments) template SigC::Slot5 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3,P4,P5) const) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot5_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot (for class member function taking six arguments) template SigC::Slot6 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3,P4,P5,P6)) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot6_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } //sigc::memfun() --> SigC::slot const (for class member function taking six arguments) template SigC::Slot6 mem_fun(O1& obj,R (O2::*method)(P1,P2,P3,P4,P5,P6) const) { //return SigC::slot (obj, method); typedef typename SigC::ObjectSlot6_ SType; O2& obj_of_method = obj; return new SigC::ObjectSlotNode((SigC::FuncPtr)(&SType::proxy), &obj, &obj_of_method, method); } } #endif