tahoma2d/toonz/sources/include/tfarmtask.h

188 lines
5.3 KiB
C
Raw Normal View History

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