TMethodJob.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef CMETHODJOB_H
00016 #define CMETHODJOB_H
00017 
00018 #include "IJob.h"
00019 
00021 
00024 template <class T>
00025 class TMethodJob : public IJob {
00026 public:
00028     TMethodJob(T* object, void (T::*method)(void*), void* arg = NULL);
00029     virtual ~TMethodJob();
00030 
00031     // IJob overrides
00032     virtual void        run();
00033 
00034 private:
00035     T*                  m_object;
00036     void                (T::*m_method)(void*);
00037     void*               m_arg;
00038 };
00039 
00040 template <class T>
00041 inline
00042 TMethodJob<T>::TMethodJob(T* object, void (T::*method)(void*), void* arg) :
00043     m_object(object),
00044     m_method(method),
00045     m_arg(arg)
00046 {
00047     // do nothing
00048 }
00049 
00050 template <class T>
00051 inline
00052 TMethodJob<T>::~TMethodJob()
00053 {
00054     // do nothing
00055 }
00056 
00057 template <class T>
00058 inline
00059 void
00060 TMethodJob<T>::run()
00061 {
00062     if (m_object != NULL) {
00063         (m_object->*m_method)(m_arg);
00064     }
00065 }
00066 
00067 #endif

Generated on Fri Nov 6 00:18:46 2009 for synergy-plus by  doxygen 1.4.7