diff options
| author | Alexander Tkachev | 2016-05-21 14:06:50 +0600 |
|---|---|---|
| committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
| commit | ca456a7241fb4b46f9c76c86eeecc273ca31d8f6 (patch) | |
| tree | 0c2ea21d76d86376ea865a5104770979def98e7f /common | |
| parent | 17eb5f91433f2414dc73f89abfdd316407259b61 (diff) | |
| download | scummvm-rg350-ca456a7241fb4b46f9c76c86eeecc273ca31d8f6.tar.gz scummvm-rg350-ca456a7241fb4b46f9c76c86eeecc273ca31d8f6.tar.bz2 scummvm-rg350-ca456a7241fb4b46f9c76c86eeecc273ca31d8f6.zip | |
CLOUD: Add object-oriented Callbacks
These callbacks can call object's methods, not some global C functions.
DropboxStorage::info2() and DropboxStorage::infoMethodCallback()
demonstrate the idea.
Diffstat (limited to 'common')
| -rw-r--r-- | common/callback.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/common/callback.h b/common/callback.h new file mode 100644 index 0000000000..4cfdd53fd9 --- /dev/null +++ b/common/callback.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef COMMON_CALLBACK_H +#define COMMON_CALLBACK_H + +namespace Common { + +class BaseCallback { +public: + BaseCallback() {} + virtual ~BaseCallback() {} + virtual void operator()(void *ptr) = 0; +}; + +template<class T> class Callback: public BaseCallback { + typedef void(T::*TMethod)(void *); + T *_object; + TMethod _method; +public: + Callback(T *object, TMethod method): _object(object), _method(method) {} + virtual ~Callback() {} + void operator()(void *ptr) { (_object->*_method)(ptr); } +}; + +} // End of namespace Common + +#endif |
