/** \file
 *
 *  Contains the Module class definition.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 *
 */

#ifndef MODULELOADER_H_
#define MODULELOADER_H_

#ifndef WINNT
#include <dlfcn.h>
#endif

#include "component/Component.h"
#include "module/LoadedModule.h"
#include "module/Module.h"
#include "utils/Str.h"

class DataReader;
class DataWriter;

/**
 *  Loads modules (either compiled c++ or scripted).
 *  \todo Eventually, will handle module unloading and reloading.
 *
 *  \ingroup module
 */
class ModuleLoader
{
public:
    /// Constructor
    ModuleLoader( ListOfLoadedModulePtrs& loadedModules );

    /// Destructor
    virtual ~ModuleLoader();

    /// Returns true if the indicated file exists
    static bool PathExists( const Str& filePath );

    /// Loads the modules in the indicated path by file name,
    /// adds the components to the list of components and component map
    /// registers their contained components' dataElements
    void loadModules( const Str& path );

    /// Loads the indicated module by file name,
    /// adds the components to the list of components and component map
    /// registers its contained components' dataElements
    LoadedModule* loadModule( Str path );

    /// Loads the indicated compiled libray module
    LoadedModule* loadLibraryModule( Str path );

    /// Run doesn't do anything
    void run( void )
    {}
    ;

private:

    /// Logger
    Logger logger_;

    /// List of modules supplied (and owned) by Supervisor
    ListOfLoadedModulePtrs& loadedModules_;


};

#endif /*MODULELOADER_H_*/
