tahoma2d/toonz/sources/toonzfarm/include/tfarmproxy.h

77 lines
1.7 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 TFARMPROXY_H
#define TFARMPROXY_H
#ifdef TFARMAPI
#undef TFARMAPI
#endif
#include <string>
#include <vector>
#include "texception.h"
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
//------------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class TFARMAPI TFarmProxy {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TFarmProxy(const QString &hostName, const QString &addr, int port)
: m_hostName(hostName), m_addr(addr), m_port(port) {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual ~TFarmProxy() {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString sendToStub(const QString &data);
static int extractArgs(const QString &s, std::vector<QString> &argv);
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
QString m_hostName;
QString m_addr;
int m_port;
2016-03-19 06:57:51 +13:00
};
//------------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class TFARMAPI TFarmProxyException : public TException {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TFarmProxyException(const QString &hostname, const QString &addr, int port,
const QString &msg)
: TException(msg.toStdString())
, m_hostName(hostname)
, m_address(addr)
, m_port(port) {}
QString getHostName() const { return m_hostName; }
QString getAddress() const { return m_address; }
int getPort() const { return m_port; }
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
QString m_hostName;
QString m_address;
int m_port;
2016-03-19 06:57:51 +13:00
};
//------------------------------------------------------------------------------
class CantConnectToStub final : public TFarmProxyException {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
CantConnectToStub(const QString &hostname, const QString &addr, int port)
: TFarmProxyException(hostname, addr, port, "") {}
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TString getMessage() const override;
2016-03-19 06:57:51 +13:00
};
#endif