SDL++
C++wrapperfortheSDLlibrary.
|
00001 00021 #ifndef SDL_MISC_SHAREDOBJECT_H 00022 #define SDL_MISC_SHAREDOBJECT_H 00023 00024 #include <stdexcept> 00025 #include <string> 00026 00027 #include <SDL_loadso.h> 00028 00029 namespace sdl { 00030 namespace misc { 00035 struct SharedObject { 00043 SharedObject (const string& fileName) : handle_ (SDL_LoadObject (fileName.c_str ())), fileName_ (fileName) { 00044 if (handle_ == NULL) 00045 throw runtime_error ("Failed to load shared object " + fileName); 00046 }; 00047 00051 ~SharedObject () { SDL_UnloadObject (handle_); }; 00052 00062 void* loadFunction (const string& name) { 00063 void* func = SDL_LoadFunction (handle_, name.c_str ()); 00064 if (func == NULL) 00065 throw runtime_error ("Failed to load function " + name + " from shared object " + fileName_); 00066 return func; 00067 }; 00068 00069 private: 00075 SharedObject (const SharedObject& rhs); 00076 00084 SharedObject& operator= (const SharedObject& rhs); 00085 00089 void* handle_; 00090 00094 string fileName_; 00095 }; //SharedObject 00096 }; //misc 00097 }; //sdl 00098 00099 #endif //SDL_MISC_SHAREDOBJECT_H 00100