Subversion Repositories dloadsdl

Rev

Blame | Last modification | View Log | RSS feed

/**
 * Example Application for Dynamic Loading of SDL
 * Copyright (C) 2010  Matthias -apoc- Hecker <apoc@sixserv.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _DLLOADER_H
#define _DLLOADER_H

#include <stdlib.h>
#include <iostream>
#include <string>

#include <SDL/SDL.h>

#ifdef _WIN32
    #include <windows.h>
#else
    #include <dlfcn.h>
#endif

/**
 * Abstract Class for Dynamic Library Loading
 */

class DLLoader
{
protected:
    // Loading the function pointers/ProcSymbols
    virtual void LoadProcSymbols();
    virtual void UnloadProcSymbols();

    void *LoadSymbol(const char *symbol_name);
    bool load_proc_symbol_error;

public:
    DLLoader();
    // DLLoader(const DLLoader& orig);
    virtual ~DLLoader();

    bool Load(std::string library_filename);
    void Unload();
private:
#ifdef _WIN32
    HMODULE libhandle;
#else
    void *libhandle;
#endif

};

#endif  /* _DLLOADER_H */