ctkPluginFrameworkEvent.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 "ctkPluginFrameworkEvent.h"
  16. #include <QString>
  17. class ctkPluginFrameworkEventData : public QSharedData
  18. {
  19. public:
  20. ctkPluginFrameworkEventData(ctkPluginFrameworkEvent::Type type, ctkPlugin* plugin, const QString& exc)
  21. : plugin(plugin), errorString(exc), type(type)
  22. {
  23. }
  24. ctkPluginFrameworkEventData(const ctkPluginFrameworkEventData& other)
  25. : QSharedData(other), plugin(other.plugin), errorString(other.errorString),
  26. type(other.type)
  27. {
  28. }
  29. /**
  30. * Plugin related to the event.
  31. */
  32. ctkPlugin* const plugin;
  33. /**
  34. * Exception related to the event.
  35. */
  36. const QString errorString;
  37. /**
  38. * Type of event.
  39. */
  40. const ctkPluginFrameworkEvent::Type type;
  41. };
  42. ctkPluginFrameworkEvent::ctkPluginFrameworkEvent()
  43. : d(0)
  44. {
  45. }
  46. ctkPluginFrameworkEvent::~ctkPluginFrameworkEvent()
  47. {
  48. }
  49. bool ctkPluginFrameworkEvent::isNull() const
  50. {
  51. return !d;
  52. }
  53. ctkPluginFrameworkEvent::ctkPluginFrameworkEvent(Type type, ctkPlugin* plugin, const std::exception& fwException)
  54. : d(new ctkPluginFrameworkEventData(type, plugin, fwException.what()))
  55. {
  56. }
  57. ctkPluginFrameworkEvent::ctkPluginFrameworkEvent(Type type, ctkPlugin* plugin)
  58. : d(new ctkPluginFrameworkEventData(type, plugin, QString()))
  59. {
  60. }
  61. ctkPluginFrameworkEvent::ctkPluginFrameworkEvent(const ctkPluginFrameworkEvent& other)
  62. : d(other.d)
  63. {
  64. }
  65. QString ctkPluginFrameworkEvent::getErrorString() const
  66. {
  67. return d->errorString;
  68. }
  69. ctkPlugin* ctkPluginFrameworkEvent::getPlugin() const
  70. {
  71. return d->plugin;
  72. }
  73. ctkPluginFrameworkEvent::Type ctkPluginFrameworkEvent::getType() const
  74. {
  75. return d->type;
  76. }