library of assembled shared sources

http://lass.cocamware.com

callback_6.h

Go to the documentation of this file.
00001 /*
00002  * *** ATTENTION!  DO NOT MODIFY THIS FILE DIRECTLY! ***
00003  * 
00004  * It has automatically been generated from callback_x.tmpl.h
00005  * by param_expander.py on Sun Nov 09 16:55:49 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 /** @class lass::util::Callback6
00053  *  @ingroup Callback
00054  *  @brief callback with 6 parameter(s) but without returnvalue.
00055  *  @date 2002
00056  *  @author Bram de Greve [Bramz] (contact: bramz@users.sourceforge.net)
00057  *
00058  *  It's a single object that can hold a reference to a free function or an
00059  *  object/(const) method pair.  Once the callback is constructed, it works
00060  *  completely transparent.  All it shows to the client is a function that
00061  *  takes one parameter but gives no returnvalue.
00062  */
00063 
00064 
00065 
00066 #ifndef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_6_H
00067 #define LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_6_H
00068 
00069 
00070 
00071 // --- OLD INTERFACES ----------------------------------------------------------
00072 
00073 #include "util_common.h"
00074 #include "shared_ptr.h"
00075 #include "impl/dispatcher_6.h"
00076 #include "callback_common.h"
00077 
00078 
00079 
00080 
00081 // --- NEW INTERFACES ----------------------------------------------------------
00082 
00083 namespace lass
00084 {
00085 namespace util
00086 {
00087 
00088 
00089 // THE CALLBACK:
00090 // This is the actuall class you use to hold callbacks:
00091 
00092 template
00093 <
00094     typename P1, typename P2, typename P3, typename P4, typename P5, typename P6
00095 >
00096 class Callback6
00097 {
00098 public:
00099 
00100     typedef Callback6<P1, P2, P3, P4, P5, P6> TSelf;
00101     typedef SharedPtr< impl::Dispatcher6<P1, P2, P3, P4, P5, P6> > TDispatcherPtr;
00102 
00103     // STRUCTORS
00104 
00105     /** Default constructor, construct empty callback.
00106      */
00107     Callback6()
00108     {
00109     }
00110 
00111     /** Construct function callback
00112      */
00113     template <typename FunctionType>
00114     Callback6(FunctionType iFunction):
00115         dispatcher_(new impl::Dispatcher6Function<P1, P2, P3, P4, P5, P6, FunctionType>(iFunction))
00116     {
00117     }
00118 
00119     /** Construct object/method callback.
00120      */
00121     template <typename ObjectPtr, typename Method>
00122     Callback6(ObjectPtr iObject, Method iMethod):
00123         dispatcher_(new impl::Dispatcher6Method<P1, P2, P3, P4, P5, P6, ObjectPtr, Method>(iObject, iMethod))
00124     {
00125     }
00126 
00127     /** copy constructor
00128      */
00129     Callback6(const TSelf& iOther):
00130         dispatcher_(iOther.dispatcher_)
00131     {
00132     }
00133 
00134 
00135 
00136     // OPERATORS
00137 
00138     /** assignment operator
00139      */
00140     template <typename Other>
00141     TSelf& operator=(const Other& iOther)
00142     {
00143         TSelf temp(iOther);
00144         swap(temp);
00145         return *this;
00146     }
00147 
00148     /** THE operator.  Executes the callback.
00149      */
00150     void operator()(typename util::CallTraits<P1>::TParam iP1, typename util::CallTraits<P2>::TParam iP2, typename util::CallTraits<P3>::TParam iP3, typename util::CallTraits<P4>::TParam iP4, typename util::CallTraits<P5>::TParam iP5, typename util::CallTraits<P6>::TParam iP6) const
00151     {
00152         if (!isEmpty())
00153         {
00154             dispatcher_->call(iP1, iP2, iP3, iP4, iP5, iP6);
00155         }
00156     }
00157 
00158 
00159     // METHODS
00160 
00161     /** Reset to empty callback.
00162      */
00163     void reset()
00164     {
00165         dispatcher_.reset();
00166     }
00167 
00168     /** Returns true if no callback dispatcher is assigned to this object.
00169      */
00170     bool isEmpty() const
00171     {
00172         return dispatcher_.isEmpty();
00173     }
00174 
00175     /** return this->isEmpty()
00176      */
00177     bool operator!() const
00178     {
00179         return dispatcher_.isEmpty(); 
00180     }
00181 
00182     /** return !this->isEmpty())
00183      */
00184     operator num::SafeBool() const
00185     {
00186         return dispatcher_.isEmpty() ? num::safeFalse : num::safeTrue;
00187     }
00188 
00189     /** Swaps the dispatcher of this callback with the dispatcher of another.
00190      */
00191     void swap(TSelf& iOther)
00192     {
00193         dispatcher_.swap(iOther.dispatcher_);
00194     }
00195 
00196 private:
00197 
00198     TDispatcherPtr dispatcher_;
00199 };
00200 
00201 
00202 
00203 /** make a Callback6 from a function
00204  *  @relates Callback6
00205  */
00206 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> inline
00207 Callback6<P1, P2, P3, P4, P5, P6> makeCallback(void (*iFunction)(P1, P2, P3, P4, P5, P6))
00208 {
00209     return Callback6<P1, P2, P3, P4, P5, P6>(iFunction);
00210 }
00211 
00212 
00213 
00214 /** make a Callback6 from a callback
00215  *  @relates Callback6
00216  */
00217 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> inline
00218 const Callback6<P1, P2, P3, P4, P5, P6>& makeCallback(const Callback6<P1, P2, P3, P4, P5, P6>& iCallback)
00219 {
00220     return iCallback;
00221 }
00222 
00223 
00224 
00225 /** make a Callback6 from a object and method
00226  *  @relates Callback6
00227  */
00228 template <typename ObjectPtr, typename Object, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> inline
00229 Callback6<P1, P2, P3, P4, P5, P6> makeCallback(ObjectPtr iObject, void (Object::*iMethod)(P1, P2, P3, P4, P5, P6))
00230 {
00231     return Callback6<P1, P2, P3, P4, P5, P6>(iObject, iMethod);
00232 }
00233 
00234 
00235 
00236 /** make a Callback6 from a object and const method
00237  *  @relates Callback6
00238  */
00239 template <typename ObjectPtr, typename Object, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> inline
00240 Callback6<P1, P2, P3, P4, P5, P6> makeCallback(ObjectPtr iObject, void (Object::*iMethod)(P1, P2, P3, P4, P5, P6) const)
00241 {
00242     return Callback6<P1, P2, P3, P4, P5, P6>(iObject, iMethod);
00243 }
00244 
00245 
00246 
00247 }
00248 
00249 }
00250 
00251 #define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_CALLBACK_6
00252 #ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_CALLBACK_PYTHON_H
00253 #   include "callback_python.h"
00254 #endif
00255 
00256 #endif // Guardian of Inclusion
00257 
00258 // EOF

Generated on Mon Nov 10 14:20:00 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo