Tesseract
3.02
|
00001 00002 // File: tesscallback.h 00003 // Description: classes and functions to replace pointer-to-functions 00004 // Author: Samuel Charron 00005 // 00006 // (C) Copyright 2006, Google Inc. 00007 // Licensed under the Apache License, Version 2.0 (the "License"); 00008 // you may not use this file except in compliance with the License. 00009 // You may obtain a copy of the License at 00010 // http://www.apache.org/licenses/LICENSE-2.0 00011 // Unless required by applicable law or agreed to in writing, software 00012 // distributed under the License is distributed on an "AS IS" BASIS, 00013 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 // See the License for the specific language governing permissions and 00015 // limitations under the License. 00016 // 00018 00019 #ifndef _TESS_CALLBACK_SPECIALIZATIONS_H 00020 #define _TESS_CALLBACK_SPECIALIZATIONS_H 00021 00022 #include "host.h" // For NULL. 00023 00024 struct TessCallbackUtils_ { 00025 static void FailIsRepeatable(const char* name); 00026 }; 00027 00028 00029 class TessClosure { 00030 public: 00031 virtual ~TessClosure() { } 00032 virtual void Run() = 0; 00033 }; 00034 00035 template <class R> 00036 class TessResultCallback { 00037 public: 00038 virtual ~TessResultCallback() { } 00039 virtual R Run() = 0; 00040 }; 00041 00042 template <bool del, class R, class T> 00043 class _ConstTessMemberResultCallback_0_0 : public TessResultCallback<R> { 00044 public: 00045 typedef TessResultCallback<R> base; 00046 typedef R (T::*MemberSignature)() const; 00047 00048 private: 00049 const T* object_; 00050 MemberSignature member_; 00051 00052 public: 00053 inline _ConstTessMemberResultCallback_0_0( 00054 const T* object, MemberSignature member) 00055 : object_(object), 00056 member_(member) { 00057 } 00058 00059 virtual R Run() { 00060 if (!del) { 00061 R result = (object_->*member_)(); 00062 return result; 00063 } else { 00064 R result = (object_->*member_)(); 00065 // zero out the pointer to ensure segfault if used again 00066 member_ = NULL; 00067 delete this; 00068 return result; 00069 } 00070 } 00071 }; 00072 00073 template <bool del, class T> 00074 class _ConstTessMemberResultCallback_0_0<del, void, T> 00075 : public TessClosure { 00076 public: 00077 typedef TessClosure base; 00078 typedef void (T::*MemberSignature)() const; 00079 00080 private: 00081 const T* object_; 00082 MemberSignature member_; 00083 00084 public: 00085 inline _ConstTessMemberResultCallback_0_0( 00086 const T* object, MemberSignature member) 00087 : object_(object), 00088 member_(member) { 00089 } 00090 00091 virtual void Run() { 00092 if (!del) { 00093 (object_->*member_)(); 00094 } else { 00095 (object_->*member_)(); 00096 // zero out the pointer to ensure segfault if used again 00097 member_ = NULL; 00098 delete this; 00099 } 00100 } 00101 }; 00102 00103 #ifndef SWIG 00104 template <class T1, class T2, class R> 00105 inline typename _ConstTessMemberResultCallback_0_0<true,R,T1>::base* 00106 NewTessCallback( 00107 const T1* obj, R (T2::*member)() const) { 00108 return new _ConstTessMemberResultCallback_0_0<true,R,T1>( 00109 obj, member); 00110 } 00111 #endif 00112 00113 #ifndef SWIG 00114 template <class T1, class T2, class R> 00115 inline typename _ConstTessMemberResultCallback_0_0<false,R,T1>::base* 00116 NewPermanentTessCallback( 00117 const T1* obj, R (T2::*member)() const) { 00118 return new _ConstTessMemberResultCallback_0_0<false,R,T1>( 00119 obj, member); 00120 } 00121 #endif 00122 00123 template <bool del, class R, class T> 00124 class _TessMemberResultCallback_0_0 : public TessResultCallback<R> { 00125 public: 00126 typedef TessResultCallback<R> base; 00127 typedef R (T::*MemberSignature)() ; 00128 00129 private: 00130 T* object_; 00131 MemberSignature member_; 00132 00133 public: 00134 inline _TessMemberResultCallback_0_0( 00135 T* object, MemberSignature member) 00136 : object_(object), 00137 member_(member) { 00138 } 00139 00140 virtual R Run() { 00141 if (!del) { 00142 R result = (object_->*member_)(); 00143 return result; 00144 } else { 00145 R result = (object_->*member_)(); 00146 // zero out the pointer to ensure segfault if used again 00147 member_ = NULL; 00148 delete this; 00149 return result; 00150 } 00151 } 00152 }; 00153 00154 template <bool del, class T> 00155 class _TessMemberResultCallback_0_0<del, void, T> 00156 : public TessClosure { 00157 public: 00158 typedef TessClosure base; 00159 typedef void (T::*MemberSignature)() ; 00160 00161 private: 00162 T* object_; 00163 MemberSignature member_; 00164 00165 public: 00166 inline _TessMemberResultCallback_0_0( 00167 T* object, MemberSignature member) 00168 : object_(object), 00169 member_(member) { 00170 } 00171 00172 virtual void Run() { 00173 if (!del) { 00174 (object_->*member_)(); 00175 } else { 00176 (object_->*member_)(); 00177 // zero out the pointer to ensure segfault if used again 00178 member_ = NULL; 00179 delete this; 00180 } 00181 } 00182 }; 00183 00184 #ifndef SWIG 00185 template <class T1, class T2, class R> 00186 inline typename _TessMemberResultCallback_0_0<true,R,T1>::base* 00187 NewTessCallback( 00188 T1* obj, R (T2::*member)() ) { 00189 return new _TessMemberResultCallback_0_0<true,R,T1>( 00190 obj, member); 00191 } 00192 #endif 00193 00194 #ifndef SWIG 00195 template <class T1, class T2, class R> 00196 inline typename _TessMemberResultCallback_0_0<false,R,T1>::base* 00197 NewPermanentTessCallback( 00198 T1* obj, R (T2::*member)() ) { 00199 return new _TessMemberResultCallback_0_0<false,R,T1>( 00200 obj, member); 00201 } 00202 #endif 00203 00204 template <bool del, class R> 00205 class _TessFunctionResultCallback_0_0 : public TessResultCallback<R> { 00206 public: 00207 typedef TessResultCallback<R> base; 00208 typedef R (*FunctionSignature)(); 00209 00210 private: 00211 FunctionSignature function_; 00212 00213 public: 00214 inline _TessFunctionResultCallback_0_0( 00215 FunctionSignature function) 00216 : function_(function) { 00217 } 00218 00219 virtual R Run() { 00220 if (!del) { 00221 R result = (*function_)(); 00222 return result; 00223 } else { 00224 R result = (*function_)(); 00225 // zero out the pointer to ensure segfault if used again 00226 function_ = NULL; 00227 delete this; 00228 return result; 00229 } 00230 } 00231 }; 00232 00233 template <bool del> 00234 class _TessFunctionResultCallback_0_0<del, void> 00235 : public TessClosure { 00236 public: 00237 typedef TessClosure base; 00238 typedef void (*FunctionSignature)(); 00239 00240 private: 00241 FunctionSignature function_; 00242 00243 public: 00244 inline _TessFunctionResultCallback_0_0( 00245 FunctionSignature function) 00246 : function_(function) { 00247 } 00248 00249 virtual void Run() { 00250 if (!del) { 00251 (*function_)(); 00252 } else { 00253 (*function_)(); 00254 // zero out the pointer to ensure segfault if used again 00255 function_ = NULL; 00256 delete this; 00257 } 00258 } 00259 }; 00260 00261 template <class R> 00262 inline typename _TessFunctionResultCallback_0_0<true,R>::base* 00263 NewTessCallback(R (*function)()) { 00264 return new _TessFunctionResultCallback_0_0<true,R>(function); 00265 } 00266 00267 template <class R> 00268 inline typename _TessFunctionResultCallback_0_0<false,R>::base* 00269 NewPermanentTessCallback(R (*function)()) { 00270 return new _TessFunctionResultCallback_0_0<false,R>(function); 00271 } 00272 00273 template <class A1> 00274 class TessCallback1 { 00275 public: 00276 virtual ~TessCallback1() { } 00277 virtual void Run(A1) = 0; 00278 }; 00279 00280 template <class R, class A1> 00281 class TessResultCallback1 { 00282 public: 00283 virtual ~TessResultCallback1() { } 00284 virtual R Run(A1) = 0; 00285 }; 00286 00287 template <bool del, class R, class T, class A1> 00288 class _ConstTessMemberResultCallback_0_1 : public TessResultCallback1<R,A1> { 00289 public: 00290 typedef TessResultCallback1<R,A1> base; 00291 typedef R (T::*MemberSignature)(A1) const; 00292 00293 private: 00294 const T* object_; 00295 MemberSignature member_; 00296 00297 public: 00298 inline _ConstTessMemberResultCallback_0_1( 00299 const T* object, MemberSignature member) 00300 : object_(object), 00301 member_(member) { 00302 } 00303 00304 virtual R Run(A1 a1) { 00305 if (!del) { 00306 R result = (object_->*member_)(a1); 00307 return result; 00308 } else { 00309 R result = (object_->*member_)(a1); 00310 // zero out the pointer to ensure segfault if used again 00311 member_ = NULL; 00312 delete this; 00313 return result; 00314 } 00315 } 00316 }; 00317 00318 template <bool del, class T, class A1> 00319 class _ConstTessMemberResultCallback_0_1<del, void, T, A1> 00320 : public TessCallback1<A1> { 00321 public: 00322 typedef TessCallback1<A1> base; 00323 typedef void (T::*MemberSignature)(A1) const; 00324 00325 private: 00326 const T* object_; 00327 MemberSignature member_; 00328 00329 public: 00330 inline _ConstTessMemberResultCallback_0_1( 00331 const T* object, MemberSignature member) 00332 : object_(object), 00333 member_(member) { 00334 } 00335 00336 virtual void Run(A1 a1) { 00337 if (!del) { 00338 (object_->*member_)(a1); 00339 } else { 00340 (object_->*member_)(a1); 00341 // zero out the pointer to ensure segfault if used again 00342 member_ = NULL; 00343 delete this; 00344 } 00345 } 00346 }; 00347 00348 #ifndef SWIG 00349 template <class T1, class T2, class R, class A1> 00350 inline typename _ConstTessMemberResultCallback_0_1<true,R,T1,A1>::base* 00351 NewTessCallback( 00352 const T1* obj, R (T2::*member)(A1) const) { 00353 return new _ConstTessMemberResultCallback_0_1<true,R,T1,A1>( 00354 obj, member); 00355 } 00356 #endif 00357 00358 #ifndef SWIG 00359 template <class T1, class T2, class R, class A1> 00360 inline typename _ConstTessMemberResultCallback_0_1<false,R,T1,A1>::base* 00361 NewPermanentTessCallback( 00362 const T1* obj, R (T2::*member)(A1) const) { 00363 return new _ConstTessMemberResultCallback_0_1<false,R,T1,A1>( 00364 obj, member); 00365 } 00366 #endif 00367 00368 template <bool del, class R, class T, class A1> 00369 class _TessMemberResultCallback_0_1 : public TessResultCallback1<R,A1> { 00370 public: 00371 typedef TessResultCallback1<R,A1> base; 00372 typedef R (T::*MemberSignature)(A1) ; 00373 00374 private: 00375 T* object_; 00376 MemberSignature member_; 00377 00378 public: 00379 inline _TessMemberResultCallback_0_1( 00380 T* object, MemberSignature member) 00381 : object_(object), 00382 member_(member) { 00383 } 00384 00385 virtual R Run(A1 a1) { 00386 if (!del) { 00387 R result = (object_->*member_)(a1); 00388 return result; 00389 } else { 00390 R result = (object_->*member_)(a1); 00391 // zero out the pointer to ensure segfault if used again 00392 member_ = NULL; 00393 delete this; 00394 return result; 00395 } 00396 } 00397 }; 00398 00399 template <bool del, class T, class A1> 00400 class _TessMemberResultCallback_0_1<del, void, T, A1> 00401 : public TessCallback1<A1> { 00402 public: 00403 typedef TessCallback1<A1> base; 00404 typedef void (T::*MemberSignature)(A1) ; 00405 00406 private: 00407 T* object_; 00408 MemberSignature member_; 00409 00410 public: 00411 inline _TessMemberResultCallback_0_1( 00412 T* object, MemberSignature member) 00413 : object_(object), 00414 member_(member) { 00415 } 00416 00417 virtual void Run(A1 a1) { 00418 if (!del) { 00419 (object_->*member_)(a1); 00420 } else { 00421 (object_->*member_)(a1); 00422 // zero out the pointer to ensure segfault if used again 00423 member_ = NULL; 00424 delete this; 00425 } 00426 } 00427 }; 00428 00429 #ifndef SWIG 00430 template <class T1, class T2, class R, class A1> 00431 inline typename _TessMemberResultCallback_0_1<true,R,T1,A1>::base* 00432 NewTessCallback( 00433 T1* obj, R (T2::*member)(A1) ) { 00434 return new _TessMemberResultCallback_0_1<true,R,T1,A1>( 00435 obj, member); 00436 } 00437 #endif 00438 00439 #ifndef SWIG 00440 template <class T1, class T2, class R, class A1> 00441 inline typename _TessMemberResultCallback_0_1<false,R,T1,A1>::base* 00442 NewPermanentTessCallback( 00443 T1* obj, R (T2::*member)(A1) ) { 00444 return new _TessMemberResultCallback_0_1<false,R,T1,A1>( 00445 obj, member); 00446 } 00447 #endif 00448 00449 template <bool del, class R, class A1> 00450 class _TessFunctionResultCallback_0_1 : public TessResultCallback1<R,A1> { 00451 public: 00452 typedef TessResultCallback1<R,A1> base; 00453 typedef R (*FunctionSignature)(A1); 00454 00455 private: 00456 FunctionSignature function_; 00457 00458 public: 00459 inline _TessFunctionResultCallback_0_1( 00460 FunctionSignature function) 00461 : function_(function) { 00462 } 00463 00464 virtual R Run(A1 a1) { 00465 if (!del) { 00466 R result = (*function_)(a1); 00467 return result; 00468 } else { 00469 R result = (*function_)(a1); 00470 // zero out the pointer to ensure segfault if used again 00471 function_ = NULL; 00472 delete this; 00473 return result; 00474 } 00475 } 00476 }; 00477 00478 template <bool del, class A1> 00479 class _TessFunctionResultCallback_0_1<del, void, A1> 00480 : public TessCallback1<A1> { 00481 public: 00482 typedef TessCallback1<A1> base; 00483 typedef void (*FunctionSignature)(A1); 00484 00485 private: 00486 FunctionSignature function_; 00487 00488 public: 00489 inline _TessFunctionResultCallback_0_1( 00490 FunctionSignature function) 00491 : function_(function) { 00492 } 00493 00494 virtual void Run(A1 a1) { 00495 if (!del) { 00496 (*function_)(a1); 00497 } else { 00498 (*function_)(a1); 00499 // zero out the pointer to ensure segfault if used again 00500 function_ = NULL; 00501 delete this; 00502 } 00503 } 00504 }; 00505 00506 template <class R, class A1> 00507 inline typename _TessFunctionResultCallback_0_1<true,R,A1>::base* 00508 NewTessCallback(R (*function)(A1)) { 00509 return new _TessFunctionResultCallback_0_1<true,R,A1>(function); 00510 } 00511 00512 template <class R, class A1> 00513 inline typename _TessFunctionResultCallback_0_1<false,R,A1>::base* 00514 NewPermanentTessCallback(R (*function)(A1)) { 00515 return new _TessFunctionResultCallback_0_1<false,R,A1>(function); 00516 } 00517 00518 template <class A1,class A2> 00519 class TessCallback2 { 00520 public: 00521 virtual ~TessCallback2() { } 00522 virtual void Run(A1,A2) = 0; 00523 }; 00524 00525 template <class R, class A1,class A2> 00526 class TessResultCallback2 { 00527 public: 00528 virtual ~TessResultCallback2() { } 00529 virtual R Run(A1,A2) = 0; 00530 }; 00531 00532 template <bool del, class R, class T, class A1, class A2> 00533 class _ConstTessMemberResultCallback_0_2 : public TessResultCallback2<R,A1,A2> { 00534 public: 00535 typedef TessResultCallback2<R,A1,A2> base; 00536 typedef R (T::*MemberSignature)(A1,A2) const; 00537 00538 private: 00539 const T* object_; 00540 MemberSignature member_; 00541 00542 public: 00543 inline _ConstTessMemberResultCallback_0_2( 00544 const T* object, MemberSignature member) 00545 : object_(object), 00546 member_(member) { 00547 } 00548 00549 virtual R Run(A1 a1,A2 a2) { 00550 if (!del) { 00551 R result = (object_->*member_)(a1,a2); 00552 return result; 00553 } else { 00554 R result = (object_->*member_)(a1,a2); 00555 // zero out the pointer to ensure segfault if used again 00556 member_ = NULL; 00557 delete this; 00558 return result; 00559 } 00560 } 00561 }; 00562 00563 template <bool del, class T, class A1, class A2> 00564 class _ConstTessMemberResultCallback_0_2<del, void, T, A1, A2> 00565 : public TessCallback2<A1,A2> { 00566 public: 00567 typedef TessCallback2<A1,A2> base; 00568 typedef void (T::*MemberSignature)(A1,A2) const; 00569 00570 private: 00571 const T* object_; 00572 MemberSignature member_; 00573 00574 public: 00575 inline _ConstTessMemberResultCallback_0_2( 00576 const T* object, MemberSignature member) 00577 : object_(object), 00578 member_(member) { 00579 } 00580 00581 virtual void Run(A1 a1,A2 a2) { 00582 if (!del) { 00583 (object_->*member_)(a1,a2); 00584 } else { 00585 (object_->*member_)(a1,a2); 00586 // zero out the pointer to ensure segfault if used again 00587 member_ = NULL; 00588 delete this; 00589 } 00590 } 00591 }; 00592 00593 #ifndef SWIG 00594 template <class T1, class T2, class R, class A1, class A2> 00595 inline typename _ConstTessMemberResultCallback_0_2<true,R,T1,A1,A2>::base* 00596 NewTessCallback( 00597 const T1* obj, R (T2::*member)(A1,A2) const) { 00598 return new _ConstTessMemberResultCallback_0_2<true,R,T1,A1,A2>( 00599 obj, member); 00600 } 00601 #endif 00602 00603 #ifndef SWIG 00604 template <class T1, class T2, class R, class A1, class A2> 00605 inline typename _ConstTessMemberResultCallback_0_2<false,R,T1,A1,A2>::base* 00606 NewPermanentTessCallback( 00607 const T1* obj, R (T2::*member)(A1,A2) const) { 00608 return new _ConstTessMemberResultCallback_0_2<false,R,T1,A1,A2>( 00609 obj, member); 00610 } 00611 #endif 00612 00613 template <bool del, class R, class T, class A1, class A2> 00614 class _TessMemberResultCallback_0_2 : public TessResultCallback2<R,A1,A2> { 00615 public: 00616 typedef TessResultCallback2<R,A1,A2> base; 00617 typedef R (T::*MemberSignature)(A1,A2) ; 00618 00619 private: 00620 T* object_; 00621 MemberSignature member_; 00622 00623 public: 00624 inline _TessMemberResultCallback_0_2( 00625 T* object, MemberSignature member) 00626 : object_(object), 00627 member_(member) { 00628 } 00629 00630 virtual R Run(A1 a1,A2 a2) { 00631 if (!del) { 00632 R result = (object_->*member_)(a1,a2); 00633 return result; 00634 } else { 00635 R result = (object_->*member_)(a1,a2); 00636 // zero out the pointer to ensure segfault if used again 00637 member_ = NULL; 00638 delete this; 00639 return result; 00640 } 00641 } 00642 }; 00643 00644 template <bool del, class T, class A1, class A2> 00645 class _TessMemberResultCallback_0_2<del, void, T, A1, A2> 00646 : public TessCallback2<A1,A2> { 00647 public: 00648 typedef TessCallback2<A1,A2> base; 00649 typedef void (T::*MemberSignature)(A1,A2) ; 00650 00651 private: 00652 T* object_; 00653 MemberSignature member_; 00654 00655 public: 00656 inline _TessMemberResultCallback_0_2( 00657 T* object, MemberSignature member) 00658 : object_(object), 00659 member_(member) { 00660 } 00661 00662 virtual void Run(A1 a1,A2 a2) { 00663 if (!del) { 00664 (object_->*member_)(a1,a2); 00665 } else { 00666 (object_->*member_)(a1,a2); 00667 // zero out the pointer to ensure segfault if used again 00668 member_ = NULL; 00669 delete this; 00670 } 00671 } 00672 }; 00673 00674 #ifndef SWIG 00675 template <class T1, class T2, class R, class A1, class A2> 00676 inline typename _TessMemberResultCallback_0_2<true,R,T1,A1,A2>::base* 00677 NewTessCallback( 00678 T1* obj, R (T2::*member)(A1,A2) ) { 00679 return new _TessMemberResultCallback_0_2<true,R,T1,A1,A2>( 00680 obj, member); 00681 } 00682 #endif 00683 00684 #ifndef SWIG 00685 template <class T1, class T2, class R, class A1, class A2> 00686 inline typename _TessMemberResultCallback_0_2<false,R,T1,A1,A2>::base* 00687 NewPermanentTessCallback( 00688 T1* obj, R (T2::*member)(A1,A2) ) { 00689 return new _TessMemberResultCallback_0_2<false,R,T1,A1,A2>( 00690 obj, member); 00691 } 00692 #endif 00693 00694 template <bool del, class R, class A1, class A2> 00695 class _TessFunctionResultCallback_0_2 : public TessResultCallback2<R,A1,A2> { 00696 public: 00697 typedef TessResultCallback2<R,A1,A2> base; 00698 typedef R (*FunctionSignature)(A1,A2); 00699 00700 private: 00701 FunctionSignature function_; 00702 00703 public: 00704 inline _TessFunctionResultCallback_0_2( 00705 FunctionSignature function) 00706 : function_(function) { 00707 } 00708 00709 virtual R Run(A1 a1,A2 a2) { 00710 if (!del) { 00711 R result = (*function_)(a1,a2); 00712 return result; 00713 } else { 00714 R result = (*function_)(a1,a2); 00715 // zero out the pointer to ensure segfault if used again 00716 function_ = NULL; 00717 delete this; 00718 return result; 00719 } 00720 } 00721 }; 00722 00723 template <bool del, class A1, class A2> 00724 class _TessFunctionResultCallback_0_2<del, void, A1, A2> 00725 : public TessCallback2<A1,A2> { 00726 public: 00727 typedef TessCallback2<A1,A2> base; 00728 typedef void (*FunctionSignature)(A1,A2); 00729 00730 private: 00731 FunctionSignature function_; 00732 00733 public: 00734 inline _TessFunctionResultCallback_0_2( 00735 FunctionSignature function) 00736 : function_(function) { 00737 } 00738 00739 virtual void Run(A1 a1,A2 a2) { 00740 if (!del) { 00741 (*function_)(a1,a2); 00742 } else { 00743 (*function_)(a1,a2); 00744 // zero out the pointer to ensure segfault if used again 00745 function_ = NULL; 00746 delete this; 00747 } 00748 } 00749 }; 00750 00751 template <class R, class A1, class A2> 00752 inline typename _TessFunctionResultCallback_0_2<true,R,A1,A2>::base* 00753 NewTessCallback(R (*function)(A1,A2)) { 00754 return new _TessFunctionResultCallback_0_2<true,R,A1,A2>(function); 00755 } 00756 00757 template <class R, class A1, class A2> 00758 inline typename _TessFunctionResultCallback_0_2<false,R,A1,A2>::base* 00759 NewPermanentTessCallback(R (*function)(A1,A2)) { 00760 return new _TessFunctionResultCallback_0_2<false,R,A1,A2>(function); 00761 } 00762 00763 template <class A1,class A2,class A3> 00764 class TessCallback3 { 00765 public: 00766 virtual ~TessCallback3() { } 00767 virtual void Run(A1,A2,A3) = 0; 00768 }; 00769 00770 template <class R, class A1,class A2,class A3> 00771 class TessResultCallback3 { 00772 public: 00773 virtual ~TessResultCallback3() { } 00774 virtual R Run(A1,A2,A3) = 0; 00775 }; 00776 00777 template <bool del, class R, class T, class A1, class A2, class A3> 00778 class _ConstTessMemberResultCallback_0_3 : public TessResultCallback3<R,A1,A2,A3> { 00779 public: 00780 typedef TessResultCallback3<R,A1,A2,A3> base; 00781 typedef R (T::*MemberSignature)(A1,A2,A3) const; 00782 00783 private: 00784 const T* object_; 00785 MemberSignature member_; 00786 00787 public: 00788 inline _ConstTessMemberResultCallback_0_3( 00789 const T* object, MemberSignature member) 00790 : object_(object), 00791 member_(member) { 00792 } 00793 00794 virtual R Run(A1 a1,A2 a2,A3 a3) { 00795 if (!del) { 00796 R result = (object_->*member_)(a1,a2,a3); 00797 return result; 00798 } else { 00799 R result = (object_->*member_)(a1,a2,a3); 00800 // zero out the pointer to ensure segfault if used again 00801 member_ = NULL; 00802 delete this; 00803 return result; 00804 } 00805 } 00806 }; 00807 00808 template <bool del, class T, class A1, class A2, class A3> 00809 class _ConstTessMemberResultCallback_0_3<del, void, T, A1, A2, A3> 00810 : public TessCallback3<A1,A2,A3> { 00811 public: 00812 typedef TessCallback3<A1,A2,A3> base; 00813 typedef void (T::*MemberSignature)(A1,A2,A3) const; 00814 00815 private: 00816 const T* object_; 00817 MemberSignature member_; 00818 00819 public: 00820 inline _ConstTessMemberResultCallback_0_3( 00821 const T* object, MemberSignature member) 00822 : object_(object), 00823 member_(member) { 00824 } 00825 00826 virtual void Run(A1 a1,A2 a2,A3 a3) { 00827 if (!del) { 00828 (object_->*member_)(a1,a2,a3); 00829 } else { 00830 (object_->*member_)(a1,a2,a3); 00831 // zero out the pointer to ensure segfault if used again 00832 member_ = NULL; 00833 delete this; 00834 } 00835 } 00836 }; 00837 00838 #ifndef SWIG 00839 template <class T1, class T2, class R, class A1, class A2, class A3> 00840 inline typename _ConstTessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>::base* 00841 NewTessCallback( 00842 const T1* obj, R (T2::*member)(A1,A2,A3) const) { 00843 return new _ConstTessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>( 00844 obj, member); 00845 } 00846 #endif 00847 00848 #ifndef SWIG 00849 template <class T1, class T2, class R, class A1, class A2, class A3> 00850 inline typename _ConstTessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>::base* 00851 NewPermanentTessCallback( 00852 const T1* obj, R (T2::*member)(A1,A2,A3) const) { 00853 return new _ConstTessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>( 00854 obj, member); 00855 } 00856 #endif 00857 00858 template <bool del, class R, class T, class A1, class A2, class A3> 00859 class _TessMemberResultCallback_0_3 : public TessResultCallback3<R,A1,A2,A3> { 00860 public: 00861 typedef TessResultCallback3<R,A1,A2,A3> base; 00862 typedef R (T::*MemberSignature)(A1,A2,A3) ; 00863 00864 private: 00865 T* object_; 00866 MemberSignature member_; 00867 00868 public: 00869 inline _TessMemberResultCallback_0_3( 00870 T* object, MemberSignature member) 00871 : object_(object), 00872 member_(member) { 00873 } 00874 00875 virtual R Run(A1 a1,A2 a2,A3 a3) { 00876 if (!del) { 00877 R result = (object_->*member_)(a1,a2,a3); 00878 return result; 00879 } else { 00880 R result = (object_->*member_)(a1,a2,a3); 00881 // zero out the pointer to ensure segfault if used again 00882 member_ = NULL; 00883 delete this; 00884 return result; 00885 } 00886 } 00887 }; 00888 00889 template <bool del, class T, class A1, class A2, class A3> 00890 class _TessMemberResultCallback_0_3<del, void, T, A1, A2, A3> 00891 : public TessCallback3<A1,A2,A3> { 00892 public: 00893 typedef TessCallback3<A1,A2,A3> base; 00894 typedef void (T::*MemberSignature)(A1,A2,A3) ; 00895 00896 private: 00897 T* object_; 00898 MemberSignature member_; 00899 00900 public: 00901 inline _TessMemberResultCallback_0_3( 00902 T* object, MemberSignature member) 00903 : object_(object), 00904 member_(member) { 00905 } 00906 00907 virtual void Run(A1 a1,A2 a2,A3 a3) { 00908 if (!del) { 00909 (object_->*member_)(a1,a2,a3); 00910 } else { 00911 (object_->*member_)(a1,a2,a3); 00912 // zero out the pointer to ensure segfault if used again 00913 member_ = NULL; 00914 delete this; 00915 } 00916 } 00917 }; 00918 00919 #ifndef SWIG 00920 template <class T1, class T2, class R, class A1, class A2, class A3> 00921 inline typename _TessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>::base* 00922 NewTessCallback( 00923 T1* obj, R (T2::*member)(A1,A2,A3) ) { 00924 return new _TessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>( 00925 obj, member); 00926 } 00927 #endif 00928 00929 #ifndef SWIG 00930 template <class T1, class T2, class R, class A1, class A2, class A3> 00931 inline typename _TessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>::base* 00932 NewPermanentTessCallback( 00933 T1* obj, R (T2::*member)(A1,A2,A3) ) { 00934 return new _TessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>( 00935 obj, member); 00936 } 00937 #endif 00938 00939 template <bool del, class R, class A1, class A2, class A3> 00940 class _TessFunctionResultCallback_0_3 : public TessResultCallback3<R,A1,A2,A3> { 00941 public: 00942 typedef TessResultCallback3<R,A1,A2,A3> base; 00943 typedef R (*FunctionSignature)(A1,A2,A3); 00944 00945 private: 00946 FunctionSignature function_; 00947 00948 public: 00949 inline _TessFunctionResultCallback_0_3( 00950 FunctionSignature function) 00951 : function_(function) { 00952 } 00953 00954 virtual R Run(A1 a1,A2 a2,A3 a3) { 00955 if (!del) { 00956 R result = (*function_)(a1,a2,a3); 00957 return result; 00958 } else { 00959 R result = (*function_)(a1,a2,a3); 00960 // zero out the pointer to ensure segfault if used again 00961 function_ = NULL; 00962 delete this; 00963 return result; 00964 } 00965 } 00966 }; 00967 00968 template <bool del, class A1, class A2, class A3> 00969 class _TessFunctionResultCallback_0_3<del, void, A1, A2, A3> 00970 : public TessCallback3<A1,A2,A3> { 00971 public: 00972 typedef TessCallback3<A1,A2,A3> base; 00973 typedef void (*FunctionSignature)(A1,A2,A3); 00974 00975 private: 00976 FunctionSignature function_; 00977 00978 public: 00979 inline _TessFunctionResultCallback_0_3( 00980 FunctionSignature function) 00981 : function_(function) { 00982 } 00983 00984 virtual void Run(A1 a1,A2 a2,A3 a3) { 00985 if (!del) { 00986 (*function_)(a1,a2,a3); 00987 } else { 00988 (*function_)(a1,a2,a3); 00989 // zero out the pointer to ensure segfault if used again 00990 function_ = NULL; 00991 delete this; 00992 } 00993 } 00994 }; 00995 00996 template <class R, class A1, class A2, class A3> 00997 inline typename _TessFunctionResultCallback_0_3<true,R,A1,A2,A3>::base* 00998 NewTessCallback(R (*function)(A1,A2,A3)) { 00999 return new _TessFunctionResultCallback_0_3<true,R,A1,A2,A3>(function); 01000 } 01001 01002 template <class R, class A1, class A2, class A3> 01003 inline typename _TessFunctionResultCallback_0_3<false,R,A1,A2,A3>::base* 01004 NewPermanentTessCallback(R (*function)(A1,A2,A3)) { 01005 return new _TessFunctionResultCallback_0_3<false,R,A1,A2,A3>(function); 01006 } 01007 01008 // Specified by TR1 [4.7.2] Reference modifications. 01009 template <class T> struct remove_reference; 01010 template<typename T> struct remove_reference { typedef T type; }; 01011 template<typename T> struct remove_reference<T&> { typedef T type; }; 01012 01013 // Identity<T>::type is a typedef of T. Useful for preventing the 01014 // compiler from inferring the type of an argument in templates. 01015 template <typename T> 01016 struct Identity { 01017 typedef T type; 01018 }; 01019 01020 template <bool del, class R, class T, class P1, class A1, class A2, class A3> 01021 class _ConstTessMemberResultCallback_1_3 01022 : public TessResultCallback3<R,A1,A2,A3> { 01023 public: 01024 typedef TessResultCallback3<R,A1,A2,A3> base; 01025 typedef R (T::*MemberSignature)(P1,A1,A2,A3) const; 01026 01027 private: 01028 T* object_; 01029 MemberSignature member_; 01030 typename remove_reference<P1>::type p1_; 01031 01032 public: 01033 inline _ConstTessMemberResultCallback_1_3(T* object, 01034 MemberSignature member, P1 p1) 01035 : object_(object), member_(member), p1_(p1) { } 01036 01037 virtual R Run(A1 a1, A2 a2, A3 a3) { 01038 if (!del) { 01039 R result = (object_->*member_)(p1_,a1,a2,a3); 01040 return result; 01041 } else { 01042 R result = (object_->*member_)(p1_,a1,a2,a3); 01043 // zero out the pointer to ensure segfault if used again 01044 member_ = NULL; 01045 delete this; 01046 return result; 01047 } 01048 } 01049 }; 01050 01051 template <bool del, class T, class P1, class A1, class A2, class A3> 01052 class _ConstTessMemberResultCallback_1_3<del, void, T, P1, A1, A2, A3> 01053 : public TessCallback3<A1,A2,A3> { 01054 public: 01055 typedef TessCallback3<A1,A2,A3> base; 01056 typedef void (T::*MemberSignature)(P1,A1,A2,A3) const; 01057 01058 private: 01059 T* object_; 01060 MemberSignature member_; 01061 typename remove_reference<P1>::type p1_; 01062 01063 public: 01064 inline _ConstTessMemberResultCallback_1_3(T* object, 01065 MemberSignature member, P1 p1) 01066 : object_(object), member_(member), p1_(p1) { } 01067 01068 virtual void Run(A1 a1, A2 a2, A3 a3) { 01069 if (!del) { 01070 (object_->*member_)(p1_,a1,a2,a3); 01071 } else { 01072 (object_->*member_)(p1_,a1,a2,a3); 01073 // zero out the pointer to ensure segfault if used again 01074 member_ = NULL; 01075 delete this; 01076 } 01077 } 01078 }; 01079 01080 #ifndef SWIG 01081 template <class T1, class T2, class R, class P1, class A1, class A2, class A3> 01082 inline typename _ConstTessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>::base* 01083 NewTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) { 01084 return new _ConstTessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>(obj, member, p1); 01085 } 01086 #endif 01087 01088 #ifndef SWIG 01089 template <class T1, class T2, class R, class P1, class A1, class A2, class A3> 01090 inline typename _ConstTessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>::base* 01091 NewPermanentTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) { 01092 return new _ConstTessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>(obj, member, p1); 01093 } 01094 #endif 01095 01096 template <bool del, class R, class T, class P1, class A1, class A2, class A3> 01097 class _TessMemberResultCallback_1_3 : public TessResultCallback3<R,A1,A2,A3> { 01098 public: 01099 typedef TessResultCallback3<R,A1,A2,A3> base; 01100 typedef R (T::*MemberSignature)(P1,A1,A2,A3) ; 01101 01102 private: 01103 T* object_; 01104 MemberSignature member_; 01105 typename remove_reference<P1>::type p1_; 01106 01107 public: 01108 inline _TessMemberResultCallback_1_3(T* object, 01109 MemberSignature member, P1 p1) 01110 : object_(object), member_(member), p1_(p1) { } 01111 01112 virtual R Run(A1 a1, A2 a2, A3 a3) { 01113 if (!del) { 01114 R result = (object_->*member_)(p1_,a1,a2,a3); 01115 return result; 01116 } else { 01117 R result = (object_->*member_)(p1_,a1,a2,a3); 01118 // zero out the pointer to ensure segfault if used again 01119 member_ = NULL; 01120 delete this; 01121 return result; 01122 } 01123 } 01124 }; 01125 01126 template <bool del, class T, class P1, class A1, class A2, class A3> 01127 class _TessMemberResultCallback_1_3<del, void, T, P1, A1, A2, A3> 01128 : public TessCallback3<A1,A2,A3> { 01129 public: 01130 typedef TessCallback3<A1,A2,A3> base; 01131 typedef void (T::*MemberSignature)(P1,A1,A2,A3) ; 01132 01133 private: 01134 T* object_; 01135 MemberSignature member_; 01136 typename remove_reference<P1>::type p1_; 01137 01138 public: 01139 inline _TessMemberResultCallback_1_3(T* object, 01140 MemberSignature member, P1 p1) 01141 : object_(object), member_(member), p1_(p1) { } 01142 01143 virtual void Run(A1 a1, A2 a2, A3 a3) { 01144 if (!del) { 01145 (object_->*member_)(p1_,a1,a2,a3); 01146 } else { 01147 (object_->*member_)(p1_,a1,a2,a3); 01148 // zero out the pointer to ensure segfault if used again 01149 member_ = NULL; 01150 delete this; 01151 } 01152 } 01153 }; 01154 01155 #ifndef SWIG 01156 template <class T1, class T2, class R, class P1, class A1, class A2, class A3> 01157 inline typename _TessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>::base* 01158 NewTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) { 01159 return new _TessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>(obj, member, p1); 01160 } 01161 #endif 01162 01163 #ifndef SWIG 01164 template <class T1, class T2, class R, class P1, class A1, class A2, class A3> 01165 inline typename _TessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>::base* 01166 NewPermanentTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) { 01167 return new _TessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>(obj, member, p1); 01168 } 01169 #endif 01170 01171 template <bool del, class R, class P1, class A1, class A2, class A3> 01172 class _TessFunctionResultCallback_1_3 : public TessCallback3<A1,A2,A3> { 01173 public: 01174 typedef TessCallback3<A1,A2,A3> base; 01175 typedef R (*FunctionSignature)(P1,A1,A2,A3); 01176 01177 private: 01178 FunctionSignature function_; 01179 typename remove_reference<P1>::type p1_; 01180 01181 public: 01182 inline _TessFunctionResultCallback_1_3(FunctionSignature function, P1 p1) 01183 : function_(function), p1_(p1) { } 01184 01185 virtual R Run(A1 a1, A2 a2, A3 a3) { 01186 if (!del) { 01187 R result = (*function_)(p1_,a1,a2,a3); 01188 return result; 01189 } else { 01190 R result = (*function_)(p1_,a1,a2,a3); 01191 // zero out the pointer to ensure segfault if used again 01192 function_ = NULL; 01193 delete this; 01194 return result; 01195 } 01196 } 01197 }; 01198 01199 template <bool del, class P1, class A1, class A2, class A3> 01200 class _TessFunctionResultCallback_1_3<del, void, P1, A1, A2, A3> 01201 : public TessCallback3<A1,A2,A3> { 01202 public: 01203 typedef TessCallback3<A1,A2,A3> base; 01204 typedef void (*FunctionSignature)(P1,A1,A2,A3); 01205 01206 private: 01207 FunctionSignature function_; 01208 typename remove_reference<P1>::type p1_; 01209 01210 public: 01211 inline _TessFunctionResultCallback_1_3(FunctionSignature function, P1 p1) 01212 : function_(function), p1_(p1) { } 01213 01214 virtual void Run(A1 a1, A2 a2, A3 a3) { 01215 if (!del) { 01216 (*function_)(p1_,a1,a2,a3); 01217 } else { 01218 (*function_)(p1_,a1,a2,a3); 01219 // zero out the pointer to ensure segfault if used again 01220 function_ = NULL; 01221 delete this; 01222 } 01223 } 01224 }; 01225 01226 template <class R, class P1, class A1, class A2, class A3> 01227 inline typename _TessFunctionResultCallback_1_3<true,R,P1,A1,A2,A3>::base* 01228 NewTessCallback(R (*function)(P1,A1,A2,A3), typename Identity<P1>::type p1) { 01229 return new _TessFunctionResultCallback_1_3<true,R,P1,A1,A2,A3>(function, p1); 01230 } 01231 01232 template <class R, class P1, class A1, class A2, class A3> 01233 inline typename _TessFunctionResultCallback_1_3<false,R,P1,A1,A2,A3>::base* 01234 NewPermanentTessCallback(R (*function)(P1,A1,A2,A3), typename Identity<P1>::type p1) { 01235 return new _TessFunctionResultCallback_1_3<false,R,P1,A1,A2,A3>(function, p1); 01236 } 01237 01238 #endif /* _TESS_CALLBACK_SPECIALIZATIONS_H */