library of assembled shared sources |
http://lass.cocamware.com |
00001 /* 00002 * *** ATTENTION! DO NOT MODIFY THIS FILE DIRECTLY! *** 00003 * 00004 * It has automatically been generated from callback.tmpl.h 00005 * by param_expander.py on Sun Nov 09 16:55:52 2008. 00006 */ 00007 00008 /** @file 00009 * @author Bram de Greve (bramz@users.sourceforge.net) 00010 * @author Tom De Muer (tomdemuer@users.sourceforge.net) 00011 * 00012 * *** BEGIN LICENSE INFORMATION *** 00013 * 00014 * The contents of this file are subject to the Common Public Attribution License 00015 * Version 1.0 (the "License"); you may not use this file except in compliance with 00016 * the License. You may obtain a copy of the License at 00017 * http://lass.sourceforge.net/cpal-license. The License is based on the 00018 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover 00019 * use of software over a computer network and provide for limited attribution for 00020 * the Original Developer. In addition, Exhibit A has been modified to be consistent 00021 * with Exhibit B. 00022 * 00023 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT 00024 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific 00025 * language governing rights and limitations under the License. 00026 * 00027 * The Original Code is LASS - Library of Assembled Shared Sources. 00028 * 00029 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer. 00030 * The Original Developer is the Initial Developer. 00031 * 00032 * All portions of the code written by the Initial Developer are: 00033 * Copyright (C) 2004-2007 the Initial Developer. 00034 * All Rights Reserved. 00035 * 00036 * Contributor(s): 00037 * 00038 * Alternatively, the contents of this file may be used under the terms of the 00039 * GNU General Public License Version 2 or later (the GPL), in which case the 00040 * provisions of GPL are applicable instead of those above. If you wish to allow use 00041 * of your version of this file only under the terms of the GPL and not to allow 00042 * others to use your version of this file under the CPAL, indicate your decision by 00043 * deleting the provisions above and replace them with the notice and other 00044 * provisions required by the GPL License. If you do not delete the provisions above, 00045 * a recipient may use your version of this file under either the CPAL or the GPL. 00046 * 00047 * *** END LICENSE INFORMATION *** 00048 */ 00049 00050 00051 00052 /** @defgroup Callback Callback 00053 * @brief library to wrap generalized callback functions in first class objects. 00054 * @date 2002-2004 00055 * @author Bram de Greve [Bramz] (contact: bramz@users.sourceforge.net) 00056 * 00057 * The use of this library is to treat function calls as first class objects, so you can pass them 00058 * around to be called at a later time. 00059 * 00060 * @code 00061 * int fun(int a, int b) { return a + b; } 00062 * // ... 00063 * CallbackR2<int, int, int> cb(fun); 00064 * // ... 00065 * int result = cb(1, 2); // result will be 3. 00066 * @endcode 00067 * 00068 * Of course, the above example could be done just as easy with plain old C function pointers. 00069 * That's true, but the advantage of this library will come forward when you want to call a 00070 * method of a specific object instead. You can tell what method must be called, and on what 00071 * object. Later, the caller can execute this without being aware this is a different case than 00072 * above. There's no way you can do this with plain old function pointers. 00073 * 00074 * @code 00075 * class Foo 00076 * { 00077 * int m_; 00078 * public: 00079 * Foo(int m): m_(m) {} 00080 * int bar(int a, b) const { return m * (a + b); } 00081 * }; 00082 * // ... 00083 * Foo foo(4); 00084 * CallbackR2<int, int, int> cb2(&foo, Foo::bar); 00085 * // ... 00086 * int result2 = cb2(1, 2); // result2 will be 12. 00087 * @endcode 00088 * 00089 * Both constant as non-constant member functions are supported as dispatchers. 00090 * 00091 * It is also possible to bind a function with a little different signature, but of which the 00092 * arguments can be implicit converted to the right type. 00093 * 00094 * @code 00095 * float spam(float a, float b) { return a / b; } 00096 * // ... 00097 * CallbackR2<int, int, int> cb3(spam); 00098 * // ... 00099 * int result3 = cb3(5, 2); // result3 will be 2 00100 * @endcode 00101 * 00102 * Callbacks can also be in an empty state. This is when the callback has no dispatcher, no 00103 * function call is bounded to it. Callbacks will be empty when constructed by the default 00104 * constructor, or when one of the arguments is a NULL pointer 00105 * 00106 * @code 00107 * CallbackR0<double> cb4; 00108 * assert(cb4.empty()); 00109 * 00110 * CallbackR1<bool, float> cb5(0); // NULL function pointer 00111 * assert(cb5.empty()); 00112 * 00113 * CallbackR2<int, int, int> cb6(0, Foo::bar); // NULL ojbect pointer 00114 * assert(cb6.empty()); 00115 * @endcode 00116 * 00117 * When executing empty callbacks, we have to distinguish two situations: callbacks without 00118 * return value, and callbacks with return value. 00119 * - In the former case, there's no danger. When the callback is executed, it has no dispatcher to 00120 * call. Hence, it won't do anything and it will immediately return. 00121 * - In the latter case, an exception will be thrown. When the callback is executed, it has to 00122 * return a value. Since there's no dispatcher to call that can return this value, we're in 00123 * troubles. An Exception will be thrown to handle this error. 00124 * 00125 * @code 00126 * Callback2<int, const std::string&> cb7; 00127 * assert(cb7.empty()); 00128 * cb7(4, "hello"); // OK, empty callback but no return value expected. 00129 * 00130 * Callback3<std::string, int, int> cb8; 00131 * assert(cb8.empty()); 00132 * try 00133 * { 00134 * std::string result8 = cb8(12, 34); // ERROR, an exception will be thrown. 00135 * } 00136 * catch(CallbackEmptyCall) 00137 * { 00138 * // you'll end up here on an empty call. 00139 * } 00140 * 00141 * std::string result8b = cb8 ? cb8(12, 34) : "bah"; // result8b will be "bah". 00142 * @endcode 00143 * 00144 * @par Callbacks without return value: 00145 * 00146 * - @ref lass::util::Callback0 00147 * - @ref lass::util::Callback1 00148 * - @ref lass::util::Callback2 00149 * - @ref lass::util::Callback3 00150 * - @ref lass::util::Callback4 00151 * - @ref lass::util::Callback5 00152 * - @ref lass::util::Callback6 00153 * - @ref lass::util::Callback7 00154 * - @ref lass::util::Callback8 00155 * - @ref lass::util::Callback9 00156 * - @ref lass::util::Callback10 00157 * - @ref lass::util::Callback11 00158 * - @ref lass::util::Callback12 00159 * - @ref lass::util::Callback13 00160 * - @ref lass::util::Callback14 00161 * - @ref lass::util::Callback15 00162 * 00163 * @par Callbacks with return value: 00164 * 00165 * - @ref lass::util::CallbackR0 00166 * - @ref lass::util::CallbackR1 00167 * - @ref lass::util::CallbackR2 00168 * - @ref lass::util::CallbackR3 00169 * - @ref lass::util::CallbackR4 00170 * - @ref lass::util::CallbackR5 00171 * - @ref lass::util::CallbackR6 00172 * - @ref lass::util::CallbackR7 00173 * - @ref lass::util::CallbackR8 00174 * - @ref lass::util::CallbackR9 00175 * - @ref lass::util::CallbackR10 00176 * - @ref lass::util::CallbackR11 00177 * - @ref lass::util::CallbackR12 00178 * - @ref lass::util::CallbackR13 00179 * - @ref lass::util::CallbackR14 00180 * - @ref lass::util::CallbackR15 00181 * * 00182 * @par Acknowledgements: 00183 * I want to thank Altair, Jaap Suter & especially Dirk Gerrits (who has spent an entire afternoon 00184 * on this to help me. It was a waste of time for both of us, but we had a lot of fun, didn't we?) 00185 */ 00186 00187 00188 00189 #ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_H 00190 #define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_H 00191 00192 #include "callback_0.h" 00193 #include "callback_1.h" 00194 #include "callback_2.h" 00195 #include "callback_3.h" 00196 #include "callback_4.h" 00197 #include "callback_5.h" 00198 #include "callback_6.h" 00199 #include "callback_7.h" 00200 #include "callback_8.h" 00201 #include "callback_9.h" 00202 #include "callback_10.h" 00203 #include "callback_11.h" 00204 #include "callback_12.h" 00205 #include "callback_13.h" 00206 #include "callback_14.h" 00207 #include "callback_15.h" 00208 00209 #include "callback_r_0.h" 00210 #include "callback_r_1.h" 00211 #include "callback_r_2.h" 00212 #include "callback_r_3.h" 00213 #include "callback_r_4.h" 00214 #include "callback_r_5.h" 00215 #include "callback_r_6.h" 00216 #include "callback_r_7.h" 00217 #include "callback_r_8.h" 00218 #include "callback_r_9.h" 00219 #include "callback_r_10.h" 00220 #include "callback_r_11.h" 00221 #include "callback_r_12.h" 00222 #include "callback_r_13.h" 00223 #include "callback_r_14.h" 00224 #include "callback_r_15.h" 00225 00226 #endif 00227 00228 // EOF
Generated on Mon Nov 10 14:20:00 2008 for Library of Assembled Shared Sources by 1.5.7.1 |