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

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

synergy v1.3.1 sources (zip).

File size: 1.5 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2004 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 CMETHODEVENTJOB_H
16#define CMETHODEVENTJOB_H
17
18#include "IEventJob.h"
19
20//! Use a member function as an event job
21/*!
22An event job class that invokes a member function.
23*/
24template <class T>
25class TMethodEventJob : public IEventJob {
26public:
27 //! run(event) invokes \c object->method(event, arg)
28 TMethodEventJob(T* object,
29 void (T::*method)(const CEvent&, void*),
30 void* arg = NULL);
31 virtual ~TMethodEventJob();
32
33 // IJob overrides
34 virtual void run(const CEvent&);
35
36private:
37 T* m_object;
38 void (T::*m_method)(const CEvent&, void*);
39 void* m_arg;
40};
41
42template <class T>
43inline
44TMethodEventJob<T>::TMethodEventJob(T* object,
45 void (T::*method)(const CEvent&, void*), void* arg) :
46 m_object(object),
47 m_method(method),
48 m_arg(arg)
49{
50 // do nothing
51}
52
53template <class T>
54inline
55TMethodEventJob<T>::~TMethodEventJob()
56{
57 // do nothing
58}
59
60template <class T>
61inline
62void
63TMethodEventJob<T>::run(const CEvent& event)
64{
65 if (m_object != NULL) {
66 (m_object->*m_method)(event, m_arg);
67 }
68}
69
70#endif
Note: See TracBrowser for help on using the repository browser.