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

#ifndef DJ_IMAGE_OP_H
#define DJ_IMAGE_OP_H
#include <djPlugin.h>
#include <djImage.h>

namespace dj {

// Image operation base.
//
class ImageOp : public Plugin {
public:

  virtual ~ImageOp() = 0;
  
  virtual const StrList inputNameList() const { return StrList(); }
  
  typedef List<const PixelDataInfo *> InfoList;
  virtual const PixelDataInfo info(const InfoList & = InfoList()) const = 0;

  typedef List<const Image *> InputList;
  virtual const Image work(const InputList & = InputList()) const = 0;
  
protected:

  const PixelDataInfo workInfo(const InputList &) const;
};

// Convenience image operation bases.
//
class ImageOp1 : public ImageOp {
public:

  virtual ~ImageOp1() = 0;

  virtual const StrList inputNameList() const
    { return StrList() + Str("Input"); }

  virtual const PixelDataInfo info(const InfoList &) const;
};
class ImageOp2 : public ImageOp1 {
public:

  virtual ~ImageOp2() = 0;

  virtual const StrList inputNameList() const
    { return ImageOp1::inputNameList() + Str("Input 2"); }
};

// Plugin entry points.
//
typedef const List<ImageOp *> (ImageOpFnc)();

// Image operation factory.
//
class ImageOpFactory : public PluginFactory {
public:
  ~ImageOpFactory();

  const List<ImageOp *> & pluginList() { return _pluginList; }
  ImageOp * pluginCopy(const Str &);
  void pluginAdd(const List<ImageOp *> &);

protected:

  const Str pluginPrefix() const { return Str("djImageOp"); }
  bool init(void *);
  void del();

private:

  List<ImageOp *> _pluginList;
};

// Utility.
//
const StrList pluginNameList(const List<ImageOp *> &);

}

#endif
