ctkCmdLineModuleParameter.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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 d 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. #include "ctkCmdLineModuleParameter.h"
  15. #include "ctkCmdLineModuleParameterPrivate.h"
  16. #include <QStringList>
  17. #include <QTextStream>
  18. //----------------------------------------------------------------------------
  19. ctkCmdLineModuleParameter::ctkCmdLineModuleParameter()
  20. : d(new ctkCmdLineModuleParameterPrivate())
  21. { }
  22. //----------------------------------------------------------------------------
  23. ctkCmdLineModuleParameter::~ctkCmdLineModuleParameter()
  24. {
  25. }
  26. //----------------------------------------------------------------------------
  27. ctkCmdLineModuleParameter::ctkCmdLineModuleParameter(const ctkCmdLineModuleParameter &other)
  28. : d(other.d)
  29. {
  30. }
  31. //----------------------------------------------------------------------------
  32. ctkCmdLineModuleParameter& ctkCmdLineModuleParameter::operator=(const ctkCmdLineModuleParameter& other)
  33. {
  34. d = other.d;
  35. return *this;
  36. }
  37. //----------------------------------------------------------------------------
  38. QString ctkCmdLineModuleParameter::tag() const
  39. {
  40. return d->Tag;
  41. }
  42. ////----------------------------------------------------------------------------
  43. //QString ctkCmdLineModuleParameter::cppType() const
  44. //{
  45. // Q_D(const ctkCmdLineModuleParameter);
  46. // return d->CPPType;
  47. //}
  48. //----------------------------------------------------------------------------
  49. QString ctkCmdLineModuleParameter::type() const
  50. {
  51. return d->Type;
  52. }
  53. //----------------------------------------------------------------------------
  54. QString ctkCmdLineModuleParameter::reference() const
  55. {
  56. return d->Reference;
  57. }
  58. //----------------------------------------------------------------------------
  59. bool ctkCmdLineModuleParameter::hidden() const
  60. {
  61. return d->Hidden;
  62. }
  63. //----------------------------------------------------------------------------
  64. bool ctkCmdLineModuleParameter::isReturnParameter() const
  65. {
  66. // could check for tag == float, int, float-vector, ...
  67. if (d->Channel == "output"
  68. && !this->isFlagParameter() && !this->isIndexParameter())
  69. {
  70. return true;
  71. }
  72. return false;
  73. }
  74. //----------------------------------------------------------------------------
  75. bool ctkCmdLineModuleParameter::isFlagParameter() const
  76. {
  77. return (d->Flag != "" || d->LongFlag != "");
  78. }
  79. //----------------------------------------------------------------------------
  80. bool ctkCmdLineModuleParameter::isIndexParameter() const
  81. {
  82. return (d->Index > -1);
  83. }
  84. //----------------------------------------------------------------------------
  85. QString ctkCmdLineModuleParameter::argType() const
  86. {
  87. return d->ArgType;
  88. }
  89. ////----------------------------------------------------------------------------
  90. //QString ctkCmdLineModuleParameter::stringToType() const
  91. //{
  92. // Q_D(const ctkCmdLineModuleParameter);
  93. // return d->StringToType;
  94. //}
  95. //----------------------------------------------------------------------------
  96. QString ctkCmdLineModuleParameter::name() const
  97. {
  98. return d->Name;
  99. }
  100. //----------------------------------------------------------------------------
  101. QString ctkCmdLineModuleParameter::longFlag() const
  102. {
  103. return d->LongFlag;
  104. }
  105. //----------------------------------------------------------------------------
  106. QString ctkCmdLineModuleParameter::longFlagAliasesAsString() const
  107. {
  108. return d->LongFlagAliasesAsString;
  109. }
  110. //----------------------------------------------------------------------------
  111. QStringList ctkCmdLineModuleParameter::longFlagAliases() const
  112. {
  113. return d->LongFlagAliases;
  114. }
  115. //----------------------------------------------------------------------------
  116. QString ctkCmdLineModuleParameter::deprecatedLongFlagAliasesAsString() const
  117. {
  118. return d->DeprecatedLongFlagAliasesAsString;
  119. }
  120. //----------------------------------------------------------------------------
  121. QStringList ctkCmdLineModuleParameter::deprecatedLongFlagAliases() const
  122. {
  123. return d->DeprecatedLongFlagAliases;
  124. }
  125. //----------------------------------------------------------------------------
  126. QString ctkCmdLineModuleParameter::label() const
  127. {
  128. return d->Label;
  129. }
  130. //----------------------------------------------------------------------------
  131. bool ctkCmdLineModuleParameter::constraints() const
  132. {
  133. return d->Constraints;
  134. }
  135. //----------------------------------------------------------------------------
  136. QString ctkCmdLineModuleParameter::maximum() const
  137. {
  138. return d->Maximum;
  139. }
  140. //----------------------------------------------------------------------------
  141. QString ctkCmdLineModuleParameter::minimum() const
  142. {
  143. return d->Minimum;
  144. }
  145. //----------------------------------------------------------------------------
  146. QString ctkCmdLineModuleParameter::step() const
  147. {
  148. return d->Step;
  149. }
  150. //----------------------------------------------------------------------------
  151. QString ctkCmdLineModuleParameter::description() const
  152. {
  153. return d->Description;
  154. }
  155. //----------------------------------------------------------------------------
  156. QString ctkCmdLineModuleParameter::channel() const
  157. {
  158. return d->Channel;
  159. }
  160. //----------------------------------------------------------------------------
  161. int ctkCmdLineModuleParameter::index() const
  162. {
  163. return d->Index;
  164. }
  165. //----------------------------------------------------------------------------
  166. QString ctkCmdLineModuleParameter::defaultValue() const
  167. {
  168. return d->Default;
  169. }
  170. //----------------------------------------------------------------------------
  171. QString ctkCmdLineModuleParameter::flag() const
  172. {
  173. return d->Flag;
  174. }
  175. //----------------------------------------------------------------------------
  176. QString ctkCmdLineModuleParameter::flagAliasesAsString() const
  177. {
  178. return d->FlagAliasesAsString;
  179. }
  180. //----------------------------------------------------------------------------
  181. QStringList ctkCmdLineModuleParameter::flagAliases() const
  182. {
  183. return d->FlagAliases;
  184. }
  185. //----------------------------------------------------------------------------
  186. QString ctkCmdLineModuleParameter::deprecatedFlagAliasesAsString() const
  187. {
  188. return d->DeprecatedFlagAliasesAsString;
  189. }
  190. //----------------------------------------------------------------------------
  191. QStringList ctkCmdLineModuleParameter::deprecatedFlagAliases() const
  192. {
  193. return d->DeprecatedFlagAliases;
  194. }
  195. //----------------------------------------------------------------------------
  196. bool ctkCmdLineModuleParameter::multiple() const
  197. {
  198. return d->Multiple;
  199. }
  200. //----------------------------------------------------------------------------
  201. QString ctkCmdLineModuleParameter::aggregate() const
  202. {
  203. return d->Aggregate;
  204. }
  205. //----------------------------------------------------------------------------
  206. QString ctkCmdLineModuleParameter::fileExtensionsAsString() const
  207. {
  208. return d->FileExtensionsAsString;
  209. }
  210. //----------------------------------------------------------------------------
  211. QStringList ctkCmdLineModuleParameter::fileExtensions() const
  212. {
  213. return d->FileExtensions;
  214. }
  215. //----------------------------------------------------------------------------
  216. QString ctkCmdLineModuleParameter::coordinateSystem() const
  217. {
  218. return d->CoordinateSystem;
  219. }
  220. //----------------------------------------------------------------------------
  221. QStringList ctkCmdLineModuleParameter::elements() const
  222. {
  223. return d->Elements;
  224. }
  225. //----------------------------------------------------------------------------
  226. //QStringList& ctkCmdLineModuleParameter::elements()
  227. //{
  228. // return d->Elements;
  229. //}
  230. //----------------------------------------------------------------------------
  231. QTextStream& operator<<(QTextStream& os, const ctkCmdLineModuleParameter& parameter)
  232. {
  233. os << " Parameter" << '\n';
  234. os << " " << "Tag: " << parameter.tag() << '\n';
  235. os << " " << "Name: " << parameter.name() << '\n';
  236. os << " " << "Description: " << parameter.description() << '\n';
  237. os << " " << "Label: " << parameter.label() << '\n';
  238. os << " " << "Type: " << parameter.type() << '\n';
  239. os << " " << "Reference: " << parameter.reference() << '\n';
  240. os << " " << "Hidden: " << (parameter.hidden() ? "true" : "false") << '\n';
  241. //os << " " << "CPPType: " << parameter.cppType() << '\n';
  242. os << " " << "ArgType: " << parameter.argType() << '\n';
  243. //os << " " << "StringToType: " << parameter.stringToType() << '\n';
  244. os << " " << "Default: " << parameter.defaultValue() << '\n';
  245. os << " " << "Elements: " << parameter.elements().join(", ") << '\n';
  246. os << " " << "Constraints: " << (parameter.constraints() ? "true" : "false") << '\n';
  247. os << " " << "Minimum: " << parameter.minimum() << '\n';
  248. os << " " << "Maximum: " << parameter.maximum() << '\n';
  249. os << " " << "Step: " << parameter.step() << '\n';
  250. os << " " << "Flag: " << parameter.flag() << '\n';
  251. os << " " << "Flag aliases: " << parameter.flagAliasesAsString() << '\n';
  252. os << " " << "Deprecated Flag aliases: " << parameter.deprecatedFlagAliasesAsString() << '\n';
  253. os << " " << "LongFlag: " << parameter.longFlag() << '\n';
  254. os << " " << "LongFlag aliases: " << parameter.longFlagAliasesAsString() << '\n';
  255. os << " " << "Deprecated LongFlag aliases: " << parameter.deprecatedLongFlagAliasesAsString() << '\n';
  256. os << " " << "Channel: " << parameter.channel() << '\n';
  257. os << " " << "Index: " << parameter.index() << '\n';
  258. os << " " << "Multiple: " << (parameter.multiple() ? "true" : "false") << '\n';
  259. os << " " << "Aggregate: " << parameter.aggregate() << '\n';
  260. os << " " << "FileExtensions: " << parameter.fileExtensionsAsString() << '\n';
  261. os << " " << "CoordinateSystem: " << parameter.coordinateSystem() << '\n';
  262. return os;
  263. }