ctkPluginFramework.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 CTKPLUGINFRAMEWORK_H
  16. #define CTKPLUGINFRAMEWORK_H
  17. #include "ctkPlugin.h"
  18. #include "CTKPluginFrameworkExport.h"
  19. namespace ctk {
  20. class PluginFrameworkContext;
  21. class PluginFrameworkPrivate;
  22. /**
  23. * A %PluginFramework instance. A %PluginFramework is also known as a System %Plugin.
  24. *
  25. * <p>
  26. * %PluginFramework instances are created using a PluginFrameworkFactory. The methods
  27. * of this class can be used to manage and control the created plugin framework
  28. * instance.
  29. *
  30. * @threadsafe
  31. */
  32. class CTK_PLUGINFW_EXPORT PluginFramework : public Plugin
  33. {
  34. Q_DECLARE_PRIVATE(PluginFramework)
  35. public:
  36. /**
  37. * Initialize this %PluginFramework. After calling this method, this %PluginFramework
  38. * must:
  39. * <ul>
  40. * <li>Be in the {@link #STARTING} state.</li>
  41. * <li>Have a valid Plugin Context.</li>
  42. * <li>Be at start level 0.</li>
  43. * <li>Have event handling enabled.</li>
  44. * <li>Have create Plugin objects for all installed plugins.</li>
  45. * <li>Have registered any framework services.</li>
  46. * </ul>
  47. *
  48. * <p>
  49. * This %PluginFramework will not actually be started until {@link #start() start}
  50. * is called.
  51. *
  52. * <p>
  53. * This method does nothing if called when this %PluginFramework is in the
  54. * {@link #STARTING}, {@link #ACTIVE} or {@link #STOPPING} states.
  55. *
  56. * @throws PluginException If this %PluginFramework could not be initialized.
  57. */
  58. void init();
  59. /**
  60. * Start this %PluginFramework.
  61. *
  62. * <p>
  63. * The following steps are taken to start this %PluginFramework:
  64. * <ol>
  65. * <li>If this %PluginFramework is not in the {@link #STARTING} state,
  66. * {@link #init() initialize} this %PluginFramework.</li>
  67. * <li>All installed plugins must be started in accordance with each
  68. * plugin's persistent <i>autostart setting</i>. This means some plugins
  69. * will not be started, some will be started with <i>lazy activation</i>
  70. * and some will be started with their <i>declared activation</i> policy.
  71. * Any exceptions that occur during plugin starting must be wrapped in a
  72. * {@link PluginException} and then published as a plugin framework event of type
  73. * {@link PluginFrameworkEvent::ERROR}</li>
  74. * <li>This %PluinFramework's state is set to {@link #ACTIVE}.</li>
  75. * <li>A plugin framework event of type {@link PluginFrameworkEvent::STARTED} is fired</li>
  76. * </ol>
  77. *
  78. * @param options Ignored. There are no start options for the %PluginFramework.
  79. * @throws PluginException If this %PluginFramework could not be started.
  80. */
  81. void start(const Plugin::StartOptions& options = 0);
  82. /**
  83. * @see Plugin::getHeaders()
  84. */
  85. QHash<QString, QString> getHeaders();
  86. /**
  87. * @see Plugin::getResourceList()
  88. */
  89. QStringList getResourceList(const QString& path) const;
  90. /**
  91. * @see Plugin::getResource()
  92. */
  93. QByteArray getResource(const QString& path) const;
  94. protected:
  95. friend class PluginFrameworkContext;
  96. PluginFramework(PluginFrameworkContext* fw);
  97. };
  98. }
  99. #endif // CTKPLUGINFRAMEWORK_H