ctkPluginEvent.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. #ifndef CTKPLUGINEVENT_H
  16. #define CTKPLUGINEVENT_H
  17. #include <QSharedDataPointer>
  18. #include "CTKPluginFrameworkExport.h"
  19. class ctkPlugin;
  20. class ctkPluginEventData;
  21. /**
  22. * An event from the Framework describing a plugin lifecycle change.
  23. * <p>
  24. * <code>ctkPluginEvent</code> objects are delivered to slots connected
  25. * via ctkPluginContext::connectPluginListener() when a change
  26. * occurs in a plugins's lifecycle. A type code is used to identify
  27. * the event type for future extendability.
  28. *
  29. * @see ctkPluginContext#connectPluginListener
  30. */
  31. class CTK_PLUGINFW_EXPORT ctkPluginEvent
  32. {
  33. QSharedDataPointer<ctkPluginEventData> d;
  34. public:
  35. enum Type {
  36. /**
  37. * The plugin has been installed.
  38. *
  39. * @see ctkPluginContext::installBundle(const QString&)
  40. */
  41. INSTALLED,
  42. /**
  43. * The plugin has been started.
  44. * <p>
  45. * The plugin's
  46. * \link ctkPluginActivator::start(ctkPluginContext*) ctkPluginActivator start\endlink method
  47. * has been executed.
  48. *
  49. * @see ctkPlugin::start()
  50. */
  51. STARTED,
  52. /**
  53. * The plugin has been stopped.
  54. * <p>
  55. * The plugin's
  56. * \link ctkPluginActivator::stop(ctkPluginContext*) ctkPluginActivator stop\endlink method
  57. * has been executed.
  58. *
  59. * @see ctkPlugin::stop()
  60. */
  61. STOPPED,
  62. /**
  63. * The plugin has been updated.
  64. *
  65. * @see ctkPlugin::update()
  66. */
  67. UPDATED,
  68. /**
  69. * The plugin has been uninstalled.
  70. *
  71. * @see ctkPlugin::uninstall()
  72. */
  73. UNINSTALLED,
  74. /**
  75. * The plugin has been resolved.
  76. *
  77. * @see ctkPlugin::RESOLVED
  78. */
  79. RESOLVED,
  80. /**
  81. * The plugin has been unresolved.
  82. *
  83. * @see ctkPlugin::INSTALLED
  84. */
  85. UNRESOLVED,
  86. /**
  87. * The plugin is about to be activated.
  88. * <p>
  89. * The plugin's
  90. * \link ctkPluginActivator::start(ctkPluginContext*) ctkPluginActivator start\endlink method
  91. * is about to be called. This
  92. * event is only delivered to synchronuous slots, which have been registered with
  93. * Qt::DirectConnection or Qt::BlockingQueuedConnection in ctkPluginContext::connectPluginListener().
  94. *
  95. * @see ctkPlugin::start()
  96. */
  97. STARTING,
  98. /**
  99. * The plugin is about to deactivated.
  100. * <p>
  101. * The plugin's
  102. * \link ctkPluginActivator::stop(ctkPluginContext*) ctkPluginActivator stop\endlink method
  103. * is about to be called. This
  104. * event is only delivered to synchronuous slots, which have been registered with
  105. * Qt::DirectConnection or Qt::BlockingQueuedConnection in ctkPluginContext::connectPluginListener().
  106. *
  107. * @see ctkPlugin::stop()
  108. */
  109. STOPPING,
  110. /**
  111. * The plugin will be lazily activated.
  112. * <p>
  113. * The plugin has a \link ctkPluginConstant::ACTIVATION_LAZY lazy activation policy\endlink
  114. * and is waiting to be activated. It is now in the
  115. * \link ctkPlugin::STARTING STARTING\endlink state and has a valid
  116. * <code>ctkPluginContext</code>. This
  117. * event is only delivered to synchronuous slots, which have been registered with
  118. * Qt::DirectConnection or Qt::BlockingQueuedConnection in ctkPluginContext::connectPluginListener().
  119. */
  120. LAZY_ACTIVATION
  121. };
  122. /**
  123. * Default constructor for use with the Qt meta object system.
  124. */
  125. ctkPluginEvent();
  126. ~ctkPluginEvent();
  127. /**
  128. * Can be used to check if this ctkPluginEvent instance is valid,
  129. * or if it has been constructed using the default constructor.
  130. *
  131. * @return <code>true</code> if this event object is valid,
  132. * <code>false</code> otherwise.
  133. */
  134. bool isNull() const;
  135. /**
  136. * Creates a plugin event of the specified type.
  137. *
  138. * @param type The event type.
  139. * @param plugin The plugin which had a lifecycle change.
  140. */
  141. ctkPluginEvent(Type type, ctkPlugin* plugin);
  142. ctkPluginEvent(const ctkPluginEvent& other);
  143. ctkPluginEvent& operator=(const ctkPluginEvent& other);
  144. /**
  145. * Returns the plugin which had a lifecycle change.
  146. *
  147. * @return The plugin that had a change occur in its lifecycle.
  148. */
  149. ctkPlugin* getPlugin() const;
  150. /**
  151. * Returns the type of lifecyle event. The type values are:
  152. * <ul>
  153. * <li>{@link #INSTALLED}
  154. * <li>{@link #RESOLVED}
  155. * <li>{@link #LAZY_ACTIVATION}
  156. * <li>{@link #STARTING}
  157. * <li>{@link #STARTED}
  158. * <li>{@link #STOPPING}
  159. * <li>{@link #STOPPED}
  160. * <li>{@link #UPDATED}
  161. * <li>{@link #UNRESOLVED}
  162. * <li>{@link #UNINSTALLED}
  163. * </ul>
  164. *
  165. * @return The type of lifecycle event.
  166. */
  167. Type getType() const;
  168. };
  169. #endif // CTKPLUGINEVENT_H