20 #ifndef CO_COMMANDFUNC_H
21 #define CO_COMMANDFUNC_H
24 #include <lunchbox/debug.h>
46 : _object( object ), _func( func ) {}
53 : _object( _convertThis< O >( from._object )),
54 _func( static_cast<bool (T::*)(
ICommand& )>(from._func))
62 return (_object->*_func)( command );
68 void clear() { _object = 0; _func = 0; }
70 bool isValid()
const {
return _object && _func; }
77 bool (T::*_func)( ICommand& );
81 template<
class F > T* _convertThis( F* ptr )
85 return reinterpret_cast< T*
>( ptr );
93 template<
typename T >
94 inline std::ostream& operator << ( std::ostream& os,
98 os <<
"CommandFunc of " << lunchbox::className( func._object );
100 os <<
"NULL CommandFunc";
105 #endif //CO_COMMANDFUNC_H
A class managing received commands.
A wrapper to register a function callback on an object instance.
CommandFunc(const CommandFunc< O > &from)
Create a copy of a callback to a different base class.
CommandFunc(T *object, bool(T::*func)(ICommand &))
Create a new callback to the method on the given object.