ctkModuleParameter.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #include "ctkModuleParameter.h"
  15. #include "QStringList"
  16. ctkModuleParameter::ctkModuleParameter()
  17. {
  18. }
  19. ctkModuleParameter::ctkModuleParameter(const ctkModuleParameter& parameter)
  20. : QHash<QString, QString>( QHash<QString, QString>( parameter ) )
  21. {
  22. }
  23. bool ctkModuleParameter::isReturnParameter() const
  24. {
  25. // could check for tag == float, int, float-vector, ...
  26. if ( (*this)["Channel"] == "output"
  27. && !this->isFlagParameter() && !this->isIndexParameter())
  28. {
  29. return true;
  30. }
  31. return false;
  32. }
  33. bool ctkModuleParameter::isFlagParameter() const
  34. {
  35. return ((*this)["Flag"] != "" || (*this)[ "LongFlag" ] != "");
  36. }
  37. bool ctkModuleParameter::isIndexParameter() const
  38. {
  39. return ((*this)[ "Index" ] != "");
  40. }
  41. //-----------------------------------------------------------------------------
  42. QTextStream & operator<<(QTextStream &os, const ctkModuleParameter &parameter)
  43. {
  44. os << " Parameter" << endl;
  45. os << " ";
  46. os.setFieldWidth(7);
  47. os.setFieldAlignment(QTextStream::AlignLeft);
  48. os << QHash<QString, QString>( parameter );
  49. os.setFieldWidth(0);
  50. os << "Flag aliases: ";
  51. os << parameter["FlagAliases"].split( "," );
  52. os << " " << "Deprecated Flag aliases: ";
  53. os << parameter["DeprecatedFlagAliases"].split( "," );
  54. os << " " << "LongFlag aliases: ";
  55. os << parameter["LongFlagAliases"].split( "," );
  56. os << " " << "Deprecated LongFlag aliases: ";
  57. os << parameter["DeprecatedLongFlagAliases"].split( "," );
  58. os << " " << "FileExtensions: ";
  59. os << parameter["FileExtensions"].split( "," );
  60. return os;
  61. }
  62. //----------------------------------------------------------------------------
  63. QTextStream & operator<<(QTextStream &os, const QStringList &list)
  64. {
  65. QStringList::const_iterator fit;
  66. for (fit = list.begin();fit != list.end(); ++fit)
  67. {
  68. if (fit != list.begin())
  69. {
  70. os << ", ";
  71. }
  72. os << (*fit);
  73. }
  74. os << endl;
  75. return os;
  76. }
  77. //----------------------------------------------------------------------------
  78. QTextStream & operator<<(QTextStream &os, const QHash<QString, QString> &hash)
  79. {
  80. QHash<QString,QString>::const_iterator itProp;
  81. for ( itProp = hash.begin( ) ;
  82. itProp != hash.end( ) ;
  83. itProp++ )
  84. {
  85. os << QString( itProp.key( ) + ": " + itProp.value( ) ) << endl;
  86. }
  87. return os;
  88. }