DSO.h

Go to the documentation of this file.
00001 /*
00002  * $Id: DSO.h 562 2007-12-02 08:04:16Z mindstorm2600 $
00003  *
00004  * X-VR2 
00005  * 
00006  * Copyright (C) Juan V. Guerrero 2007
00007  * 
00008  * Juan V. Guerrero <mindstorm2600@users.sourceforge.net>
00009  * 
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License Version 2. See the LICENSE file
00012  * at the top of the source tree.
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

Generated on Fri Jun 20 22:55:47 2008 for X-VR2 SDK by  doxygen 1.5.5