ctkModuleDescription.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 __ctkModuleDescription_h
  15. #define __ctkModuleDescription_h
  16. #include "QHash"
  17. #include "QIcon"
  18. #include "ctkModuleParameterGroup.h"
  19. /**
  20. * Description of the parameters of a module
  21. *
  22. * The parameters can be used for automated GUI generation or execution
  23. * of the module.
  24. *
  25. * For example:
  26. * - Target: This is the entry point for a shared object module and the full
  27. * command (with path) for an executable.
  28. * - Type: Unknown, SharedObjectModule, CommandLineModule
  29. * - AlternativeTarget: This is the entry
  30. * point for a shared object module and the full command (with path)
  31. * for an executable. The alternative target is used for a second version
  32. * of a module (whose type differs from the primary target,
  33. * executable verses shared object).
  34. * - Location: This is path to the file (shared
  35. * object or executable) for the module
  36. * - AlternativeLocation: This is path to the
  37. * file (shared object or executable) for a second version of the
  38. * module (usually a different type from the primary).
  39. */
  40. class CTK_MODULDESC_EXPORT ctkModuleDescription : public QHash<QString, QString>
  41. {
  42. public:
  43. ctkModuleDescription();
  44. ctkModuleDescription(const ctkModuleDescription &md);
  45. void operator=(const ctkModuleDescription &md);
  46. void setLogo(const QIcon& logo);
  47. const QIcon& logo() const;
  48. void addParameterGroup(const ctkModuleParameterGroup &group);
  49. const QVector<ctkModuleParameterGroup>& parameterGroups() const;
  50. QVector<ctkModuleParameterGroup>& parameterGroups();
  51. void setParameterGroups(const QVector<ctkModuleParameterGroup>& groups);
  52. // Does the module have any simple (primitive) return types?
  53. bool hasReturnParameters() const;
  54. bool setParameterDefaultValue(const QString& name,
  55. const QString& value);
  56. ctkModuleParameter* parameter(const QString& name);
  57. ///
  58. /// Read a parameter file. Syntax of file is "name: value" for each
  59. /// parameter. Returns a bool indicating whether any parameter value
  60. /// was modified.
  61. bool readParameterFile(const QString& filename);
  62. ///
  63. /// Write a parameter file. By default, the method writes out all
  64. /// the parameters. The "withHandlesToBulkParameters" parameter
  65. /// controls whether the handles to the bulk parameters (image,
  66. /// geometry, etc.) are written to the file.
  67. bool writeParameterFile(const QString& filename, bool withHandlesToBulkParameters = true);
  68. private:
  69. /// Groups of parameters
  70. QVector<ctkModuleParameterGroup> ParameterGroups;
  71. /// Logo
  72. QIcon Logo;
  73. };
  74. CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const ctkModuleDescription &module);
  75. #endif