|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TFARMCONTROLLER_H
|
|
Toshihiro Shimizu |
890ddd |
#define TFARMCONTROLLER_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <vector></vector>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using std::vector;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tfarmtask.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "tfilepath.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFilePath;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TFARMAPI
|
|
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 |
|
|
Shinya Kitaoka |
120a6e |
enum ServerState { Ready, Busy, NotResponding, Down, Offline, ServerUnknown };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class ServerIdentity {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ServerIdentity(const QString &id, const QString &name)
|
|
Shinya Kitaoka |
120a6e |
: m_id(id), m_name(name) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString m_id;
|
|
Shinya Kitaoka |
120a6e |
QString m_name;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class ServerInfo {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
QString m_name;
|
|
Shinya Kitaoka |
120a6e |
QString m_ipAddress;
|
|
Shinya Kitaoka |
120a6e |
QString m_portNumber;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ServerState m_state;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString m_platform;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int m_cpuCount;
|
|
Shinya Kitaoka |
120a6e |
unsigned int m_totPhysMem;
|
|
Shinya Kitaoka |
120a6e |
unsigned int m_totVirtMem;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// the following fields can be used just if the server state is not Down
|
|
Shinya Kitaoka |
120a6e |
unsigned int m_availPhysMem;
|
|
Shinya Kitaoka |
120a6e |
unsigned int m_availVirtMem;
|
|
Shinya Kitaoka |
120a6e |
QString m_currentTaskId;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TaskShortInfo {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TaskShortInfo(const QString &id, const QString &name, TaskState status)
|
|
Shinya Kitaoka |
120a6e |
: m_id(id), m_name(name), m_status(status) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString m_id;
|
|
Shinya Kitaoka |
120a6e |
QString m_name;
|
|
Shinya Kitaoka |
120a6e |
TaskState m_status;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TFARMAPI TFarmController {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
virtual ~TFarmController() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual QString addTask(const TFarmTask &task, bool suspended) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void removeTask(const QString &id) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void suspendTask(const QString &id) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void activateTask(const QString &id) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void restartTask(const QString &id) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void getTasks(vector<qstring> &tasks) = 0;</qstring>
|
|
Shinya Kitaoka |
120a6e |
virtual void getTasks(const QString &parentId, vector<qstring> &tasks) = 0;</qstring>
|
|
Shinya Kitaoka |
120a6e |
virtual void getTasks(const QString &parentId,
|
|
Shinya Kitaoka |
120a6e |
vector<taskshortinfo> &tasks) = 0;</taskshortinfo>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void queryTaskInfo(const QString &id, TFarmTask &task) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void queryTaskShortInfo(const QString &id, QString &parentId,
|
|
Shinya Kitaoka |
120a6e |
QString &name, TaskState &status) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// used (by a server) to notify a server start
|
|
Shinya Kitaoka |
120a6e |
virtual void attachServer(const QString &name, const QString &addr,
|
|
Shinya Kitaoka |
120a6e |
int port) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// used (by a server) to notify a server stop
|
|
Shinya Kitaoka |
120a6e |
virtual void detachServer(const QString &name, const QString &addr,
|
|
Shinya Kitaoka |
120a6e |
int port) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// used by a server to notify a task submission error
|
|
Shinya Kitaoka |
120a6e |
virtual void taskSubmissionError(const QString &taskId, int errCode) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// used by a server to notify a task progress
|
|
Shinya Kitaoka |
120a6e |
virtual void taskProgress(const QString &taskId, int step, int stepCount,
|
|
Shinya Kitaoka |
120a6e |
int frameNumber, FrameState state) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// used by a server to notify a task completion
|
|
Shinya Kitaoka |
120a6e |
virtual void taskCompleted(const QString &taskId, int exitCode) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// fills the servers vector with the identities of the servers
|
|
Shinya Kitaoka |
120a6e |
virtual void getServers(vector<serveridentity> &servers) = 0;</serveridentity>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// returns the state of the server whose id has been specified
|
|
Shinya Kitaoka |
120a6e |
virtual ServerState queryServerState2(const QString &id) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// fills info with the infoes about the server whose id is specified
|
|
Shinya Kitaoka |
120a6e |
virtual void queryServerInfo(const QString &id, ServerInfo &info) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// activates the server whose id has been specified
|
|
Shinya Kitaoka |
120a6e |
virtual void activateServer(const QString &id) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// deactivates the server whose id has been specified
|
|
Shinya Kitaoka |
120a6e |
// once deactivated, a server is not available for task rendering
|
|
Shinya Kitaoka |
120a6e |
virtual void deactivateServer(const QString &id,
|
|
Shinya Kitaoka |
120a6e |
bool completeRunningTasks = true) = 0;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TFARMAPI ControllerData {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ControllerData(const QString &hostName = "", const QString &ipAddr = "",
|
|
Shinya Kitaoka |
120a6e |
int port = 0)
|
|
Shinya Kitaoka |
120a6e |
: m_hostName(hostName), m_ipAddress(ipAddr), m_port(port) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool operator==(const ControllerData &rhs) {
|
|
Shinya Kitaoka |
120a6e |
return m_hostName == rhs.m_hostName && m_ipAddress == rhs.m_ipAddress &&
|
|
Shinya Kitaoka |
120a6e |
m_port == rhs.m_port;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString m_hostName;
|
|
Shinya Kitaoka |
120a6e |
QString m_ipAddress;
|
|
Shinya Kitaoka |
120a6e |
int m_port;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TFARMAPI TFarmControllerFactory {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TFarmControllerFactory();
|
|
Shinya Kitaoka |
120a6e |
int create(const ControllerData &data, TFarmController **controller);
|
|
Shinya Kitaoka |
120a6e |
int create(const QString &hostname, int port, TFarmController **controller);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFARMAPI loadControllerData(const TFilePath &fp, ControllerData &data);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|