/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * This file is part of NMM. 
 * 
 * NMM 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; only version 2 of the License.      
 * 
 * NMM 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 NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef NMM_IPluginManagerImpl_HPP
#define NMM_IPluginManagerImpl_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/NMMObject.hpp"
#include "IPluginManager.hpp"


#include "visibility.hpp"

namespace NMM
{

  class DLLEXPORT IPluginManagerImpl  : public virtual NMM::NMMObject { 
  public:
    IPluginManagerImpl() { addInterface(new IPluginManager(*this)); registerEvents(); };

    virtual ~IPluginManagerImpl() {};

  protected:
    /** This method adds library path which is searched if a library is load. 
     *  The path must be a valid Unix path on the current system.
     *  Path is only added if it is not set already.
     *  @param path path to be add
     */

    virtual void addPluginPath(const string& path) = 0;
    /** This method loads a Plug-In library, register it with a Registry by calling activateRegisryPart()
     * and with a NodeFactory by calling activateFactoryPart().
     * 
     * @param library The name of the library that should be load
     * @sa loadPlugin()
     * @sa activateRegistryPart()
     * @sa activateFactoryPart()
     */

    virtual void loadLibrary(const string& library) = 0;
    /** Loads plug-in library and register the contained plug-in. 
     * This method gets called by method loadLibrary loads a Plug-In library and registers the Plug-In.
     * @sa loadLibrary()  
     * @param plugin_name The name of the library of the Plug-In that should be load
     */

    virtual void loadPlugin(const string& plugin_name) 
      throw(const SerializedException&) = 0;
    /** This method loads all plugins in a given directory. These plugins must be 'external' plugins which does 
     * not provide NMM nodes. Thus, this method does not search and register NMM nodes, even if they exist in 
     *  a plugin.
     *
     *  @param directory directory which libraries should be loaded
     */    

    virtual void loadExternalPlugins(const string& directory) 
      throw(const SerializedException&) = 0;
    /** This method removes all plugins located in a given directory. These plugins must be 'external' plugins 
     * which does not provide NMM nodes. Thus, this method does not unregister NMM nodes, even if they 
     *  exist.
     * 
     * @param directory directory which libraries should be removed
     */

    virtual void removeExternalPlugins(const string& directory) 
      throw(const SerializedException&) = 0;
    /** This method registers the plugins of library with a Registry.
     *
     * @param library The name of the library that should be registered with a Registry
     *
     */

    virtual void activateRegistryPart(const string& library) 
      throw(const SerializedException&) = 0;
    /** This method registers the plugins of library with a NodeFactory.
     *
     * @param library The name of the library that should be registered with a NodeFactory
     *
     */

    virtual void activateFactoryPart(const string& library) 
      throw(const SerializedException&) = 0;
    /** This method removes the plugins of a library from the registry.
     * @param library The name of the library that should be removed from a registry
     */

    virtual void deactivateRegistryPart(const string& library) 
      throw(const SerializedException&) = 0;
    /** This method removes the plugins of a library from the NodeFactory.
     * @param library The name of the library that should be removed from a NodeFactory
     */

    virtual void deactivateFactoryPart(const string& library) 
      throw(const SerializedException&) = 0;
    /** Removes library with given name.
     * This method removes a library with given name. This method calls the method
     * deactivateRegistryPart() and deactivateFactoryPart().
     * @param library The name of the library that should be removed
     * @sa deactivateRegistryPart()
     * @sa deactivateFactoryPart()
     */

    virtual void removeLibrary(const string& library) 
      throw(const SerializedException&) = 0;
    /** Returns list of ObjectID's.
     * This method returns the list od ObjectID's that are set in the i'th plugin in a library.
     * The list is only valid if the plugin was registered to a Registry
     * @param library the name of the library
     * @param index the i'th plugin
     * @return list od ObjectID's that are set in the i'th plugin in a library
     */

    virtual list<ObjectID >  getPluginID(const string& library, const nmm_uint32& index) = 0;
    /** This method returns a list of all libraries that can be loaded.
     *  @return string list of all liraries that can be loaded
     */

    virtual list<string >  getPlugins() const = 0;
    /** This method returns a list of libraries that are currently in use.
     * @return string list of libraries that are currently in use
     */

    virtual list<string >  getUsedPlugins() const = 0;
    /** This method returns a list of paths that are searched for libraries.
     * @return string list of paths that are searched for libraries
     */

    virtual list<string >  getPluginPath() const = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
