ctkCmdLineModuleFuture.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "ctkCmdLineModuleFutureInterface.h"
  19. #include <QFuture>
  20. /**
  21. * \class ctkCmdLineModuleFuture
  22. * \brief QFuture sub-class for enhanced communication with running modules.
  23. * \ingroup CommandLineModulesCore_API
  24. *
  25. * Please see the QFuture documentation of Qt for details. This sub-class provides
  26. * additional query methods to check if a module can be paused and/or canceled and
  27. * also provides the ability to retrieve the arbitrary output and error data
  28. * from the module.
  29. *
  30. * \see ctkCmdLineModuleFutureWatcher
  31. */
  32. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleFuture : public QFuture<ctkCmdLineModuleResult>
  33. {
  34. public:
  35. ctkCmdLineModuleFuture();
  36. /** \cond */
  37. explicit ctkCmdLineModuleFuture(ctkCmdLineModuleFutureInterface* p); // internal
  38. /** \endcond */
  39. /**
  40. * @brief Read all output data reported by the running module so far.
  41. * @return Returns the reported output.
  42. */
  43. QByteArray readAllOutputData() const;
  44. /**
  45. * @brief Read all error data reported by the running module so far.
  46. * @return Returns the reported error.
  47. */
  48. QByteArray readAllErrorData() const;
  49. /**
  50. * @brief Check if this module can be canceled via cancel().
  51. * @return \c true if this module can be canceled, \c false otherwise.
  52. */
  53. bool canCancel() const;
  54. /**
  55. * @brief Check if this module can be paused via pause() and similar QFuture methods.
  56. * @return \c true if this module can be paused, \c false otherwise.
  57. */
  58. bool canPause() const;
  59. };
  60. inline ctkCmdLineModuleFuture ctkCmdLineModuleFutureInterface::future()
  61. {
  62. return ctkCmdLineModuleFuture(this);
  63. }
  64. #endif // CTKCMDLINEMODULEFUTURE_H