This file is indexed.

/usr/include/sigx-2.0/sigx/tunnel_functor.h is in libsigx-2.0-dev 2.0.2-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
// -*- c++ -*-
/* Do not edit! -- generated file */


#ifndef _SIGXMACROS_TUNNEL_FUNCTOR_H_
#define _SIGXMACROS_TUNNEL_FUNCTOR_H_


/*
 * Copyright 2007 Klaus Triendl
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/**	@defgroup Functors Adaptors
 *	@short Useful sigc++ adaptors.
 */

#include <sigc++/sigc++.h>
#include <sigx/types.h>
#include <sigx/internal_types.h>
#include <sigx/tunnel_base.h>
#include <sigx/tunnel_context.h>
#include <sigx/ref.h>


namespace sigx
{


template<sync_type I_sync, typename T_functor>
struct tunnel_functor;

/**	@short creates a tunnel on the given functor.
 *	@note expects the functor to be dispatchable. A functor is dispatchable if
 *	the class the functor operates on is derived from sigx::dispatchable or if the 
 *	functor is or contains a SIGX_DISPATCH_WITH_FUNCTOR.
 *	@ingroup Functors
 *	@code
 *	// if class MyThread is dispatchable, sigc::mem_fun creates a dispatchable functor.
 *	open_tunnel(sigc::mem_fun(destobj, &MyThread::dosomething));
 *	// otherwise, create a dispatchable functor explicitly with dispatch_with
 *	open_tunnel_with(sigc::mem_fun(destobj, &MyThread::dosomething), dispatchable);
 *	open_tunnel_with(sigc::ptr_fun(&MyThread::dosomething_static), dispatchable);
 *	@endcode
 *	@attention Never invoke an asynchronous functor with arguments passed by
 *	reference with sigc::ref() (or at least not if you don't know exactly what 
 *	you are doing)!
 *	@note You have to be careful that T_functor, arguments bound to it and 
 *	passed arguments are threadsafe.
 *	Asynchronous tunnels copy T_functor and passed arguments on invokation of 
 *	the tunnel functor and destroy them in the context of the server thread 
 *	(the thread receiving the message which is different from the sender thread!).
 *	e.g. never do this:
 *	@code
 *	struct MyThread
 *	{
 *		void do_something(const GLib::RefPtr<X>& p) {}
 *	};
 *	
 *	Glib::RefPtr<X> p;
 *	open_tunnel(mythread, &MyThread::do_something)(p);
 *	@endcode
 *	For safety reasons you can apply this rule also for synchronous tunnels, 
 *	although the invokation behaves differently: Still T_functor is copied but
 *	passed arguments are sent by reference to the server thread.
 *	The same rules apply for sigx::request_f
 */
template<typename T_functor>
struct tunnel_functor<ASYNC, T_functor>: public sigc::adapts<T_functor>, public tunnel_base
{
	typedef typename sigc::adapts<T_functor>::adaptor_type adaptor_type;
	typedef typename adaptor_type::result_type result_type;

	template<typename T_arg1 = void, typename T_arg2 = void, typename T_arg3 = void, typename T_arg4 = void, typename T_arg5 = void, typename T_arg6 = void, typename T_arg7 = void>
	struct deduce_result_type
	{
		// we could also use sigc::deduce_result_type but this saves another
		// level of indirection and does what sigc++ does internally
		typedef typename adaptor_type::template deduce_result_type<typename sigc::type_trait<T_arg1>::pass, typename sigc::type_trait<T_arg2>::pass, typename sigc::type_trait<T_arg3>::pass, typename sigc::type_trait<T_arg4>::pass, typename sigc::type_trait<T_arg5>::pass, typename sigc::type_trait<T_arg6>::pass, typename sigc::type_trait<T_arg7>::pass>::type type;
	};


	result_type operator()()
	{
		return make_new_tunnel_context<ASYNC, result_type>(m_disp, m_validity_tracker, this->functor_)->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	result_type sun_forte_workaround()
	{
		return make_new_tunnel_context<I_sync, result_type>(m_disp, m_validity_tracker, this->functor_)->tunnel();
	}
	#endif

	template<typename T_arg1>
	typename deduce_result_type<T_arg1>::type
	operator()(T_arg1 _A_arg1)
	{
		typedef typename deduce_result_type<T_arg1>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1>
	typename deduce_result_type<T_arg1>::type
	sun_forte_workaround(T_arg1 _A_arg1)
	{
		typedef typename deduce_result_type<T_arg1>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2>
	typename deduce_result_type<T_arg1, T_arg2>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2>
	typename deduce_result_type<T_arg1, T_arg2>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6, T_arg7 _A_arg7)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6, _A_arg7))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6, T_arg7 _A_arg7)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type deduced_result_type;
		return make_new_tunnel_context<ASYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, _A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6, _A_arg7))->tunnel();
	}
	#endif


	
	/**	@short Constructs an adaptor that wraps the passed functor.
	 *	@param _A_func Functor to invoke at the other end of the tunnel 
	 *	from operator()().
	 *	@param dispatcher_change_is_cleanup Whether a dispatcher change should be
	 *	be treated as reason to destroy the tunnel
	 *	@note The passed in functor must be a "dispatchable functor", i.e.
	 *	a functor on a dispatchable's method or a functor created by 
	 *	sigx::dispatch_with.
	 */
	explicit tunnel_functor(typename sigc::type_trait<T_functor>::take _A_func): 
		sigc::adapts<T_functor>(_A_func), 
		// find the dispatchable object contained in the functor by 
		// stepping down the functor chain;
		// dispatchable_constraint finds the dispatchable and issues a compiler
		// error if the passed in functor is not a functor on a dispatchable's
		// method or does find a dispatchable in a SIGX_DISPATCH_WITH_FUNCTOR
		tunnel_base(internal::dispatchable_constraint<adaptor_type>::find_dispatchable(this->functor_))
	{}
	
	// implicit copy ctor is fine
	// implicit dtor is fine
	// implicit assignment operator is fine


	/**	@short	Activates validity tracking for sigc::trackableS and tracking of a dispatcher change 
	 *		(e.g. when a thread finishes its execution and resets its dispatcher)
	 *	@note	%activate_validity_tracking() assumes that the tunnel functor, all sigc::trackableS and the dispatcher/dispatchable 
	 *		are managed and accessed in the context of the calling thread.
	 */
	void activate_validity_tracking() const
	{
		validity_tracker().activate();

		// visit each trackable and bind the validity trackable to the sigc trackable and vice versa
		sigc::visit_each_type<sigc::trackable*>(
			sigc::mem_fun(validity_tracker(), &tunnel_validity_tracker::do_bind_to_trackable), 
			this->functor_
		);
	}
};

template<typename T_functor>
struct tunnel_functor<SYNC, T_functor>: public sigc::adapts<T_functor>, public tunnel_base
{
	typedef typename sigc::adapts<T_functor>::adaptor_type adaptor_type;
	typedef typename adaptor_type::result_type result_type;

	template<typename T_arg1 = void, typename T_arg2 = void, typename T_arg3 = void, typename T_arg4 = void, typename T_arg5 = void, typename T_arg6 = void, typename T_arg7 = void>
	struct deduce_result_type
	{
		// we could also use sigc::deduce_result_type but this saves another
		// level of indirection and does what sigc++ does internally
		typedef typename adaptor_type::template deduce_result_type<typename sigc::type_trait<T_arg1>::pass, typename sigc::type_trait<T_arg2>::pass, typename sigc::type_trait<T_arg3>::pass, typename sigc::type_trait<T_arg4>::pass, typename sigc::type_trait<T_arg5>::pass, typename sigc::type_trait<T_arg6>::pass, typename sigc::type_trait<T_arg7>::pass>::type type;
	};


	result_type operator()()
	{
		return make_new_tunnel_context<SYNC, result_type>(m_disp, m_validity_tracker, this->functor_)->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	result_type sun_forte_workaround()
	{
		return make_new_tunnel_context<I_sync, result_type>(m_disp, m_validity_tracker, this->functor_)->tunnel();
	}
	#endif

	template<typename T_arg1>
	typename deduce_result_type<T_arg1>::type
	operator()(T_arg1 _A_arg1)
	{
		typedef typename deduce_result_type<T_arg1>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1)))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1>
	typename deduce_result_type<T_arg1>::type
	sun_forte_workaround(T_arg1 _A_arg1)
	{
		typedef typename deduce_result_type<T_arg1>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1)))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2>
	typename deduce_result_type<T_arg1, T_arg2>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2)))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2>
	typename deduce_result_type<T_arg1, T_arg2>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2)))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3)))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3)))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4)))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4)))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4), sigx::ref(_A_arg5)))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4), sigx::ref(_A_arg5)))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4), sigx::ref(_A_arg5), sigx::ref(_A_arg6)))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4), sigx::ref(_A_arg5), sigx::ref(_A_arg6)))->tunnel();
	}
	#endif

	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type
	operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6, T_arg7 _A_arg7)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4), sigx::ref(_A_arg5), sigx::ref(_A_arg6), sigx::ref(_A_arg7)))->tunnel();
	}

	#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
	template<typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7>
	typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type
	sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6, T_arg7 _A_arg7)
	{
		typedef typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type deduced_result_type;
		return make_new_tunnel_context<SYNC, deduced_result_type>(m_disp, m_validity_tracker, 
			sigc::bind(this->functor_, sigx::ref(_A_arg1), sigx::ref(_A_arg2), sigx::ref(_A_arg3), sigx::ref(_A_arg4), sigx::ref(_A_arg5), sigx::ref(_A_arg6), sigx::ref(_A_arg7)))->tunnel();
	}
	#endif


	
	/**	@short Constructs an adaptor that wraps the passed functor.
	 *	@param _A_func Functor to invoke at the other end of the tunnel 
	 *	from operator()().
	 *	@param dispatcher_change_is_cleanup Whether a dispatcher change should be
	 *	be treated as reason to destroy the tunnel
	 *	@note The passed in functor must be a "dispatchable functor", i.e.
	 *	a functor on a dispatchable's method or a functor created by 
	 *	sigx::dispatch_with.
	 */
	explicit tunnel_functor(typename sigc::type_trait<T_functor>::take _A_func): 
		sigc::adapts<T_functor>(_A_func), 
		// find the dispatchable object contained in the functor by 
		// stepping down the functor chain;
		// dispatchable_constraint finds the dispatchable and issues a compiler
		// error if the passed in functor is not a functor on a dispatchable's
		// method or does find a dispatchable in a SIGX_DISPATCH_WITH_FUNCTOR
		tunnel_base(internal::dispatchable_constraint<adaptor_type>::find_dispatchable(this->functor_))
	{}
	
	// implicit copy ctor is fine
	// implicit dtor is fine
	// implicit assignment operator is fine


	/**	@short	Activates validity tracking for sigc::trackableS and tracking of a dispatcher change 
	 *		(e.g. when a thread finishes its execution and resets its dispatcher)
	 *	@note	%activate_validity_tracking() assumes that the tunnel functor, all sigc::trackableS and the dispatcher/dispatchable 
	 *		are managed and accessed in the context of the calling thread.
	 */
	void activate_validity_tracking() const
	{
		validity_tracker().activate();

		// visit each trackable and bind the validity trackable to the sigc trackable and vice versa
		sigc::visit_each_type<sigc::trackable*>(
			sigc::mem_fun(validity_tracker(), &tunnel_validity_tracker::do_bind_to_trackable), 
			this->functor_
		);
	}
};





/**	@short Binds a dispatchable explicitly to a functor.
 *	@note Use only with non-dispatchable functors (functors on functions or 
 *	methods of classes that do not derive from sigx::dispatchable)
 *	@ingroup Functors
 */
template<typename T_functor>
SIGX_DISPATCH_WITH_FUNCTOR(T_functor)
dispatch_with(const T_functor& _A_func, const shared_dispatchable& d)
{
	return sigc::bind(sigc::hide(_A_func), d);
}


/**	@short Opens an asynchronous tunnel on the specified functor.
 *	@ingroup Functors
 *	@param _A_func the functor on which the tunnel should be created
 *	@note @p _A_func must be a dispatchable functor, i.e. a member function
 *	of a class derived from sigx::dispatchable or a dispatchable functor explicitly created with 
 *	dispatch_with()
 *	@return Functor that executes @e _A_func on invokation in the context of the server thread.
 *	@ingroup Functors
 */
template<typename T_functor>
tunnel_functor<ASYNC, T_functor> 
open_tunnel(const T_functor& _A_func)
{
	return tunnel_functor<ASYNC, T_functor>(_A_func);
}

/**	@short Opens a synchronous tunnel on the specified functor.
 *	@ingroup Functors
 *	@param _A_func the functor on which the tunnel should be created
 *	@note @p _A_func must be a dispatchable functor, i.e. a member function
 *	of a class derived from sigx::dispatchable or a dispatchable functor explicitly created with 
 *	dispatch_with()
 *	@return Functor that executes @e _A_func on invokation in the context of the server thread.
 *	@ingroup Functors
 */
template<typename T_functor>
tunnel_functor<SYNC, T_functor> 
open_sync_tunnel(const T_functor& _A_func)
{
	return tunnel_functor<SYNC, T_functor>(_A_func);
}

/**	@short Opens an asynchronous tunnel on the specified functor with the dispatcher of the specified dispatchable.
 *	@ingroup Functors
 *	@param _A_func the functor on which the tunnel should be created
 *	@param d the dispatchable to operate on
 *	@note @p _A_func must be a dispatchable functor, i.e. a member function
 *	of a class derived from sigx::dispatchable or a dispatchable functor explicitly created with 
 *	dispatch_with()
 *	@return Functor that executes @e _A_func on invokation in the context of the server thread.
 *	@ingroup Functors
 */
template<typename T_functor>
tunnel_functor<ASYNC, SIGX_DISPATCH_WITH_FUNCTOR(T_functor)> 
open_tunnel_with(const T_functor& _A_func, const shared_dispatchable& d)
{
	return tunnel_functor<ASYNC, SIGX_DISPATCH_WITH_FUNCTOR(T_functor)>(dispatch_with(_A_func, d));
}

/**	@short Opens a synchronous tunnel on the specified functor with the dispatcher of the specified dispatchable.
 *	@ingroup Functors
 *	@param _A_func the functor on which the tunnel should be created
 *	@param d the dispatchable to operate on
 *	@note @p _A_func must be a dispatchable functor, i.e. a member function
 *	of a class derived from sigx::dispatchable or a dispatchable functor explicitly created with 
 *	dispatch_with()
 *	@return Functor that executes @e _A_func on invokation in the context of the server thread.
 *	@ingroup Functors
 */
template<typename T_functor>
tunnel_functor<SYNC, SIGX_DISPATCH_WITH_FUNCTOR(T_functor)> 
open_sync_tunnel_with(const T_functor& _A_func, const shared_dispatchable& d)
{
	return tunnel_functor<SYNC, SIGX_DISPATCH_WITH_FUNCTOR(T_functor)>(dispatch_with(_A_func, d));
}


} // namespace sigx


namespace sigc
{

/**	@short visit_each overload for tunnel functors, completely turning off the visit_each mechanism and thus turning off the trackable mechanism.
 *	
 *	This is necessary because binding a tunnel functor to a slot would access a trackable in a non-threadsafe manner.
 *	sigx++ activates validity tracking for trackables at the call site when the client thread connects to a signal through signal_wrapper<>::connect()
 */
template<typename T_action, typename T_functor, sigx::sync_type I_sync>
void visit_each(const T_action& /*_A_action*/, const sigx::tunnel_functor<I_sync, T_functor>& /*_A_func*/)
{
	// do nothing
}


} // namespace sigc
#endif /* _SIGXMACROS_TUNNEL_FUNCTOR_H_ */