Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TFARMPROXY_H
Toshihiro Shimizu 890ddd
#define TFARMPROXY_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TFARMAPI
Toshihiro Shimizu 890ddd
#undef TFARMAPI
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <string></string>
Toshihiro Shimizu 890ddd
#include <vector></vector>
Toshihiro Shimizu 890ddd
using std::string;
Toshihiro Shimizu 890ddd
using std::vector;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "texception.h"
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 TFarmProxy {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFarmProxy(const QString &hostName, const QString &addr, int port)
Shinya Kitaoka 120a6e
      : m_hostName(hostName), m_addr(addr), m_port(port) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual ~TFarmProxy() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QString sendToStub(const QString &data);
Shinya Kitaoka 120a6e
  static int extractArgs(const QString &s, vector<qstring> &argv);</qstring>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  QString m_hostName;
Shinya Kitaoka 120a6e
  QString m_addr;
Shinya Kitaoka 120a6e
  int m_port;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class TFARMAPI TFarmProxyException : public TException {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFarmProxyException(const QString &hostname, const QString &addr, int port,
Shinya Kitaoka 120a6e
                      const QString &msg)
Shinya Kitaoka 120a6e
      : TException(msg.toStdString())
Shinya Kitaoka 120a6e
      , m_hostName(hostname)
Shinya Kitaoka 120a6e
      , m_address(addr)
Shinya Kitaoka 120a6e
      , m_port(port) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QString getHostName() const { return m_hostName; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QString getAddress() const { return m_address; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getPort() const { return m_port; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  QString m_hostName;
Shinya Kitaoka 120a6e
  QString m_address;
Shinya Kitaoka 120a6e
  int m_port;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class CantConnectToStub final : public TFarmProxyException {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  CantConnectToStub(const QString &hostname, const QString &addr, int port)
Shinya Kitaoka 120a6e
      : TFarmProxyException(hostname, addr, port, "") {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  TString getMessage() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif