Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7264 in orxonox.OLD for branches/shared_lib/src/lib/util/loading


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

shared_lib: compile again

Location:
branches/shared_lib/src/lib/util/loading
Files:
3 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}
  • branches/shared_lib/src/lib/util/loading/dynamic_loader.h

    r7193 r7264  
    88
    99#include "util/loading/factory.h"
     10#include <ltdl.h>
    1011
    1112#include <string>
    12 
    13 #define DYNAMIC_LINKAGE_FACTORY(CLASS_NAME, CLASS_ID) \
    14           void* DynamicCreator(const TiXmlElement* root) { return new CLASS_NAME(root); };
    1513
    1614// FORWARD DECLARATION
    1715
    1816//! A class for ...
    19 class DynamicLoader : public Factory
     17class DynamicLoader : public BaseObject
    2018{
    2119
     
    2523
    2624  bool loadDynamicLib(const std::string& libName);
    27   virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const;
    2825
    2926  static bool loadDyLib(const std::string& libName);
    3027
     28  static void addSearchDir(const std::string& searchDir);
     29  static bool addSearchDirRelative(const std::string& relSearchDir);
     30  static bool addSearchDirInLibDir(const std::string& relSearchDir);
     31  static const char* getSearchDir();
     32
     33  static void unload();
     34private:
     35  // will be done automatically when using the this Engine.
     36  static bool initialize();
    3137
    3238private:
    33   void*      handle;
     39  lt_dlhandle      handle;
    3440};
    3541
  • branches/shared_lib/src/lib/util/loading/resource_manager.cc

    r7225 r7264  
    881881
    882882
     883
     884
    883885/**
    884886 * @param fileName the Name of the File to check
     
    921923  return ResourceManager::getInstance()->_cwd;
    922924}
    923 
    924925
    925926/**
Note: See TracChangeset for help on using the changeset viewer.