ctkCmdLineModuleBackend.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 CTKCMDLINEMODULEBACKEND_H
  16. #define CTKCMDLINEMODULEBACKEND_H
  17. #include "ctkCommandLineModulesCoreExport.h"
  18. class ctkCmdLineModuleFrontend;
  19. class ctkCmdLineModuleFuture;
  20. template<typename T> class QList;
  21. class QUrl;
  22. /**
  23. * @ingroup CommandLineModulesCore_API
  24. *
  25. * @brief Abstract base class for all back-end command line module
  26. * implementations.
  27. *
  28. * A back-end is responsible for providing the XML module description for a
  29. * given URL and its "timestamp". It also knows how to actually run a module,
  30. * using the current parameter values provided by a ctkCmdLineModuleFrontend instance.
  31. *
  32. * @see ctkCmdLineModuleBackendLocalProcess
  33. * @see ctkCmdLineModuleBackendFunctionPointer
  34. */
  35. struct CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleBackend
  36. {
  37. ~ctkCmdLineModuleBackend();
  38. /**
  39. * @brief Returns the name of the type of the backend, not the name
  40. * of the thing or application that is run.
  41. * @return A QString containing the name.
  42. */
  43. virtual QString name() const = 0;
  44. /**
  45. * @brief Returns a brief description of the type of the backend.
  46. * @return A QString containing a description.
  47. */
  48. virtual QString description() const = 0;
  49. /**
  50. * @brief Returns a list of URL schemes this back-end can handle.
  51. * @return A list of "schemes", meaning the capabilities.
  52. */
  53. virtual QList<QString> schemes() const = 0;
  54. /**
  55. * @brief Returns a timestap of the backend, which for example in the
  56. * case of the LocalProcess may be the last modified time of the command line
  57. * application.
  58. */
  59. virtual qint64 timeStamp(const QUrl& location) const = 0;
  60. /**
  61. * @brief Get the XML parameter description from the given location.
  62. * @param location The location URL specifying the module.
  63. * @return The raw XML parameter description.
  64. *
  65. * This method may be concurrently called by the ctkCmdLineModuleManager and
  66. * must be thread-safe. Implementations must not use any caching mechanism,
  67. * as caching is done by the ctkCmdLineModuleManager itself, checking the
  68. * return value of timeStamp().
  69. *
  70. */
  71. virtual QByteArray rawXmlDescription(const QUrl& location) = 0;
  72. protected:
  73. friend class ctkCmdLineModuleManager;
  74. /**
  75. * @brief The main method to actually execute the back-end process.
  76. * @param frontend A pointer to a front end implementation.
  77. *
  78. * Implementations must execute the actual task of running the module asynchronously
  79. * and return from this method immediately. After returning from this method,
  80. * accessing the <code>frontend</code> pointer is not guaranteed to be safe.
  81. */
  82. virtual ctkCmdLineModuleFuture run(ctkCmdLineModuleFrontend* frontend) = 0;
  83. };
  84. #endif // CTKCMDLINEMODULEBACKEND_H