ctkCmdLineModuleReference.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. ctkCmdLineModuleDescription ctkCmdLineModuleReferencePrivate::description() const
  20. {
  21. // Lazy creation. The title is a required XML element.
  22. if (Description.title().isNull())
  23. {
  24. QByteArray xml(RawXmlDescription);
  25. QBuffer xmlInput(&xml);
  26. ctkCmdLineModuleXmlParser parser(&xmlInput, &Description);
  27. parser.doParse();
  28. }
  29. return Description;
  30. }
  31. ctkCmdLineModuleReference::ctkCmdLineModuleReference()
  32. : d(new ctkCmdLineModuleReferencePrivate())
  33. {}
  34. ctkCmdLineModuleReference::~ctkCmdLineModuleReference()
  35. {
  36. }
  37. ctkCmdLineModuleReference::ctkCmdLineModuleReference(const ctkCmdLineModuleReference &ref)
  38. : d(ref.d)
  39. {
  40. }
  41. ctkCmdLineModuleReference &ctkCmdLineModuleReference::operator =(const ctkCmdLineModuleReference &ref)
  42. {
  43. d = ref.d;
  44. return *this;
  45. }
  46. ctkCmdLineModuleReference::operator bool()
  47. {
  48. return !d->RawXmlDescription.isEmpty();
  49. }
  50. ctkCmdLineModuleDescription ctkCmdLineModuleReference::description() const
  51. {
  52. return d->description();
  53. }
  54. QByteArray ctkCmdLineModuleReference::rawXmlDescription() const
  55. {
  56. return d->RawXmlDescription;
  57. }
  58. QString ctkCmdLineModuleReference::location() const
  59. {
  60. return d->Location;
  61. }