//#define DJ_DBG
#include <djImageOp.h>
#include <djImageIo.h>
#include <djImageApp.h>

using namespace dj;

class App : public ImageApp {
public:
  App(int & argc, char ** argv);
  void work(const Str & type, const Plugin *);
};

App::App(int & argc, char ** argv) :
  ImageApp("imagePlugins", argc, argv)
{
  for (
    ConstListIt<ImageOp *> it = imageOp().pluginList(); it.isValid(); ++it
  )
    work("op", it());
  for (
    ConstListIt<ImageLoad *> it = imageLoad().pluginList(); it.isValid(); ++it
  )
    work("load", it());
  for (
    ConstListIt<ImageSave *> it = imageSave().pluginList(); it.isValid(); ++it
  )
    work("save", it());
}

void App::work(const Str & type, const Plugin * in)
{
  print(Str("%1 %2").arg(type).arg(in->name()));
  const StrList attrList = in->attrNameList();
  for (ConstStrListIt it = attrList; it.isValid(); ++it)
    print(Str("  %1 = %2").arg(it()).arg(in->attr(it())));
  printSeparator();
}

int main(int argc, char ** argv)
{
  DJ_DBG_LOG();
  App app(argc, argv);
  return app.exitValue();
}
