Main Page | Class Hierarchy | Class List | File List | Class Members

aedCallBack.h

00001 
00002 /*
00003  * The aedCallBack class
00004  * This class delivers signals from the GUI library.
00005  * Initial design by Eduardo B. Fonseca <ebf@aedsol.com>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the Free
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 #ifndef AEDCALLBACK_H
00024 #define AEDCALLBACK_H
00025 
00026 #include "dllmacros.h"
00027 #include "aedFunctorNoArgs.h"
00028 #include "aedFunctor1Arg.h"
00029 
00030 class DLLEXPORT aedCallBack
00031 {
00032   public:
00033     aedCallBack()
00034     {
00035         m_FuncPtr = NULL;
00036     }
00037 
00038     aedCallBack(void (*function) (void *, void *)):m_FuncPtr(new
00039                                                              aedFunctorNoArgs <
00040                                                              stub > (function))
00041     {
00042     }
00043 
00044     template < class A >
00045         aedCallBack(void (*function) (void *, void *, A *),
00046                     A * arg):m_FuncPtr(new aedFunctor1Arg < stub, A > (function,
00047                                                                        arg))
00048     {
00049     }
00050 
00051     template < class T >
00052         aedCallBack(T * obj,
00053                     void (T::*memberfunction) (void *,
00054                                                void *)):m_FuncPtr(new
00055                                                                   aedFunctorNoArgs
00056                                                                   < T > (obj,
00057                                                                          memberfunction))
00058     {
00059     }
00060 
00061     template < class T, class A >
00062         aedCallBack(T * obj, void (T::*memberfunction) (void *, void *, A *),
00063                     A * arg):m_FuncPtr(new aedFunctor1Arg < T, A > (obj,
00064                                                                     memberfunction,
00065                                                                     arg))
00066     {
00067     }
00068 
00069     aedCallBack(const aedCallBack & obj)
00070     {
00071         m_FuncPtr = obj.getFunctor()->clone();
00072     }
00073 
00074     aedCallBack operator=(const aedCallBack & obj)
00075     {
00076         m_FuncPtr = obj.getFunctor()->clone();
00077 
00078         return *this;
00079     }
00080 
00081     aedFunctorBase *getFunctor(void) const
00082     {
00083         return m_FuncPtr;
00084     }
00085 
00086     void Call(void *caller, void *data)
00087     {
00088         if(m_FuncPtr != NULL)
00089         {
00090             m_FuncPtr->Call(caller, data);
00091         }
00092     }
00093 
00094     ~aedCallBack()
00095     {
00096         if(m_FuncPtr)
00097             delete m_FuncPtr;
00098     }
00099 
00100   private:
00101     aedFunctorBase * m_FuncPtr;
00102 };
00103 
00104 #endif

Generated on Mon Mar 1 19:56:18 2004 for aedGUI by doxygen 1.3.6