ctkPluginEvent.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 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. * @see ctkEventBus
  31. */
  32. class CTK_PLUGINFW_EXPORT ctkPluginEvent
  33. {
  34. QSharedDataPointer<ctkPluginEventData> d;
  35. public:
  36. enum Type {
  37. INSTALLED,
  38. STARTED,
  39. STOPPED,
  40. UPDATED,
  41. UNINSTALLED,
  42. RESOLVED,
  43. UNRESOLVED,
  44. STARTING,
  45. STOPPING,
  46. LAZY_ACTIVATION
  47. };
  48. /**
  49. * Default constructor for use with the Qt meta object system.
  50. */
  51. ctkPluginEvent();
  52. ~ctkPluginEvent();
  53. /**
  54. * Creates a plugin event of the specified type.
  55. *
  56. * @param type The event type.
  57. * @param plugin The plugin which had a lifecycle change.
  58. */
  59. ctkPluginEvent(Type type, ctkPlugin* plugin);
  60. ctkPluginEvent(const ctkPluginEvent& other);
  61. /**
  62. * Returns the plugin which had a lifecycle change.
  63. *
  64. * @return The plugin that had a change occur in its lifecycle.
  65. */
  66. ctkPlugin* getPlugin() const;
  67. /**
  68. * Returns the type of lifecyle event. The type values are:
  69. * <ul>
  70. * <li>{@link #INSTALLED}
  71. * <li>{@link #RESOLVED}
  72. * <li>{@link #LAZY_ACTIVATION}
  73. * <li>{@link #STARTING}
  74. * <li>{@link #STARTED}
  75. * <li>{@link #STOPPING}
  76. * <li>{@link #STOPPED}
  77. * <li>{@link #UPDATED}
  78. * <li>{@link #UNRESOLVED}
  79. * <li>{@link #UNINSTALLED}
  80. * </ul>
  81. *
  82. * @return The type of lifecycle event.
  83. */
  84. Type getType() const;
  85. };
  86. #endif // CTKPLUGINEVENT_H