source:
orxonox.OLD/trunk/src/lib/util/loading/dynamic_loader.cc
@
7642
Last change on this file since 7642 was 7355, checked in by bensch, 19 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" |
[1853] | 19 | |
[7355] | 20 | #ifndef __WIN32__ |
[7167] | 21 | #include <dlfcn.h> |
22 | ||
23 | ||
[1856] | 24 | using namespace std; |
[1853] | 25 | |
[1856] | 26 | |
[3245] | 27 | /** |
[4838] | 28 | * standard constructor |
29 | * @todo this constructor is not jet implemented - do it | |
[3245] | 30 | */ |
[7167] | 31 | DynamicLoader::DynamicLoader (const std::string& libName) |
32 | : Factory(NULL, CL_NULL) | |
[3365] | 33 | { |
[7167] | 34 | this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader"); |
[4320] | 35 | |
[7167] | 36 | this->handle = NULL; |
[4320] | 37 | |
[7167] | 38 | if (loadDynamicLib(libName)); |
39 | this->setName(&libName[0]); | |
[3365] | 40 | } |
[1853] | 41 | |
42 | ||
[3245] | 43 | /** |
[4838] | 44 | * standard deconstructor |
[3245] | 45 | */ |
[7167] | 46 | DynamicLoader::~DynamicLoader () |
[3543] | 47 | { |
48 | // delete what has to be deleted here | |
[7167] | 49 | if (this->handle != NULL) |
50 | dlclose(this->handle); | |
[3543] | 51 | } |
[7167] | 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 | } | |
[7355] | 81 | #endif |
Note: See TracBrowser
for help on using the repository browser.