Changeset 7167 in orxonox.OLD for trunk/src/util/loading/dynamic_loader.cc
- Timestamp:
- Feb 19, 2006, 3:18:08 PM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/loading/dynamic_loader.cc
r7164 r7167 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 */ 15 15 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING 17 17 18 #include "proto_class.h" 18 #include "dynamic_loader.h" 19 20 21 #include <dlfcn.h> 22 19 23 20 24 using namespace std; … … 25 29 * @todo this constructor is not jet implemented - do it 26 30 */ 27 ProtoClass::ProtoClass () 31 DynamicLoader::DynamicLoader (const std::string& libName) 32 : Factory(NULL, CL_NULL) 28 33 { 29 this->setClassID(CL_PROTO_ID, "ProtoClass");34 this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader"); 30 35 31 /* If you make a new class, what is most probably the case when you write this file 32 don't forget to: 33 1. Add the new file new_class.cc to the ./src/Makefile.am 34 2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS 36 this->handle = NULL; 35 37 36 Advanced Topics: 37 - if you want to let your object be managed via the ObjectManager make sure to read 38 the object_manager.h header comments. You will use this most certanly only if you 39 make many objects of your class, like a weapon bullet. 40 */ 38 if (loadDynamicLib(libName)); 39 this->setName(&libName[0]); 41 40 } 42 41 … … 45 44 * standard deconstructor 46 45 */ 47 ProtoClass::~ProtoClass()46 DynamicLoader::~DynamicLoader () 48 47 { 49 48 // delete what has to be deleted here 49 if (this->handle != NULL) 50 dlclose(this->handle); 50 51 } 52 53 54 bool DynamicLoader::loadDynamicLib(const std::string& libName) 55 { 56 this->handle = dlopen(&libName[0], RTLD_NOW); 57 if(this->handle == NULL) 58 { 59 return false; 60 } 61 void *mkr = dlsym( this->handle, "maker"); 62 } 63 64 bool DynamicLoader::loadDyLib(const std::string& libName) 65 { 66 void* handle; 67 handle = dlopen(&libName[0], RTLD_NOW); 68 if(handle == NULL) 69 { 70 PRINTF(0)("unable to load %s\n", &libName[0]); 71 return false; 72 } 73 // void *mkr = dlsym("maker"); 74 75 } 76 77 78 BaseObject* DynamicLoader::fabricateObject(const TiXmlElement* root) const 79 { 80 }
Note: See TracChangeset
for help on using the changeset viewer.