ctkModuleDescription.h 3.6 KB

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