source: vendor/synergy/current/lib/base/TMethodJob.h

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 1.3 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2002 Chris Schoeneman
4 *
5 * This package is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * found in the file COPYING that should have accompanied this file.
8 *
9 * This package is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef CMETHODJOB_H
16#define CMETHODJOB_H
17
18#include "IJob.h"
19
20//! Use a function as a job
21/*!
22A job class that invokes a member function.
23*/
24template <class T>
25class TMethodJob : public IJob {
26public:
27 //! run() invokes \c object->method(arg)
28 TMethodJob(T* object, void (T::*method)(void*), void* arg = NULL);
29 virtual ~TMethodJob();
30
31 // IJob overrides
32 virtual void run();
33
34private:
35 T* m_object;
36 void (T::*m_method)(void*);
37 void* m_arg;
38};
39
40template <class T>
41inline
42TMethodJob<T>::TMethodJob(T* object, void (T::*method)(void*), void* arg) :
43 m_object(object),
44 m_method(method),
45 m_arg(arg)
46{
47 // do nothing
48}
49
50template <class T>
51inline
52TMethodJob<T>::~TMethodJob()
53{
54 // do nothing
55}
56
57template <class T>
58inline
59void
60TMethodJob<T>::run()
61{
62 if (m_object != NULL) {
63 (m_object->*m_method)(m_arg);
64 }
65}
66
67#endif
Note: See TracBrowser for help on using the repository browser.