ctkModuleParameter.cpp 2.9 KB

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