ctkCmdLineModuleReference.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkCmdLineModuleReference.h"
  16. #include "ctkCmdLineModuleReference_p.h"
  17. #include "ctkCmdLineModuleXmlParser_p.h"
  18. #include <QBuffer>
  19. //----------------------------------------------------------------------------
  20. ctkCmdLineModuleReferencePrivate::ctkCmdLineModuleReferencePrivate()
  21. : Backend(NULL)
  22. {
  23. }
  24. //----------------------------------------------------------------------------
  25. ctkCmdLineModuleDescription ctkCmdLineModuleReferencePrivate::description() const
  26. {
  27. // Lazy creation. The title is a required XML element.
  28. if (Description.title().isNull())
  29. {
  30. QByteArray xml(RawXmlDescription);
  31. QBuffer xmlInput(&xml);
  32. ctkCmdLineModuleXmlParser parser(&xmlInput, &Description);
  33. parser.doParse();
  34. }
  35. return Description;
  36. }
  37. //----------------------------------------------------------------------------
  38. ctkCmdLineModuleReference::ctkCmdLineModuleReference()
  39. : d(new ctkCmdLineModuleReferencePrivate())
  40. {}
  41. //----------------------------------------------------------------------------
  42. ctkCmdLineModuleReference::~ctkCmdLineModuleReference()
  43. {
  44. }
  45. //----------------------------------------------------------------------------
  46. ctkCmdLineModuleReference::ctkCmdLineModuleReference(const ctkCmdLineModuleReference &ref)
  47. : d(ref.d)
  48. {
  49. }
  50. //----------------------------------------------------------------------------
  51. ctkCmdLineModuleReference &ctkCmdLineModuleReference::operator =(const ctkCmdLineModuleReference &ref)
  52. {
  53. d = ref.d;
  54. return *this;
  55. }
  56. //----------------------------------------------------------------------------
  57. ctkCmdLineModuleReference::operator bool() const
  58. {
  59. return !d->RawXmlDescription.isEmpty();
  60. }
  61. //----------------------------------------------------------------------------
  62. ctkCmdLineModuleDescription ctkCmdLineModuleReference::description() const
  63. {
  64. return d->description();
  65. }
  66. //----------------------------------------------------------------------------
  67. QByteArray ctkCmdLineModuleReference::rawXmlDescription() const
  68. {
  69. return d->RawXmlDescription;
  70. }
  71. //----------------------------------------------------------------------------
  72. QString ctkCmdLineModuleReference::xmlValidationErrorString() const
  73. {
  74. return d->XmlValidationErrorString;
  75. }
  76. //----------------------------------------------------------------------------
  77. QUrl ctkCmdLineModuleReference::location() const
  78. {
  79. return d->Location;
  80. }
  81. //----------------------------------------------------------------------------
  82. ctkCmdLineModuleBackend *ctkCmdLineModuleReference::backend() const
  83. {
  84. return d->Backend;
  85. }
  86. //----------------------------------------------------------------------------
  87. uint qHash(const ctkCmdLineModuleReference& moduleRef)
  88. {
  89. return qHash(moduleRef.d.data());
  90. }