00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __MX_FUNC_HX_
00019 #define __MX_FUNC_HX_
00020
00021 #include"SDL.h"
00022 #include"SDL_loadso.h"
00023 #include<string>
00024
00025
00026
00027 namespace mx
00028 {
00031 class mxShared {
00032
00033 public:
00037 mxShared(std::string module_name = "");
00039 ~mxShared();
00040
00045 bool loadModule(std::string name);
00049 bool unloadModule();
00050
00055 void *loadFunction(std::string name);
00056 protected:
00057 void *ptr;
00058
00059 private:
00060 mxShared(const mxShared &);
00061 mxShared &operator=(const mxShared &);
00062 };
00063
00064
00065
00066 template<typename Class, typename Parameter, typename Return>
00068 class mxFunctor {
00069
00070 Return (Class::*func)(Parameter p);
00071 Class *cls;
00072 public:
00077 explicit mxFunctor(Class *cls, Return (Class::*functor)(Parameter p))
00078 {
00079 this->cls = cls;
00080 func = functor;
00081 }
00086 Return operator()(Parameter p)
00087 {
00088 return (*cls.*func)(p);
00089 }
00094 Return CallFunction(Parameter p)
00095 {
00096 return (*cls.*func)(p);
00097 }
00098 private:
00099 mxFunctor(const mxFunctor<Class, Parameter, Return> &f);
00100 mxFunctor<Class,Parameter,Return> &operator=(const mxFunctor<Class,Parameter,Return> &p);
00101 };
00102
00103 }
00104
00105
00106
00107 #endif
00108
00109