//=-- PluginManager.h - Maintains plugins, makes sure they all play nicely ---=
//
//  The class organizes all of the plugins.  It is the main dispatch class that
//    interfaces with all of the plugin classes.  See Plugins.h for more info.
//
//=---------------------------------------------------------------------------=
//  This file is copyright (c) 1997-1998 Chris Lattner
//=---------------------------------------------------------------------------=

#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H

#include "LinkedList.h"

class String;
class CSString;
class MSFilename;
class AccessFormatPlugin;
class Plugin;
class PagePlugin;
class VTExp;
template <class Key, class Value> class Table;

class PluginManager {
public :
  PluginManager();
  int  init();
  ~PluginManager();

  static void ProcessAccess(AccessFormatPlugin &access);
  static void FlushPluginState(int UpdateFreq);

  // Find a plugin matching the name S in the internal PluginList list of 
  //   instantiated plugins.  See the Plugin class to create plugins.
  static PagePlugin *GetPagePlugin(const CSString &S);
  static PagePlugin *GetPagePluginByFullName(const String &S);

  static int AddPlugin(Plugin *);
  static int RemovePlugin(Plugin *);

  void LoadPluginData();
  void SavePluginData();

private :

  static LinkedList<Plugin *> &PluginList();
  int Initialized;

  void LoadDynaPlugins();

  static void InitPlugins();
  void InitOutputFiles();

  // Support functions...
  int ScanFileForPlugins(const MSFilename &, int, Table<CSString,VTExp*> &,
                         const String &CWD);
};

#endif
