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

TMethodEventJob.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2004 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 CMETHODEVENTJOB_H
00016 #define CMETHODEVENTJOB_H
00017 
00018 #include "IEventJob.h"
00019 
00021 
00024 template <class T>
00025 class TMethodEventJob : public IEventJob {
00026 public:
00028     TMethodEventJob(T* object,
00029                             void (T::*method)(const CEvent&, void*),
00030                             void* arg = NULL);
00031     virtual ~TMethodEventJob();
00032 
00033     // IJob overrides
00034     virtual void        run(const CEvent&);
00035 
00036 private:
00037     T*                  m_object;
00038     void                (T::*m_method)(const CEvent&, void*);
00039     void*               m_arg;
00040 };
00041 
00042 template <class T>
00043 inline
00044 TMethodEventJob<T>::TMethodEventJob(T* object,
00045                 void (T::*method)(const CEvent&, void*), void* arg) :
00046     m_object(object),
00047     m_method(method),
00048     m_arg(arg)
00049 {
00050     // do nothing
00051 }
00052 
00053 template <class T>
00054 inline
00055 TMethodEventJob<T>::~TMethodEventJob()
00056 {
00057     // do nothing
00058 }
00059 
00060 template <class T>
00061 inline
00062 void
00063 TMethodEventJob<T>::run(const CEvent& event)
00064 {
00065     if (m_object != NULL) {
00066         (m_object->*m_method)(event, m_arg);
00067     }
00068 }
00069 
00070 #endif

Generated on Fri Nov 6 00:21:15 2009 for synergy-plus by  doxygen 1.3.9.1