ctkPluginFramework.h 3.8 KB

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