Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7167 in orxonox.OLD for trunk/src/util/loading/dynamic_loader.cc


Ignore:
Timestamp:
Feb 19, 2006, 3:18:08 PM (18 years ago)
Author:
bensch
Message:

trunk: dynamic library loading test

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/util/loading/dynamic_loader.cc

    r7164 r7167  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
    1515
    16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
    1717
    18 #include "proto_class.h"
     18#include "dynamic_loader.h"
     19
     20
     21#include <dlfcn.h>
     22
    1923
    2024using namespace std;
     
    2529 * @todo this constructor is not jet implemented - do it
    2630*/
    27 ProtoClass::ProtoClass ()
     31DynamicLoader::DynamicLoader (const std::string& libName)
     32    : Factory(NULL, CL_NULL)
    2833{
    29    this->setClassID(CL_PROTO_ID, "ProtoClass");
     34  this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader");
    3035
    31    /* If you make a new class, what is most probably the case when you write this file
    32       don't forget to:
    33        1. Add the new file new_class.cc to the ./src/Makefile.am
    34        2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
     36  this->handle = NULL;
    3537
    36       Advanced Topics:
    37       - if you want to let your object be managed via the ObjectManager make sure to read
    38         the object_manager.h header comments. You will use this most certanly only if you
    39         make many objects of your class, like a weapon bullet.
    40    */
     38  if (loadDynamicLib(libName));
     39  this->setName(&libName[0]);
    4140}
    4241
     
    4544 * standard deconstructor
    4645*/
    47 ProtoClass::~ProtoClass ()
     46DynamicLoader::~DynamicLoader ()
    4847{
    4948  // delete what has to be deleted here
     49  if (this->handle != NULL)
     50    dlclose(this->handle);
    5051}
     52
     53
     54bool 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
     64bool 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
     78BaseObject* DynamicLoader::fabricateObject(const TiXmlElement* root) const
     79{
     80}
Note: See TracChangeset for help on using the changeset viewer.