Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/shared_lib/src/lib/util/loading/dynamic_loader.cc @ 7913

Last change on this file since 7913 was 7266, checked in by bensch, 19 years ago

compile, but does not load anything… i do absolutely not get why :/

File size: 2.5 KB
Line 
1/*
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.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
17
18#include "dynamic_loader.h"
19#include "resource_manager.h"
20
21using namespace std;
22
23/**
24 * standard constructor
25 * @todo this constructor is not jet implemented - do it
26*/
27DynamicLoader::DynamicLoader (const std::string& libName)
28{
29  this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader");
30
31  this->handle = NULL;
32
33  if (loadDynamicLib(libName));
34  this->setName(&libName[0]);
35}
36
37/**
38 * @brief initializes the Dynamic Library loader
39 * @returns true on succes, false otherwise
40 */
41bool DynamicLoader::initialize()
42{
43  if (lt_dlinit () != 0)
44  {
45    PRINTF(1)("Initializing LT_DL_LIB: %s\n", lt_dlerror());
46    return false;
47  }
48  else
49    return true;
50}
51
52/**
53 * standard deconstructor
54*/
55DynamicLoader::~DynamicLoader ()
56{
57  // delete what has to be deleted here
58  if (this->handle != NULL)
59    lt_dlclose(this->handle);
60}
61
62
63bool DynamicLoader::loadDynamicLib(const std::string& libName)
64{
65  DynamicLoader::initialize();
66
67  this->handle = lt_dlopen(&libName[0]);
68  if(this->handle == NULL)
69  {
70    return false;
71  }
72}
73
74bool DynamicLoader::loadDyLib(const std::string& libName)
75{
76  DynamicLoader::initialize();
77
78  void* handle;
79  handle = lt_dlopen(libName.c_str());
80  if(handle == NULL)
81  {
82    PRINTF(1)("unable to load %s: %s\n", libName.c_str(), lt_dlerror());
83
84    return false;
85  }
86
87}
88
89void DynamicLoader::addSearchDir(const std::string& searchDir)
90{
91  DynamicLoader::initialize();
92
93  lt_dladdsearchdir(searchDir.c_str());
94}
95
96/**
97 * @param relSearchDir: the Relative directory to add to searchPath of lt_dl
98 * @returns true if the Path was Valid, false otherwise
99 */
100bool DynamicLoader::addSearchDirRelative(const std::string& relSearchDir)
101{
102  std::string absSearchDir = ResourceManager::getAbsDir(relSearchDir);
103  if (ResourceManager::isDir(absSearchDir))
104  {
105    //printf("ADDED %s\n", absSearchDir.c_str());
106    DynamicLoader::addSearchDir(absSearchDir);
107    return true;
108  }
109  else
110  {
111    //printf("not a directory %s\n", absSearchDir.c_str());
112    return false;
113  }
114}
115
116bool DynamicLoader::addSearchDirInLibDir(const std::string& relSearchDir)
117{
118
119}
120
121
122const char* DynamicLoader::getSearchDir()
123{
124  return lt_dlgetsearchpath();
125}
Note: See TracBrowser for help on using the repository browser.