ctkCmdLineModuleFuture.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKCMDLINEMODULEFUTURE_H
  16. #define CTKCMDLINEMODULEFUTURE_H
  17. #include <ctkCommandLineModulesCoreExport.h>
  18. //#include <QFutureInterface>
  19. //#include <QFutureWatcher>
  20. #include <QProcess>
  21. /**
  22. * \ingroup CommandLineModulesCore
  23. */
  24. class ctkCmdLineModuleFuture
  25. {
  26. public:
  27. ctkCmdLineModuleFuture()
  28. : d(ctkCmdLineModuleFutureInterface::canceledResult())
  29. { }
  30. explicit ctkCmdLineModuleFuture(const ctkCmdLineModuleProcess& p) // internal
  31. : d(*p)
  32. { }
  33. ctkCmdLineModuleFuture(const ctkCmdLineModuleFuture &other)
  34. : d(other.d)
  35. { }
  36. ~ctkCmdLineModuleFuture()
  37. { }
  38. ctkCmdLineModuleFuture& operator=(const ctkCmdLineModuleFuture& other);
  39. bool operator==(const ctkCmdLineModuleFuture& other) const { return (d == other.d); }
  40. bool operator!=(const ctkCmdLineModuleFuture& other) const { return (d != other.d); }
  41. void cancel() { d.cancel(); }
  42. bool isCanceled() const { return d.isCanceled(); }
  43. bool isStarted() const { return d.isStarted(); }
  44. bool isFinished() const { return d.isFinished(); }
  45. bool isRunning() const { return d.isRunning(); }
  46. int exitCode() const { return d.exitCode(); }
  47. int exitStatus() const { return d.exitStatus(); }
  48. QProcess::ProcessError error() const { return d.error(); }
  49. QString errorString() const { return d.errorString(); }
  50. QString standardOutput() const { return d.standardOutput(); }
  51. QString standardError() const { return d.standardError(); }
  52. int progressValue() const { return d.progressValue(); }
  53. int progressMinimum() const { return d.progressMinimum(); }
  54. int progressMaximum() const { return d.progressMaximum(); }
  55. QString progressText() const { return d.progressText(); }
  56. void waitForFinished() { d.waitForFinished(); }
  57. private:
  58. friend class ctkCmdLineModuleFutureWatcher;
  59. mutable ctkCmdLineModuleProcess d;
  60. };
  61. inline ctkCmdLineModuleFuture& ctkCmdLineModuleFuture::operator=(const ctkCmdLineModuleFuture& other)
  62. {
  63. d = other.d;
  64. return *this;
  65. }
  66. #endif // CTKCMDLINEMODULEFUTURE_H