|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Shinya Kitaoka |
810553 |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef SERVICE_H
|
|
Toshihiro Shimizu |
890ddd |
#define SERVICE_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
262a92 |
#include <memory></memory>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFilePath;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <string></string>
|
|
Toshihiro Shimizu |
890ddd |
#include <qstring></qstring>
|
|
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 |
bool ReportStatusToSCMgr(long currentState, long win32ExitCode, long WaitHint);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AddToMessageLog(char *msg);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
2148c8 |
TFARMAPI std::string getLastErrorText();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class TFARMAPI TService {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TService(const std::string &name, const std::string &displayName);
|
|
Shinya Kitaoka |
120a6e |
virtual ~TService();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static TService *instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
enum Status {
|
|
Shinya Kitaoka |
120a6e |
Stopped = 1,
|
|
Shinya Kitaoka |
120a6e |
StartPending,
|
|
Shinya Kitaoka |
120a6e |
StopPending,
|
|
Shinya Kitaoka |
120a6e |
Running,
|
|
Shinya Kitaoka |
120a6e |
ContinuePending,
|
|
Shinya Kitaoka |
120a6e |
PausePending,
|
|
Shinya Kitaoka |
120a6e |
Paused
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setStatus(Status status, long exitCode, long waitHint);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::string getName() const;
|
|
Shinya Kitaoka |
120a6e |
std::string getDisplayName() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void run(int argc, char *argv[], bool console = false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void onStart(int argc, char *argv[]) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void onStop() = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isRunningAsConsoleApp() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static void start(const std::string &name);
|
|
Shinya Kitaoka |
120a6e |
static void stop(const std::string &name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static void install(const std::string &name, const std::string &displayName,
|
|
Shinya Kitaoka |
120a6e |
const TFilePath &appPath);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static void remove(const std::string &name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static void addToMessageLog(const std::string &msg);
|
|
Shinya Kitaoka |
120a6e |
static void addToMessageLog(const QString &msg);
|
|
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 |
|
|
Shinya Kitaoka |
120a6e |
static TService *m_instance;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|