Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef TFARMSERVER_H
Toshihiro Shimizu 890ddd
#define TFARMSERVER_H
Toshihiro Shimizu 890ddd
Shinya Kitaoka 262a92
#include <memory></memory>
Shinya Kitaoka 262a92
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
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
class TFARMAPI TFarmServer {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  class HwInfo {
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    HwInfo()
Shinya Kitaoka 120a6e
        : m_cpuCount(0)
Shinya Kitaoka 120a6e
        , m_totPhysMem(0)
Shinya Kitaoka 120a6e
        , m_availPhysMem(0)
Shinya Kitaoka 120a6e
        , m_totVirtMem(0)
Shinya Kitaoka 120a6e
        , m_availVirtMem(0)
Shinya Kitaoka 120a6e
        , m_type(NoPlatform) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    int m_cpuCount;
Shinya Kitaoka 120a6e
    unsigned int m_totPhysMem;
Shinya Kitaoka 120a6e
    unsigned int m_availPhysMem;
Shinya Kitaoka 120a6e
    unsigned int m_totVirtMem;
Shinya Kitaoka 120a6e
    unsigned int m_availVirtMem;
Shinya Kitaoka 120a6e
    TFarmPlatform m_type;
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual ~TFarmServer() {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual int addTask(const QString &taskid, const QString &cmdline) = 0;
Shinya Kitaoka 120a6e
  virtual int terminateTask(const QString &taskid)  = 0;
Shinya Kitaoka 120a6e
  virtual int getTasks(std::vector<qstring> &tasks) = 0;</qstring>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual void queryHwInfo(HwInfo &hwInfo) = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // used (by a controller) to notify a controller start
Shinya Kitaoka 120a6e
  virtual void attachController(const QString &name, const QString &addr,
Shinya Kitaoka 120a6e
                                int port) = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // used (by a controller) to notify a controller stop
Shinya Kitaoka 120a6e
  virtual void detachController(const QString &name, const QString &addr,
Shinya Kitaoka 120a6e
                                int port) = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TFARMAPI TFarmServerFactory {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFarmServerFactory();
Shinya Kitaoka 120a6e
  ~TFarmServerFactory();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int create(const QString &hostName, const QString &addr, int port,
Shinya Kitaoka 120a6e
             TFarmServer **tfserver);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TFARMAPI TFarmServerStub {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFarmServerStub(TFarmServer *farmServer, int port);
Shinya Kitaoka 120a6e
  ~TFarmServerStub();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int run();
Shinya Kitaoka 120a6e
  int shutdown();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getPort() const;
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