• Main Page
  • Classes
  • Files
  • File List

TMethodEventJob.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2004 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #ifndef CMETHODEVENTJOB_H
00020 #define CMETHODEVENTJOB_H
00021 
00022 #include "IEventJob.h"
00023 
00025 
00028 template <class T>
00029 class TMethodEventJob : public IEventJob {
00030 public:
00032     TMethodEventJob(T* object,
00033                             void (T::*method)(const CEvent&, void*),
00034                             void* arg = NULL);
00035     virtual ~TMethodEventJob();
00036 
00037     // IJob overrides
00038     virtual void        run(const CEvent&);
00039 
00040 private:
00041     T*                  m_object;
00042     void                (T::*m_method)(const CEvent&, void*);
00043     void*               m_arg;
00044 };
00045 
00046 template <class T>
00047 inline
00048 TMethodEventJob<T>::TMethodEventJob(T* object,
00049                 void (T::*method)(const CEvent&, void*), void* arg) :
00050     m_object(object),
00051     m_method(method),
00052     m_arg(arg)
00053 {
00054     // do nothing
00055 }
00056 
00057 template <class T>
00058 inline
00059 TMethodEventJob<T>::~TMethodEventJob()
00060 {
00061     // do nothing
00062 }
00063 
00064 template <class T>
00065 inline
00066 void
00067 TMethodEventJob<T>::run(const CEvent& event)
00068 {
00069     if (m_object != NULL) {
00070         (m_object->*m_method)(event, m_arg);
00071     }
00072 }
00073 
00074 #endif

Generated on Sun May 19 2013 00:00:05 for Synergy by  doxygen 1.7.1