source:
orxonox.OLD/trunk/src/lib/util/loading/dynamic_loader.cc
@
8915
Last change on this file since 8915 was 8362, checked in by bensch, 18 years ago | |
---|---|
File size: 1.6 KB |
Rev | Line | |
---|---|---|
[4744] | 1 | /* |
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
3 | ||
4 | Copyright (C) 2004 orx | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
[1855] | 10 | |
11 | ### File Specific: | |
[7167] | 12 | main-programmer: Benjamin Grauer |
[1855] | 13 | co-programmer: ... |
[1853] | 14 | */ |
15 | ||
[7167] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING |
[1853] | 17 | |
[7167] | 18 | #include "dynamic_loader.h" |
[8362] | 19 | #include "debug.h" |
[1853] | 20 | |
[7355] | 21 | #ifndef __WIN32__ |
[7167] | 22 | #include <dlfcn.h> |
23 | ||
24 | ||
[1856] | 25 | using namespace std; |
[1853] | 26 | |
[1856] | 27 | |
[3245] | 28 | /** |
[4838] | 29 | * standard constructor |
30 | * @todo this constructor is not jet implemented - do it | |
[3245] | 31 | */ |
[7167] | 32 | DynamicLoader::DynamicLoader (const std::string& libName) |
33 | : Factory(NULL, CL_NULL) | |
[3365] | 34 | { |
[7167] | 35 | this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader"); |
[4320] | 36 | |
[7167] | 37 | this->handle = NULL; |
[4320] | 38 | |
[7167] | 39 | if (loadDynamicLib(libName)); |
40 | this->setName(&libName[0]); | |
[3365] | 41 | } |
[1853] | 42 | |
43 | ||
[3245] | 44 | /** |
[4838] | 45 | * standard deconstructor |
[3245] | 46 | */ |
[7167] | 47 | DynamicLoader::~DynamicLoader () |
[3543] | 48 | { |
49 | // delete what has to be deleted here | |
[7167] | 50 | if (this->handle != NULL) |
51 | dlclose(this->handle); | |
[3543] | 52 | } |
[7167] | 53 | |
54 | ||
55 | bool DynamicLoader::loadDynamicLib(const std::string& libName) | |
56 | { | |
57 | this->handle = dlopen(&libName[0], RTLD_NOW); | |
58 | if(this->handle == NULL) | |
59 | { | |
60 | return false; | |
61 | } | |
62 | void *mkr = dlsym( this->handle, "maker"); | |
[8316] | 63 | return (mkr != NULL); |
[7167] | 64 | } |
65 | ||
66 | bool DynamicLoader::loadDyLib(const std::string& libName) | |
67 | { | |
68 | void* handle; | |
69 | handle = dlopen(&libName[0], RTLD_NOW); | |
70 | if(handle == NULL) | |
71 | { | |
72 | PRINTF(0)("unable to load %s\n", &libName[0]); | |
73 | return false; | |
74 | } | |
75 | // void *mkr = dlsym("maker"); | |
[8316] | 76 | return true; |
[7167] | 77 | } |
78 | ||
79 | ||
80 | BaseObject* DynamicLoader::fabricateObject(const TiXmlElement* root) const | |
81 | { | |
[8316] | 82 | /// FIXME |
83 | return NULL; | |
[7167] | 84 | } |
[7355] | 85 | #endif |
Note: See TracBrowser
for help on using the repository browser.