/*------------------------------------------------------------------------------
 src/lib/dj/djPlugin.h
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJ_PLUGIN_H
#define DJ_PLUGIN_H
#include <djBase.h>

namespace dj {

// Plugin base.
//
typedef Map<Str, StrList> PluginAttr;
class Plugin {
public:

  virtual ~Plugin() = 0;
  
  virtual const Str name() const = 0;
  virtual Plugin * copy() const = 0;
  
  // Attributes.
  //
  virtual const StrList attrNameList() const { return StrList(); }
  virtual bool attr(const Str &, const StrList &) { return false; }
  virtual const StrList attr(const Str &) const { return StrList(); }
  bool attrSet(const PluginAttr &);
  const PluginAttr attrGet() const;
};

// Plugin factory base.
//
class PluginFactory {
public:

  PluginFactory();
  virtual ~PluginFactory();
  
  void set(const StrList & searchPathList = StrList());
  
protected:

  virtual const Str pluginPrefix() const = 0;
  virtual bool init(void *) = 0;
  virtual void del();

private:

  List<void *> _handleList;
};

}

#endif
