ctkCmdLineModuleFrontend.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 CTKCMDLINEMODULEFRONTEND_H
  16. #define CTKCMDLINEMODULEFRONTEND_H
  17. #include "ctkCommandLineModulesCoreExport.h"
  18. #include <QObject>
  19. template<class K, class V> class QHash;
  20. class QUrl;
  21. class ctkCmdLineModuleFuture;
  22. class ctkCmdLineModuleReference;
  23. class ctkCmdLineModuleFrontendPrivate;
  24. /**
  25. * \ingroup CommandLineModulesCore
  26. */
  27. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleFrontend : public QObject
  28. {
  29. Q_OBJECT
  30. public:
  31. enum ParameterValueRole {
  32. /* Data returned using this role must no be of any type not supported by
  33. QVariant by default. For complex parameter types (like file, image,
  34. geometry, etc.) the data must be convertible to a QString pointing
  35. to a local resource.
  36. */
  37. LocalResourceRole = 0,
  38. /* This role can be used in custom frontends to return a QVariant
  39. containing for example an in-memory representation of a complex object.
  40. One can then either convert the in-memory representation to a local
  41. resource before running a module such that arbitrary backends relying on
  42. the LocalResourceRole can process the data. Or one creates a custom
  43. backend which knows how to handle QVariants returned by this role.
  44. */
  45. UserRole = 8
  46. };
  47. enum ParameterFilter {
  48. Input = 0x01,
  49. Output = 0x02,
  50. All = Input | Output
  51. };
  52. Q_DECLARE_FLAGS(ParameterFilters, ParameterFilter)
  53. ~ctkCmdLineModuleFrontend();
  54. virtual QObject* guiHandle() const = 0;
  55. virtual QVariant value(const QString& parameter, int role = LocalResourceRole) const = 0;
  56. virtual void setValue(const QString& parameter, const QVariant& value) = 0;
  57. virtual ctkCmdLineModuleFuture future() const;
  58. QUrl location() const;
  59. ctkCmdLineModuleReference moduleReference() const;
  60. virtual QList<QString> parameterNames() const;
  61. virtual QHash<QString,QVariant> values() const;
  62. virtual void setValues(const QHash<QString,QVariant>& values);
  63. bool isRunning() const;
  64. bool isPaused() const;
  65. Q_SIGNAL void valueChanged(const QString& parameter, const QVariant& value);
  66. protected:
  67. ctkCmdLineModuleFrontend(const ctkCmdLineModuleReference& moduleRef);
  68. void setFuture(const ctkCmdLineModuleFuture& future);
  69. private:
  70. Q_DISABLE_COPY(ctkCmdLineModuleFrontend)
  71. friend class ctkCmdLineModuleManager;
  72. friend class ctkCmdLineModulePrivate;
  73. QScopedPointer<ctkCmdLineModuleFrontendPrivate> d;
  74. };
  75. Q_DECLARE_OPERATORS_FOR_FLAGS(ctkCmdLineModuleFrontend::ParameterFilters)
  76. #endif // CTKCMDLINEMODULEFRONTEND_H