Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TFARMSERVER_H
Toshihiro Shimizu 890ddd
#define TFARMSERVER_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "texception.h"
Toshihiro Shimizu 890ddd
//#include "tconvert.h"
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qstring></qstring>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tfarmplatforms.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TFARMAPI
Toshihiro Shimizu 890ddd
#undef TFARMAPI
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#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
class TFARMAPI TFarmServer
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	class HwInfo
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
	public:
Toshihiro Shimizu 890ddd
		HwInfo()
Toshihiro Shimizu 890ddd
			: m_cpuCount(0), m_totPhysMem(0), m_availPhysMem(0), m_totVirtMem(0), m_availVirtMem(0), m_type(NoPlatform) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		int m_cpuCount;
Toshihiro Shimizu 890ddd
		unsigned int m_totPhysMem;
Toshihiro Shimizu 890ddd
		unsigned int m_availPhysMem;
Toshihiro Shimizu 890ddd
		unsigned int m_totVirtMem;
Toshihiro Shimizu 890ddd
		unsigned int m_availVirtMem;
Toshihiro Shimizu 890ddd
		TFarmPlatform m_type;
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TFarmServer() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual int addTask(const QString &taskid, const QString &cmdline) = 0;
Toshihiro Shimizu 890ddd
	virtual int terminateTask(const QString &taskid) = 0;
Toshihiro Shimizu 890ddd
	virtual int getTasks(vector<qstring> &tasks) = 0;</qstring>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual void queryHwInfo(HwInfo &hwInfo) = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// used (by a controller) to notify a controller start
Toshihiro Shimizu 890ddd
	virtual void attachController(const QString &name, const QString &addr, int port) = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// used (by a controller) to notify a controller stop
Toshihiro Shimizu 890ddd
	virtual void detachController(const QString &name, const QString &addr, int port) = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TFARMAPI TFarmServerFactory
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TFarmServerFactory();
Toshihiro Shimizu 890ddd
	~TFarmServerFactory();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int create(const QString &hostName, const QString &addr, int port, TFarmServer **tfserver);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TFARMAPI TFarmServerStub
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TFarmServerStub(TFarmServer *farmServer, int port);
Toshihiro Shimizu 890ddd
	~TFarmServerStub();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int run();
Toshihiro Shimizu 890ddd
	int shutdown();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getPort() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	class Imp;
Toshihiro Shimizu 890ddd
	Imp *m_imp;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif