ctkTrackedPlugin.tpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. template<class T>
  16. ctkTrackedPlugin<T>::ctkTrackedPlugin(ctkPluginTracker<T>* pluginTracker,
  17. ctkPluginTrackerCustomizer<T>* customizer)
  18. : pluginTracker(pluginTracker), customizer(customizer)
  19. {
  20. }
  21. template<class T>
  22. void ctkTrackedPlugin<T>::pluginChanged(const ctkPluginEvent& event)
  23. {
  24. /*
  25. * Check if we had a delayed call (which could happen when we
  26. * close).
  27. */
  28. if (this->closed)
  29. {
  30. return;
  31. }
  32. QSharedPointer<ctkPlugin> plugin = event.getPlugin();
  33. ctkPlugin::State state = plugin->getState();
  34. if (pluginTracker->d_func()->DEBUG)
  35. {
  36. qDebug() << "ctkTrackedPlugin<T>::pluginChanged[" << state << "]: " << *plugin;
  37. }
  38. if (pluginTracker->d_func()->mask & state)
  39. {
  40. this->track(plugin, event);
  41. /*
  42. * If the customizer throws an exception, it is safe
  43. * to let it propagate
  44. */
  45. }
  46. else
  47. {
  48. this->untrack(plugin, event);
  49. /*
  50. * If the customizer throws an exception, it is safe
  51. * to let it propagate
  52. */
  53. }
  54. }
  55. template<class T>
  56. T ctkTrackedPlugin<T>::customizerAdding(QSharedPointer<ctkPlugin> item,
  57. const ctkPluginEvent& related)
  58. {
  59. return customizer->addingPlugin(item, related);
  60. }
  61. template<class T>
  62. void ctkTrackedPlugin<T>::customizerModified(QSharedPointer<ctkPlugin> item,
  63. const ctkPluginEvent& related,
  64. T object)
  65. {
  66. customizer->modifiedPlugin(item, related, object);
  67. }
  68. template<class T>
  69. void ctkTrackedPlugin<T>::customizerRemoved(QSharedPointer<ctkPlugin> item,
  70. const ctkPluginEvent& related,
  71. T object)
  72. {
  73. customizer->removedPlugin(item, related, object);
  74. }