X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Ftool_abstract.h;h=6ef7d3b5f084becaaf50527a74a2c6f4da2d1722;hb=6f5b3c4e4b8ccffecccc8dbb1665218d22c56441;hp=25641e112df65d22cd124d75c618dc3395c46930;hpb=6164e4860474e819cfd3a223f4f1aba1d45c2ae1;p=x264-launcher%2Fx264-launcher.git diff --git a/src/tool_abstract.h b/src/tool_abstract.h index 25641e1..6ef7d3b 100644 --- a/src/tool_abstract.h +++ b/src/tool_abstract.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Simple x264 Launcher -// Copyright (C) 2004-2014 LoRd_MuldeR +// Copyright (C) 2004-2015 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -33,6 +33,10 @@ class QProcess; class QSemaphore; enum JobStatus; +// ------------------------------------------------------------ +// Base Class +// ------------------------------------------------------------ + class AbstractTool : public QObject { Q_OBJECT @@ -41,6 +45,14 @@ public: AbstractTool(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause); virtual ~AbstractTool(void) {/*NOP*/} + virtual QString getName(void) const = 0; + + virtual unsigned int checkVersion(bool &modified); + virtual bool isVersionSupported(const unsigned int &revision, const bool &modified) = 0; + virtual QString printVersion(const unsigned int &revision, const bool &modified) = 0; + + //static const unsigned int REV_MULT = 10000; + signals: void statusChanged(const JobStatus &newStatus); void progressChanged(unsigned int newProgress); @@ -52,6 +64,12 @@ protected: static const unsigned int m_processTimeoutMaxCounter = 120; static const unsigned int m_processTimeoutWarning = 24; + virtual QString getBinaryPath(void) const = 0; + + virtual void checkVersion_init(QList &patterns, QStringList &cmdLine) = 0; + virtual void checkVersion_parseLine(const QString &line, QList &patterns, unsigned int &core, unsigned int &build, bool &modified) = 0; + virtual bool checkVersion_succeeded(const int &exitCode); + void log(const QString &text) { emit messageLogged(text); } void setStatus(const JobStatus &newStatus) { emit statusChanged(newStatus); } void setProgress(unsigned int newProgress) { emit progressChanged(newProgress); } @@ -70,6 +88,26 @@ protected: static QString commandline2string(const QString &program, const QStringList &arguments); static QString stringToHash(const QString &string); - + static unsigned int makeRevision(const unsigned int &core, const unsigned int &build); + static void splitRevision(const unsigned int &revision, unsigned int &core, unsigned int &build); + static QMutex s_mutexStartProcess; }; + +// ------------------------------------------------------------ +// Helper Macros +// ------------------------------------------------------------ + +#define PROCESS_PENDING_LINES(PROC, HANDLER, ...) do \ +{ \ + while((PROC).bytesAvailable() > 0) \ + { \ + QList lines = (PROC).readLine().split('\r'); \ + while(!lines.isEmpty()) \ + { \ + const QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified(); \ + HANDLER(text, __VA_ARGS__); \ + } \ + } \ +} \ +while(0)