ctkCmdLineModuleReference.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 CTKCMDLINEMODULEREFERENCE_H
  16. #define CTKCMDLINEMODULEREFERENCE_H
  17. #include <ctkCommandLineModulesCoreExport.h>
  18. #include <QSharedDataPointer>
  19. #include <QMetaType>
  20. struct ctkCmdLineModuleBackend;
  21. class ctkCmdLineModuleDescription;
  22. struct ctkCmdLineModuleReferencePrivate;
  23. /**
  24. * \class ctkCmdLineModuleReference
  25. * \brief Defines a reference or handle to a module, including location,
  26. * XML, description and access to the associated backend.
  27. * \ingroup CommandLineModulesCore_API
  28. *
  29. * Instances of this class reference registered modules and can be used
  30. * to retrieve information about their parameters or to create a specific
  31. * front-end.
  32. */
  33. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleReference
  34. {
  35. public:
  36. /**
  37. * @brief Creates an invalid module reference.
  38. */
  39. ctkCmdLineModuleReference();
  40. ~ctkCmdLineModuleReference();
  41. ctkCmdLineModuleReference(const ctkCmdLineModuleReference& ref);
  42. ctkCmdLineModuleReference& operator=(const ctkCmdLineModuleReference& ref);
  43. /**
  44. * @brief Conversion operator to test the validity of this module reference.
  45. */
  46. operator bool() const;
  47. /**
  48. * @brief Get the module description for the parameters.
  49. * @return The XML description as a class representation.
  50. * @throws ctkCmdLineModuleXmlException if the raw XML description cannot be parsed.
  51. */
  52. ctkCmdLineModuleDescription description() const;
  53. /**
  54. * @brief Get the raw XML description, as supplied by the back-end.
  55. * @return The raw XML description.
  56. */
  57. QByteArray rawXmlDescription() const;
  58. /**
  59. * @brief Retrieve a validation error string.
  60. * @return A non-empty string describing the validation error, if validation
  61. * of the XML description was not successful.
  62. */
  63. QString xmlValidationErrorString() const;
  64. /**
  65. * @brief Get the URL under which the module was registered.
  66. * @return The module location.
  67. */
  68. QUrl location() const;
  69. /**
  70. * @brief Get the back-end which was registered to handle this module.
  71. * @return The back-end handling this module.
  72. */
  73. ctkCmdLineModuleBackend* backend() const;
  74. private:
  75. friend class ctkCmdLineModuleManager;
  76. friend uint CTK_CMDLINEMODULECORE_EXPORT qHash(const ctkCmdLineModuleReference&);
  77. QSharedDataPointer<ctkCmdLineModuleReferencePrivate> d;
  78. };
  79. Q_DECLARE_METATYPE(ctkCmdLineModuleReference)
  80. uint CTK_CMDLINEMODULECORE_EXPORT qHash(const ctkCmdLineModuleReference& moduleRef);
  81. #endif // CTKCMDLINEMODULEREFERENCE_H