Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef TFARMTASK_H
Toshihiro Shimizu 890ddd
#define TFARMTASK_H
Toshihiro Shimizu 890ddd
Shinya Kitaoka 262a92
#include <memory></memory>
Shinya Kitaoka 262a92
Campbell Barton d0e335
#include <qdatetime></qdatetime>
Toshihiro Shimizu 890ddd
#include "tpersist.h"
Toshihiro Shimizu 890ddd
#include "tfarmplatforms.h"
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
#ifdef TFARMAPI
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef TFARMAPI
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#ifdef TFARM_EXPORTS
Toshihiro Shimizu 890ddd
#define TFARMAPI __declspec(dllexport)
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define TFARMAPI __declspec(dllimport)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define TFARMAPI
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const int cPortNumber = 51005;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
enum TaskState { Suspended, Waiting, Running, Completed, Aborted, TaskUnknown };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
enum FrameState { FrameDone, FrameFailed };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
enum OverwriteBehavior { Overwrite_All = 0, Overwrite_NoPaint, Overwrite_Off };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define RENDER_LICENSE_NOT_FOUND 888
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TFARMAPI TFarmTask : public TPersist {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef QString Id;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  class TFARMAPI Dependencies {
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    Dependencies();
Shinya Kitaoka 120a6e
    ~Dependencies();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    Dependencies(const Dependencies &);
Shinya Kitaoka 120a6e
    Dependencies &operator=(const Dependencies &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bool operator==(const Dependencies &);
Shinya Kitaoka 120a6e
    bool operator!=(const Dependencies &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    void add(const QString &id);
Shinya Kitaoka 120a6e
    void remove(const QString &id);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    int getTaskCount() const;
Shinya Kitaoka 120a6e
    QString getTaskId(int i) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  private:
Shinya Kitaoka 120a6e
    class Data;
Shinya Kitaoka 120a6e
    Data *m_data;
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Id m_id;        //!< Internal task identifier
Shinya Kitaoka 120a6e
  Id m_parentId;  //!< Task id of the parent task (if any)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_isComposerTask;  //!< Whether this is a tcomposer task (opposed to
Shinya Kitaoka 38fd86
                          //! tcleanupper task)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QString m_name;               //!< User-readable name
Shinya Kitaoka 120a6e
  TFilePath m_taskFilePath;     //!< Path of the input file affected by the task
Shinya Kitaoka 120a6e
  TFilePath m_outputPath;       //!< Path of the task's output file
Shinya Kitaoka 120a6e
  QString m_callerMachineName;  //!< Name of the... caller (submitter?) machine
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_priority;  //!< Priority value used for scheduling order
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QString m_user;      //!< User who submitted the task
Shinya Kitaoka 120a6e
  QString m_hostName;  //!< Machine on which the task was submitted
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TaskState
Shinya Kitaoka 120a6e
      m_status;      //!< The task's status (completed, work in progress... etc)
Shinya Kitaoka 120a6e
  QString m_server;  //!< Server node (name) the task was supplied to
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QDateTime m_submissionDate;
Shinya Kitaoka 120a6e
  QDateTime m_startDate;
Shinya Kitaoka 120a6e
  QDateTime m_completionDate;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_successfullSteps;  //
Shinya Kitaoka 120a6e
  int m_failedSteps;       //
Shinya Kitaoka 120a6e
  int m_stepCount;  // Why 3 values ? One should be found with the other 2!
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_from, m_to, m_step, m_shrink;  //!< Range data
Shinya Kitaoka 120a6e
  int m_chunkSize;                     //!< Sub-tasks size
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_multimedia;
Shinya Kitaoka 120a6e
  int m_threadsIndex;
Shinya Kitaoka 120a6e
  int m_maxTileSizeIndex;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  OverwriteBehavior m_overwrite;
Shinya Kitaoka 120a6e
  bool m_onlyVisible;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmPlatform m_platform;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Dependencies *m_dependencies;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFarmTask(const QString &name = "");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmTask(const QString &id, const QString &name, const QString &cmdline,
Shinya Kitaoka 120a6e
            const QString &user, const QString &host, int stepCount,
Shinya Kitaoka 120a6e
            int priority);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmTask(const QString &id, const QString &name, bool composerTask,
Shinya Kitaoka 120a6e
            const QString &user, const QString &host, int stepCount,
Shinya Kitaoka 120a6e
            int priority, const TFilePath &taskFilePath,
Shinya Kitaoka 120a6e
            const TFilePath &outputPath, int from, int to, int step, int shrink,
Shinya Kitaoka 120a6e
            int multimedia, int chunksize, int threadsIndex,
Shinya Kitaoka 120a6e
            int maxTileSizeIndex, OverwriteBehavior overwrite,
Shinya Kitaoka 120a6e
            bool onlyvisible);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual ~TFarmTask() { delete m_dependencies; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmTask(const TFarmTask &);
Shinya Kitaoka 120a6e
  TFarmTask &operator=(const TFarmTask &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool operator==(const TFarmTask &task);
Shinya Kitaoka 120a6e
  bool operator!=(const TFarmTask &task);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual int getTaskCount() const { return 1; }
Shinya Kitaoka 120a6e
  virtual TFarmTask *getTask(int index) { return this; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QString getCommandLine(bool isFarmTask = false) const;
Shinya Kitaoka 120a6e
  void parseCommandLine(QString commandLine);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // TPersist
Shinya Kitaoka 473e70
  void loadData(TIStream &is) override;
Shinya Kitaoka 473e70
  void saveData(TOStream &os) override;
Shinya Kitaoka 473e70
  const TPersistDeclaration *getDeclaration() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class TFARMAPI TFarmTaskGroup final : public TFarmTask {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFarmTaskGroup();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmTaskGroup(const QString &id, const QString &name, const QString &user,
Shinya Kitaoka 120a6e
                 const QString &host, int stepCount, int priority,
Shinya Kitaoka 120a6e
                 const TFilePath &taskFilePath, const TFilePath &outputPath,
Shinya Kitaoka 120a6e
                 int from, int to, int step, int shrink, int multimedia,
Shinya Kitaoka 120a6e
                 int chunksize, int threadsIndex, int maxTileSizeIndex);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmTaskGroup(const QString &id, const QString &name, const QString &user,
Shinya Kitaoka 120a6e
                 const QString &host, int stepCount, int priority,
Shinya Kitaoka 120a6e
                 const TFilePath &taskFilePath, OverwriteBehavior overwrite,
Shinya Kitaoka 120a6e
                 bool onlyvisible);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmTaskGroup(const QString &id, const QString &name, const QString &cmdline,
Shinya Kitaoka 120a6e
                 const QString &user, const QString &host, int stepCount,
Shinya Kitaoka 120a6e
                 int priority);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFarmTaskGroup(const TFarmTaskGroup &src);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ~TFarmTaskGroup();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addTask(TFarmTask *task);
Shinya Kitaoka 120a6e
  void removeTask(TFarmTask *task);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int getTaskCount() const override;
Shinya Kitaoka 473e70
  TFarmTask *getTask(int index) override;
Shinya Kitaoka 120a6e
  bool changeChunkSize(int chunksize);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // TPersist
Shinya Kitaoka 473e70
  void loadData(TIStream &is) override;
Shinya Kitaoka 473e70
  void saveData(TOStream &os) override;
Shinya Kitaoka 473e70
  const TPersistDeclaration *getDeclaration() const override;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  class Imp;
Shinya Kitaoka 120a6e
  std::unique_ptr<imp> m_imp;</imp>
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif