ctkCmdLineModuleBackendLocalProcess.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 CTKCMDLINEMODULEBACKENDLOCALPROCESS_H
  16. #define CTKCMDLINEMODULEBACKENDLOCALPROCESS_H
  17. #include "ctkCmdLineModuleBackend.h"
  18. #include "ctkCommandLineModulesBackendLocalProcessExport.h"
  19. #include <QScopedPointer>
  20. struct ctkCmdLineModuleBackendLocalProcessPrivate;
  21. /**
  22. * @ingroup CommandLineModulesBackendLocalProcess_API
  23. *
  24. * @brief Provides an ctkCmdLineModuleBackend implementation
  25. * to run a locally installed command line application.
  26. *
  27. * Use this back-end if you want to be able to register local executables as command
  28. * line modules. The back-end handles the "file" URL scheme, allowing you to register
  29. * modules with the ctkCmdLineModuleManager by using
  30. * @code
  31. * ctkCmdLineModuleManager::registerModule(QUrl::fromLocalFile("/path/to/executable"));
  32. * @endcode
  33. *
  34. * The XML description for a module is extracted from the standard output of the
  35. * executable when calling it with the \c &ndash;&ndash;xml command line argument.
  36. *
  37. * The ctkCmdLineModuleFuture returned by run() allows cancelation by killing the running
  38. * process. On Unix systems, it also allows to pause it.
  39. */
  40. class CTK_CMDLINEMODULEBACKENDLP_EXPORT ctkCmdLineModuleBackendLocalProcess : public ctkCmdLineModuleBackend
  41. {
  42. public:
  43. ctkCmdLineModuleBackendLocalProcess();
  44. ~ctkCmdLineModuleBackendLocalProcess();
  45. virtual QString name() const;
  46. virtual QString description() const;
  47. /**
  48. * @brief This back-end can handle the "file" URL scheme.
  49. * @return Returns the schemes this back-end can handle.
  50. */
  51. virtual QList<QString> schemes() const;
  52. /**
  53. * @brief Returns the last modified time of the module at \c location.
  54. * @param location The location URL of the module for which to get the timestamp.
  55. * @return A timestamp.
  56. */
  57. virtual qint64 timeStamp(const QUrl &location) const;
  58. /**
  59. * @brief Get the raw XML description from the module at \c location.
  60. * @param location The location URL of the module for which to get the XML description.
  61. * @return The raw XML description.
  62. *
  63. * This method always calls the executable with a \c &ndash;&ndash;xml argument and returns
  64. * the complete data emitted on the standard output channel.
  65. */
  66. virtual QByteArray rawXmlDescription(const QUrl& location);
  67. /**
  68. * @brief Run a front-end for this module in a local process.
  69. * @param frontend The front-end to run.
  70. * @return A future object for communicating with the running process.
  71. */
  72. virtual ctkCmdLineModuleFuture run(ctkCmdLineModuleFrontend *frontend);
  73. private:
  74. QScopedPointer<ctkCmdLineModuleBackendLocalProcessPrivate> d;
  75. };
  76. #endif // CTKCMDLINEMODULEBACKENDLOCALPROCESS_H