00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __XVR2_DSO_H__
00015 #define __XVR2_DSO_H__
00016 #include<xvr2/System.h>
00017 #include<xvr2/String.h>
00018 #include<xvr2/CoreExceptions.h>
00019 #include<xvr2/SystemException.h>
00020
00021 #ifndef _WIN32
00022
00023 namespace xvr2{
00028 class DSO:public System{
00029 protected:
00033 String dso;
00037 bool loaded;
00042 void *handle;
00043 public:
00048 DSO();
00053 DSO(const String &plName);
00054 ~DSO();
00061 void load();
00066 void load(const String &plName);
00070 void unload();
00075 void *getSymbol(const String &sym);
00079 const String &getDSOName();
00080 template<class T>
00081 inline T *createObject(const String &createfuncname = "__xvr2_create_dsobject"){
00082 T *obj = 0;
00083 T *(*dso_create)();
00084 dso_create = (T * (*)())getSymbol(createfuncname);
00085 obj = dso_create();
00086 return obj;
00087 }
00088 template<class T>
00089 inline void destroyObject(T *obj, const String &destroyfuncname = "__xvr2_destroy_dsobject"){
00090 void (*dso_destroy)(T *);
00091 dso_destroy = (void (*)(T *))getSymbol(destroyfuncname);
00092 dso_destroy(obj);
00093 }
00094
00098 bool isLoaded(){
00099 return loaded;
00100 }
00101 };
00102
00103 }
00104 #else
00105 #warning "There's no portability for the windows side yet"
00106 #endif
00107
00108 #endif