ctkCmdLineModuleDescription.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 "ctkCmdLineModuleDescription.h"
  15. #include "ctkCmdLineModuleDescriptionPrivate.h"
  16. #include "ctkCmdLineModuleParameter.h"
  17. #include "ctkCmdLineModuleParameterGroup.h"
  18. #include "ctkException.h"
  19. #include <QTextStream>
  20. //----------------------------------------------------------------------------
  21. ctkCmdLineModuleDescription::ctkCmdLineModuleDescription()
  22. : d(new ctkCmdLineModuleDescriptionPrivate)
  23. {
  24. }
  25. //----------------------------------------------------------------------------
  26. ctkCmdLineModuleDescription::~ctkCmdLineModuleDescription()
  27. {
  28. }
  29. //----------------------------------------------------------------------------
  30. QString ctkCmdLineModuleDescription::category() const
  31. {
  32. return d->Category;
  33. }
  34. //----------------------------------------------------------------------------
  35. QString ctkCmdLineModuleDescription::title() const
  36. {
  37. return d->Title;
  38. }
  39. //----------------------------------------------------------------------------
  40. QString ctkCmdLineModuleDescription::description() const
  41. {
  42. return d->Description;
  43. }
  44. //----------------------------------------------------------------------------
  45. QString ctkCmdLineModuleDescription::version() const
  46. {
  47. return d->Version;
  48. }
  49. //----------------------------------------------------------------------------
  50. QString ctkCmdLineModuleDescription::documentationURL() const
  51. {
  52. return d->DocumentationURL;
  53. }
  54. //----------------------------------------------------------------------------
  55. QString ctkCmdLineModuleDescription::license() const
  56. {
  57. return d->License;
  58. }
  59. //----------------------------------------------------------------------------
  60. QString ctkCmdLineModuleDescription::acknowledgements() const
  61. {
  62. return d->Acknowledgements;
  63. }
  64. //----------------------------------------------------------------------------
  65. QString ctkCmdLineModuleDescription::contributor() const
  66. {
  67. return d->Contributor;
  68. }
  69. //----------------------------------------------------------------------------
  70. QIcon ctkCmdLineModuleDescription::logo() const
  71. {
  72. return d->Logo;
  73. }
  74. //----------------------------------------------------------------------------
  75. QList<ctkCmdLineModuleParameterGroup> ctkCmdLineModuleDescription::parameterGroups() const
  76. {
  77. return d->ParameterGroups;
  78. }
  79. //----------------------------------------------------------------------------
  80. bool ctkCmdLineModuleDescription::hasParameter(const QString& name) const
  81. {
  82. // iterate over each parameter group
  83. foreach(const ctkCmdLineModuleParameterGroup group, d->ParameterGroups)
  84. {
  85. if (group.hasParameter(name)) return true;
  86. }
  87. return false;
  88. }
  89. //----------------------------------------------------------------------------
  90. ctkCmdLineModuleParameter ctkCmdLineModuleDescription::parameter(const QString& name) const
  91. {
  92. foreach(const ctkCmdLineModuleParameterGroup group, d->ParameterGroups)
  93. {
  94. if (group.hasParameter(name))
  95. {
  96. return group.parameter(name);
  97. }
  98. }
  99. throw ctkInvalidArgumentException(QString("No parameter named \"%1\" available.").arg(name));
  100. }
  101. //----------------------------------------------------------------------------
  102. bool ctkCmdLineModuleDescription::hasReturnParameters() const
  103. {
  104. // iterate over each parameter group
  105. foreach(const ctkCmdLineModuleParameterGroup group, d->ParameterGroups)
  106. {
  107. if (group.hasReturnParameters()) return true;
  108. }
  109. return false;
  110. }
  111. //----------------------------------------------------------------------------
  112. QTextStream & operator<<(QTextStream &os, const ctkCmdLineModuleDescription &module)
  113. {
  114. os << "Title: " << module.title() << '\n';
  115. os << "Category: " << module.category() << '\n';
  116. os << "Description: " << module.description() << '\n';
  117. os << "Version: " << module.version() << '\n';
  118. os << "DocumentationURL: " << module.documentationURL() << '\n';
  119. os << "License: " << module.license() << '\n';
  120. os << "Contributor: " << module.contributor() << '\n';
  121. os << "Acknowledgements: " << module.acknowledgements() << '\n';
  122. //os << "Logo: " << module.GetLogo() << '\n';
  123. os << "ParameterGroups: " << '\n';
  124. foreach(const ctkCmdLineModuleParameterGroup group, module.parameterGroups())
  125. {
  126. os << group;
  127. }
  128. return os;
  129. }