ctkCmdLineModuleParameter.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 __ctkCmdLineModuleParameter_h
  15. #define __ctkCmdLineModuleParameter_h
  16. #include "ctkCommandLineModulesCoreExport.h"
  17. #include <QSharedDataPointer>
  18. class QTextStream;
  19. class QStringList;
  20. struct ctkCmdLineModuleParameterPrivate;
  21. /**
  22. * \class ctkCmdLineModuleParameter
  23. * \brief Single parameter to a module, like a threshold of a filter.
  24. * \ingroup CommandLineModulesCore
  25. *
  26. *
  27. * ctkCmdLineModuleParameter describes a single parameter for a
  28. * module. Information on the parameter type, name, flag, label,
  29. * description, channel, index, default, and constraints can be
  30. * retrieved.
  31. */
  32. class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleParameter
  33. {
  34. public:
  35. ctkCmdLineModuleParameter(const ctkCmdLineModuleParameter& other);
  36. ~ctkCmdLineModuleParameter();
  37. ctkCmdLineModuleParameter& operator=(const ctkCmdLineModuleParameter& other);
  38. /**
  39. * @return The tag name, e.g. "integer" or "image".
  40. */
  41. QString tag() const;
  42. /**
  43. * @return The type of the parameter, e.g. "scalar" or "vector" for image parameters.
  44. */
  45. QString type() const;
  46. /**
  47. * @return <code>true</code> if the parameter is declared hidden, <code>false</code>
  48. * otherwise.
  49. */
  50. bool hidden() const;
  51. /**
  52. * Simple return types are parameters on the output channel with no
  53. * flags and with a dummy index of 1000.
  54. *
  55. * @return <code>true</code> if the parameter is a simple return type,
  56. * <code>false</code> otherwise.
  57. */
  58. bool isReturnParameter() const;
  59. /**
  60. * @return <code>true</code> if the parameter has a flag (long or short),
  61. * <code>false</code> otherwise.
  62. */
  63. bool isFlagParameter() const;
  64. /**
  65. * @return <code>true</code> if the parameter has an index, <code>false</code> otherwise.
  66. */
  67. bool isIndexParameter() const;
  68. /**
  69. * @return The parameter name.
  70. */
  71. QString name() const;
  72. /**
  73. * @return The (possibly empty) long flag for this parameter.
  74. */
  75. QString longFlag() const;
  76. /**
  77. * @return A (possibly empty) comma separated string of aliases for the long flag.
  78. */
  79. QString longFlagAliasesAsString() const;
  80. /**
  81. * @return A (possibly empty) list of long flag aliases.
  82. */
  83. QStringList longFlagAliases() const;
  84. /**
  85. * @return A (possibly empty) comma separated string of deprecated long flag aliases.
  86. */
  87. QString deprecatedLongFlagAliasesAsString() const;
  88. /**
  89. * @return A (possibly empty) list of deprectated long flag aliases.
  90. */
  91. QStringList deprecatedLongFlagAliases() const;
  92. /**
  93. * @return The human-readable name of this parameter.
  94. */
  95. QString label() const;
  96. /**
  97. * @return <code>true</code> if this parameter imposes constraints on the set of allowed values.
  98. */
  99. bool constraints() const;
  100. /**
  101. * @return The maximum value constraint.
  102. */
  103. QString maximum() const;
  104. /**
  105. * @return The minimum value constraint.
  106. */
  107. QString minimum() const;
  108. /**
  109. * @return The value step size constraint.
  110. */
  111. QString step() const;
  112. /**
  113. * @return A longer description of this parameter.
  114. */
  115. QString description() const;
  116. /**
  117. * @return The string "input" for input parameters and "output" for output parameters.
  118. */
  119. QString channel() const;
  120. /**
  121. * @return The parameter index or <code>-1</code> if this is not an indexed parameter.
  122. * @sa flag()
  123. * @sa longFlag()
  124. */
  125. int index() const;
  126. /**
  127. * @return The default value.
  128. */
  129. QString defaultValue() const;
  130. /**
  131. * @return The (possibly empty) flag for this parameter.
  132. * @sa index()
  133. */
  134. QString flag() const;
  135. /**
  136. * @return A (possibly empty) comma separated string of flag aliases.
  137. */
  138. QString flagAliasesAsString() const;
  139. /**
  140. * @return A (possibly empty) list of flag aliases.
  141. */
  142. QStringList flagAliases() const;
  143. /**
  144. * @return A (possibly empty) comma separated string of deprecated flag aliases.
  145. */
  146. QString deprecatedFlagAliasesAsString() const;
  147. /**
  148. * @return A (possibly empty) list of deprecated flag aliases.
  149. */
  150. QStringList deprecatedFlagAliases() const;
  151. /**
  152. * @return <code>true</code> if this parameter can appear multiple time in the argument list,
  153. * <code>false</code> otherwise.
  154. */
  155. bool multiple() const;
  156. /**
  157. * @return A (possibly empty) comma separated list of file extensions (e.g. "*.nrrd,*.mhd") for
  158. * the "file", "image", or "geometry" parameter tags.
  159. */
  160. QString fileExtensionsAsString() const;
  161. /**
  162. * @return A (possibly empty) list of file extensions.
  163. * @sa fileExtensionsAsString()
  164. */
  165. QStringList fileExtensions() const;
  166. /**
  167. * @return The coordinate system (either "lps", "ras", oder "ijk") for the "point" or "region"
  168. * parameter tags.
  169. */
  170. QString coordinateSystem() const;
  171. /**
  172. * @return The list of valid elements for enumeration parameters (e.g. "string-enumeration").
  173. */
  174. QStringList elements() const;
  175. private:
  176. friend struct ctkCmdLineModuleParameterParser;
  177. friend class ctkCmdLineModuleXmlParser;
  178. ctkCmdLineModuleParameter();
  179. QSharedDataPointer<ctkCmdLineModuleParameterPrivate> d;
  180. };
  181. CTK_CMDLINEMODULECORE_EXPORT QTextStream& operator<<(QTextStream& os, const ctkCmdLineModuleParameter& parameter);
  182. #endif