aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra/util.h')
-rw-r--r--engines/kyra/util.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/engines/kyra/util.h b/engines/kyra/util.h
index 1c4b8462cc..78925441f3 100644
--- a/engines/kyra/util.h
+++ b/engines/kyra/util.h
@@ -78,10 +78,37 @@ private:
Res (T::*_func)(Arg);
};
-struct ScriptState;
+template<class Arg1, class Arg2, class Res>
+struct Functor2 : public Common::BinaryFunction<Arg1, Arg2, Res> {
+ virtual ~Functor2() {}
+
+ virtual bool isValid() const = 0;
+ virtual Res operator()(Arg1, Arg2) const = 0;
+};
+
+template<class Arg1, class Arg2, class Res, class T>
+class Functor2Mem : public Functor2<Arg1, Arg2, Res> {
+public:
+ typedef Res (T::*FuncType)(Arg1, Arg2);
+
+ Functor2Mem(T *t, const FuncType &func) : _t(t), _func(func) {}
+
+ bool isValid() const { return _func != 0; }
+ Res operator()(Arg1 v1, Arg2 v2) const {
+ return (_t->*_func)(v1, v2);
+ }
+private:
+ mutable T *_t;
+ Res (T::*_func)(Arg1, Arg2);
+};
+struct ScriptState;
typedef Functor1<ScriptState*, int> Opcode;
+struct TIM;
+typedef Functor2<const TIM*, const uint16*, int> TIMOpcode;
+
} // end of namespace Kyra
#endif
+