Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/loading/dynamic_loader.cc @ 8319

Last change on this file since 8319 was 8316, checked in by bensch, 19 years ago

trunk: fixed most -Wall warnings… but there are still many missing :/

File size: 1.6 KB
RevLine 
[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]24using 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]31DynamicLoader::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]46DynamicLoader::~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
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");
[8316]62  return (mkr != NULL);
[7167]63}
64
65bool DynamicLoader::loadDyLib(const std::string& libName)
66{
67  void* handle;
68  handle = dlopen(&libName[0], RTLD_NOW);
69  if(handle == NULL)
70  {
71    PRINTF(0)("unable to load %s\n", &libName[0]);
72    return false;
73  }
74//  void *mkr = dlsym("maker");
[8316]75  return true;
[7167]76}
77
78
79BaseObject* DynamicLoader::fabricateObject(const TiXmlElement* root) const
80{
[8316]81  /// FIXME
82  return NULL;
[7167]83}
[7355]84#endif
Note: See TracBrowser for help on using the repository browser.