ctkCmdLineModuleDescription.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =============================================================================*/
  14. #ifndef __ctkCmdLineModuleDescription_h
  15. #define __ctkCmdLineModuleDescription_h
  16. #include <ctkCommandLineModulesCoreExport.h>
  17. #include <QList>
  18. #include <QSharedDataPointer>
  19. class QIcon;
  20. class QIODevice;
  21. class QTextStream;
  22. struct ctkCmdLineModuleDescriptionPrivate;
  23. class ctkCmdLineModuleParameterGroup;
  24. class ctkCmdLineModuleParameter;
  25. /**
  26. * \class ctkCmdLineModuleDescription
  27. * \brief Description of the parameters of a command line module.
  28. * \ingroup CommandLineModulesCore_API
  29. *
  30. * The parameters can be used for automated GUI generation or execution
  31. * of the module, and are directly related to the XML description used to
  32. * describe the command line module parameters.
  33. */
  34. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleDescription
  35. {
  36. public:
  37. ctkCmdLineModuleDescription(const ctkCmdLineModuleDescription& description);
  38. ~ctkCmdLineModuleDescription();
  39. ctkCmdLineModuleDescription& operator=(const ctkCmdLineModuleDescription& other);
  40. static ctkCmdLineModuleDescription parse(QIODevice* input);
  41. /**
  42. * @brief Returns the category, derived from the \code <category> \endcode tag.
  43. */
  44. QString category() const;
  45. /**
  46. * @brief Returns the title, derived from the \code <title> \endcode tag.
  47. */
  48. QString title() const;
  49. /**
  50. * @brief Helper method that returns the category followed by a dot followed by the title.
  51. */
  52. QString categoryDotTitle() const;
  53. /**
  54. * @brief Returns the title, derived from the \code <description> \endcode tag.
  55. */
  56. QString description() const;
  57. /**
  58. * @brief Returns the title, derived from the \code <version> \endcode tag.
  59. */
  60. QString version() const;
  61. /**
  62. * @brief Returns the title, derived from the \code <documentation-url> \endcode tag.
  63. */
  64. QString documentationURL() const;
  65. /**
  66. * @brief Returns the title, derived from the \code <license> \endcode tag.
  67. */
  68. QString license() const;
  69. /**
  70. * @brief Returns the title, derived from the \code <acknowledgements> \endcode tag.
  71. */
  72. QString acknowledgements() const;
  73. /**
  74. * @brief Returns the title, derived from the \code <contributor> \endcode tag.
  75. */
  76. QString contributor() const;
  77. /**
  78. * @brief Should return a QIcon, but does not appear to be supported yet.
  79. */
  80. QIcon logo() const;
  81. /**
  82. * \brief The XML can define groups of parameters, so this method returns
  83. * a QList of ctkCmdLineModuleParameterGroup to handle groups.
  84. */
  85. QList<ctkCmdLineModuleParameterGroup> parameterGroups() const;
  86. /**
  87. * @brief Searches the list of parameters, checking if a parameter has the given name.
  88. * @param name the name of the parameter, derived from the \code <name> \endcode tag.
  89. * @return true if this module has a parameter called name and false otherwise
  90. */
  91. bool hasParameter(const QString& name) const;
  92. /**
  93. * @brief Returns the parameter specified by name
  94. * @param name the name of the parameter, derived from the \code <name> \endcode tag.
  95. * @return the parameter
  96. * @throw ctkInvalidArgumentException if this module does not have this parameter.
  97. */
  98. ctkCmdLineModuleParameter parameter(const QString& name) const;
  99. /**
  100. * @brief Does the module have any simple (primitive) return types?
  101. */
  102. bool hasReturnParameters() const;
  103. private:
  104. friend class ctkCmdLineModuleXmlParser;
  105. friend struct ctkCmdLineModuleReferencePrivate;
  106. ctkCmdLineModuleDescription();
  107. QSharedDataPointer<ctkCmdLineModuleDescriptionPrivate> d;
  108. };
  109. CTK_CMDLINEMODULECORE_EXPORT QTextStream & operator<<(QTextStream& os, const ctkCmdLineModuleDescription& module);
  110. #endif