DSObject.h

Go to the documentation of this file.
00001 /*
00002  * $Id: DSObject.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_DS_OBJECT_H__
00015 #define __XVR2_DS_OBJECT_H__
00016 #include<xvr2/Object.h>
00017 #include<xvr2/String.h>
00018 #include<xvr2/DSO.h>
00019 #include<xvr2/CoreExceptions.h>
00020 
00021 namespace xvr2 {
00022 
00023         /* DSObject stands for Dynamic Shared Object and is a for to load a C++ object
00024          * from a shared library, in the same way you load a funciotns using the Plugin
00025          * class.
00026          * @todo Document the DSObjectFactory class better. */
00027         class DSObjectFactory : public Object {
00028                 private:
00029                 protected:
00030                 public:
00031                         template<class T>
00032                         static T *create(DSO *dso, const String &createfuncname = "__xvr2_create_dsobject"){
00033                                 T *obj = 0;
00034                                 T *(*dso_create)();
00035                                 dso_create = (T * (*)())dso->getSymbol(createfuncname);
00036                                 obj = dso_create();
00037                                 return obj;
00038                         }
00039                         template<class T>
00040                         static void destroy(DSO *dso, T *obj, const String &destroyfuncname = "__xvr2_destroy_dsobject"){
00041                                 void (*dso_destroy)(T *);
00042                                 dso_destroy = (void (*)(T *))dso->getSymbol(destroyfuncname);
00043                                 dso_destroy(obj);
00044                         }
00045         };
00046 
00047 }
00048 
00049 #endif

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