/*
 * This source file is part of KEOS (Free 3D Engine)
 * For the latest info, see http://www.keosengine.org/
 * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation; either version 2 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
 * http://www.gnu.org/copyleft/lesser.txt.
 *
 */

#ifndef KEOS_DYNLIBMANAGER_H
#define KEOS_DYNLIBMANAGER_H

#include "KeosPrerequisites.h"
#include "KeosSingleton.h"

namespace Keos 
{
    //-----------------------------------------------------------------------
    /** Manager for Dynamic-loading Libraries.
     *  This manager keeps a track of all the open dynamic-loading
     *  libraries, opens them and returns references to already-open
     *  libraries.
     */
    class KEOS_EXPORT CDynLibManager: public CSingleton<CDynLibManager>
    {
    friend CSingleton<CDynLibManager>;

    public:    
        
        /** Loads the passed library.
         *  @param strFilename The name of the library. The extension can be ommitted.
         */
        CDynLib* Load(const String& strFilename);

        /** Unloads the passed library.
         *  @param pLib Library to unload.
         */
		void Unload(CDynLib* pLib);

    private:
		typedef std::map<String, CDynLib*> DynLibList;

        //! List of all the open dynamic-loading libraries
		DynLibList m_LibList;

        /** Default constructor.
         */
        CDynLibManager();

        /** Destructor.
         */
        ~CDynLibManager();
    };
}
#endif // KEOS_DYNLIBMANAGER_H
