2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __ardour_extra_bind_h__
22 #define __ardour_extra_bind_h__
24 #include <sigc++/adaptor.h>
25 #include <sigc++/scope.h>
30 /****************************************************************
31 ***** Adaptor Bind Slot 0 arguments, 3 hidden arguments
32 ****************************************************************/
34 class C1, class C2, class C3>
35 struct AdaptorBindSlot0_3: public AdaptorSlot_
37 #ifdef SIGC_CXX_PARTIAL_SPEC
40 typedef typename Trait<R>::type RType;
42 typedef Slot0<R> SlotType;
43 typedef Slot3<R,C1,C2,C3> InSlotType;
45 struct Node:public AdaptorNode
52 typedef CallDataObj2<typename SlotType::Func,Node> CallData;
54 static RType callback(void* d)
56 CallData* data=(CallData*)d;
58 return ((typename InSlotType::Callback&)(node->data_))(
63 static SlotData* create(SlotData *s,C1 c1, C2 c2, C3 c3)
65 SlotData* tmp=(SlotData*)s;
66 Node *node=new Node();
67 copy_callback(tmp,node);
71 CallData &data=reinterpret_cast<CallData&>(tmp->data_);
72 data.callback=&callback;
79 #ifndef SIGC_CXX_VOID_RETURN
80 #ifdef SIGC_CXX_PARTIAL_SPEC
83 struct AdaptorBindSlot0_3
85 C1,C2,C3> : public AdaptorSlot_
88 typedef Slot0<void> SlotType;
89 typedef Slot3<void,C1,C2,C3> InSlotType;
91 struct Node:public AdaptorNode
98 typedef CallDataObj2<typename SlotType::Func,Node> CallData;
100 static RType callback(void* d)
102 CallData* data=(CallData*)d;
103 Node* node=data->obj;
104 ((typename InSlotType::Callback&)(node->data_))(
109 static SlotData* create(SlotData *s,C1 c1, C2 c2, C3 c3)
111 SlotData* tmp=(SlotData*)s;
112 Node *node=new Node();
113 copy_callback(tmp,node);
117 CallData &data=reinterpret_cast<CallData&>(tmp->data_);
118 data.callback=&callback;
127 template <class C1, class C2, class C3,
130 bind(const Slot3<R,C1,C2,C3> &s,
132 {return AdaptorBindSlot0_3<R,
133 C1,C2,C3>::create(s.data(),c1,c2,c3);
138 #endif /* __ardour_extra_bind_h__ */