#ifndef QGRUNSESSION_H
#define QGRUNSESSION_H

#include <QObject>
#include <QString>

class QDir;

class QgRunSession: public QObject
{
  Q_OBJECT

  Q_PROPERTY(QString workDirPath READ workDirPath WRITE setWorkDirPath)
  Q_PROPERTY(QString outDirPath READ outDirPath WRITE setOutDirPath)
  Q_PROPERTY(QString sessionDirPath READ sessionDirPath WRITE setSessionDirPath)

  Q_PROPERTY(QString currentDirPath READ currentDirPath)

  Q_PROPERTY(bool outValid READ outValid)
  Q_PROPERTY(bool outEnable READ outEnable WRITE setOutEnable)

public:
  virtual ~QgRunSession();

  static QgRunSession& defaultSession();
  QgRunSession* createSession(const QString& name);

  bool parseStandardArguments(QStringList &, bool interactive=false);

  const QDir& workDir() const;
  const QDir& outDir() const;
  const QDir& sessionDir() const;

  QString currentDirPath() const;

  //Properties
  QString workDirPath() const;
  void setWorkDirPath(const QString&);

  QString outDirPath() const;
  void setOutDirPath(const QString&);

  QString sessionDirPath() const;
  void setSessionDirPath(const QString&);

  bool outValid() const;

  bool outEnable() const;
  void setOutEnable(bool enable=true);

  enum OutValidationFlags { OutDirNoCreate, OutDirCreate, OutDirCreateOnDemand};

  bool validateOutputDirectory(OutValidationFlags f=OutDirNoCreate);

  static QString checkArg(const QString& arg, const QString& prefix);

signals:
  void workDirChanged();
  void outDirChanged();
  void sessionDirChanged();
  void outValidChanged(bool);
  void outEnableChanged(bool);

private:
  explicit QgRunSession(const QString&);

  void setOutValid(bool valid);

  class Implementation;
  Implementation& p_;
};


#endif // QGRUNSESSION_H
