ctkPluginTrackerCustomizer.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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. #ifndef CTKPLUGINTRACKERCUSTOMIZER_H
  16. #define CTKPLUGINTRACKERCUSTOMIZER_H
  17. #include <QVariant>
  18. #include "ctkPluginEvent.h"
  19. class QObject;
  20. class ctkPlugin;
  21. /**
  22. * The <code>ctkPluginTrackerCustomizer</code> interface allows a
  23. * <code>ctkPluginTracker</code> to customize the <code>Plugin</code>s that are
  24. * tracked. A <code>ctkPluginTrackerCustomizer</code> is called when a plugin is
  25. * being added to a <code>ctkPluginTracker</code>. The
  26. * <code>ctkPluginTrackerCustomizer</code> can then return an object for the
  27. * tracked plugin. A <code>ctkPluginTrackerCustomizer</code> is also called when a
  28. * tracked plugin is modified or has been removed from a
  29. * <code>ctkPluginTracker</code>.
  30. *
  31. * <p>
  32. * The methods in this interface may be called as the result of a
  33. * <code>ctkPluginEvent</code> being received by a <code>ctkPluginTracker</code>.
  34. * Since <code>ctkPluginEvent</code>s are received synchronously by the
  35. * <code>ctkPluginTracker</code>, it is highly recommended that implementations of
  36. * these methods do not alter plugin states while being synchronized on any
  37. * object.
  38. *
  39. * <p>
  40. * The <code>ctkPluginTracker</code> class is thread-safe. It does not call a
  41. * <code>ctkPluginTrackerCustomizer</code> while holding any locks.
  42. * <code>ctkPluginTrackerCustomizer</code> implementations must also be
  43. * thread-safe.
  44. *
  45. * @ThreadSafe
  46. */
  47. struct ctkPluginTrackerCustomizer {
  48. virtual ~ctkPluginTrackerCustomizer() {}
  49. /**
  50. * A plugin is being added to the <code>ctkPluginTracker</code>.
  51. *
  52. * <p>
  53. * This method is called before a plugin which matched the search parameters
  54. * of the <code>ctkPluginTracker</code> is added to the
  55. * <code>ctkPluginTracker</code>. This method should return the object to be
  56. * tracked for the specified <code>ctkPlugin</code>. The returned object is
  57. * stored in the <code>ctkPluginTracker</code> and is available from the
  58. * ctkPluginTracker::getObject(ctkPlugin*) method.
  59. *
  60. * @param plugin The <code>ctkPlugin</code> being added to the
  61. * <code>ctkPluginTracker</code>.
  62. * @param event The plugin event which caused this customizer method to be
  63. * called or an invalid event (ctkPluginEvent::isNull() returns <code>true</code>)
  64. * if there is no plugin event associated
  65. * with the call to this method.
  66. * @return The object to be tracked for the specified <code>ctkPlugin</code>
  67. * object or <code>null</code> if the specified <code>ctkPlugin</code>
  68. * object should not be tracked.
  69. */
  70. virtual QVariant addingPlugin(ctkPlugin* plugin, const ctkPluginEvent& event) = 0;
  71. /**
  72. * A plugin tracked by the <code>ctkPluginTracker</code> has been modified.
  73. *
  74. * <p>
  75. * This method is called when a plugin being tracked by the
  76. * <code>ctkPluginTracker</code> has had its state modified.
  77. *
  78. * @param plugin The <code>ctkPlugin</code> whose state has been modified.
  79. * @param event The plugin event which caused this customizer method to be
  80. * called or an invalid event (ctkPluginEvent::isNull() returns <code>true</code>)
  81. * if there is no plugin event associated
  82. * with the call to this method.
  83. * @param object The tracked object for the specified plugin.
  84. */
  85. virtual void modifiedPlugin(ctkPlugin* plugin, const ctkPluginEvent& event,
  86. QVariant object) = 0;
  87. /**
  88. * A plugin tracked by the <code>ctkPluginTracker</code> has been removed.
  89. *
  90. * <p>
  91. * This method is called after a plugin is no longer being tracked by the
  92. * <code>ctkPluginTracker</code>.
  93. *
  94. * @param plugin The <code>ctkPlugin</code> that has been removed.
  95. * @param event The plugin event which caused this customizer method to be
  96. * called or an invalid event (ctkPluginEvent::isNull() returns <code>true</code>)
  97. * if there is no plugin event associated
  98. * with the call to this method.
  99. * @param object The tracked object for the specified plugin.
  100. */
  101. virtual void removedPlugin(ctkPlugin* plugin, const ctkPluginEvent& event,
  102. QVariant object) = 0;
  103. };
  104. #endif // CTKPLUGINTRACKERCUSTOMIZER_H