Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 2, 2006, 4:51:19 PM (19 years ago)
Author:
bensch
Message:

shared_lib: compile again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/shared_lib/src/lib/util/loading/dynamic_loader.cc

    r7167 r7264  
    1717
    1818#include "dynamic_loader.h"
    19 
    20 
    21 #include <dlfcn.h>
    22 
     19#include "resource_manager.h"
    2320
    2421using namespace std;
    25 
    2622
    2723/**
     
    3026*/
    3127DynamicLoader::DynamicLoader (const std::string& libName)
    32     : Factory(NULL, CL_NULL)
    3328{
    3429  this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader");
     
    4035}
    4136
     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}
    4251
    4352/**
     
    4857  // delete what has to be deleted here
    4958  if (this->handle != NULL)
    50     dlclose(this->handle);
     59    lt_dlclose(this->handle);
    5160}
    5261
     
    5463bool DynamicLoader::loadDynamicLib(const std::string& libName)
    5564{
    56   this->handle = dlopen(&libName[0], RTLD_NOW);
     65  DynamicLoader::initialize();
     66
     67  this->handle = lt_dlopen(&libName[0]);
    5768  if(this->handle == NULL)
    5869  {
    5970    return false;
    6071  }
    61   void *mkr = dlsym( this->handle, "maker");
    6272}
    6373
    6474bool DynamicLoader::loadDyLib(const std::string& libName)
    6575{
     76  DynamicLoader::initialize();
     77
    6678  void* handle;
    67   handle = dlopen(&libName[0], RTLD_NOW);
     79  handle = lt_dlopen(libName.c_str());
    6880  if(handle == NULL)
    6981  {
    70     PRINTF(0)("unable to load %s\n", &libName[0]);
     82    PRINTF(1)("unable to load %s: %s\n", libName.c_str(), lt_dlerror());
     83
    7184    return false;
    7285  }
    73 //  void *mkr = dlsym("maker");
     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    DynamicLoader::addSearchDir(absSearchDir);
     106    return true;
     107  }
     108  else
     109  {
     110    return false;
     111  }
     112}
     113
     114bool DynamicLoader::addSearchDirInLibDir(const std::string& relSearchDir)
     115{
    74116
    75117}
    76118
    77119
    78 BaseObject* DynamicLoader::fabricateObject(const TiXmlElement* root) const
     120const char* DynamicLoader::getSearchDir()
    79121{
     122  return lt_dlgetsearchpath();
    80123}
Note: See TracChangeset for help on using the changeset viewer.