ctkPluginFramework_p.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 CTKPLUGINFRAMEWORKPRIVATE_P_H
  16. #define CTKPLUGINFRAMEWORKPRIVATE_P_H
  17. #include <QMutex>
  18. #include "ctkPlugin_p.h"
  19. #include "ctkPluginFramework.h"
  20. class ctkPluginFrameworkContext;
  21. /**
  22. * \ingroup PluginFramework
  23. */
  24. class ctkPluginFrameworkPrivate : public ctkPluginPrivate
  25. {
  26. public:
  27. /**
  28. * Holds all information for constructing a ctkPluginFrameworkEvent instance,
  29. * except for holding a QSharedPointer to the framework plug-in. This avoids
  30. * cyclic references in ctkPluginFramework.
  31. */
  32. struct FWEventWrapper
  33. {
  34. FWEventWrapper() : isNull(true) {}
  35. bool isNull;
  36. ctkPluginFrameworkEvent::Type type;
  37. };
  38. /**
  39. * The event to return to callers waiting in ctkPluginFramework::waitForStop()
  40. * when the framework has been stopped.
  41. */
  42. FWEventWrapper stopEvent;
  43. /**
  44. * The flag indicating that the thread that performs shutdown of this
  45. * framework instance is running.
  46. */
  47. QAtomicInt shuttingDown;
  48. /**
  49. * Lock object
  50. */
  51. LockObject lock;
  52. ctkPluginFrameworkPrivate(QWeakPointer<ctkPlugin> qq, ctkPluginFrameworkContext* fw);
  53. void init();
  54. void initSystemPlugin();
  55. void uninitSystemPlugin();
  56. /**
  57. * This method starts a thread that stops this Framework,
  58. * stopping all started plug-ins.
  59. *
  60. * <p>If the framework is not started, this method does nothing.
  61. * If the framework is started, this method will:
  62. * <ol>
  63. * <li>Set the state of the ctkPluginFrameworkContext to <i>inactive</i>.</li>
  64. * <li>Suspended all started plug-ins as described in the
  65. * {@link ctkPlugin#stop()} method except that the persistent
  66. * state of the plug-in will continue to be started.
  67. * Reports any exceptions that occur during stopping using
  68. * <code>ctkPluginFramework</code>s.</li>
  69. * <li>Disable event handling.</li>
  70. * </ol></p>
  71. *
  72. */
  73. void shutdown(bool restart);
  74. QHash<QString, QString> systemHeaders;
  75. private:
  76. /**
  77. * Stop this FrameworkContext, suspending all started contexts.
  78. * This method suspends all started contexts so that they can be
  79. * automatically restarted when this FrameworkContext is next launched.
  80. *
  81. * <p>If the framework is not started, this method does nothing.
  82. * If the framework is started, this method will:
  83. * <ol>
  84. * <li>Set the state of the FrameworkContext to <i>inactive</i>.</li>
  85. * <li>Stop all started bundles as described in the
  86. * {@link Bundle#stop(int)} method except that the persistent
  87. * state of the bundle will continue to be started.
  88. * Reports any exceptions that occur during stopping using
  89. * <code>FrameworkErrorEvents</code>.</li>
  90. * <li>Disable event handling.</li>
  91. * </ol>
  92. * </p>
  93. *
  94. */
  95. void shutdown0(bool restart, bool wasActive);
  96. /**
  97. * Tell system plugin shutdown finished.
  98. */
  99. void shutdownDone_unlocked(bool restart);
  100. /**
  101. * Stop and unresolve all plug-ins.
  102. */
  103. void stopAllPlugins();
  104. /**
  105. * Shutting down is done.
  106. */
  107. void systemShuttingdownDone(const ctkPluginFrameworkEvent& fe);
  108. void systemShuttingdownDone_unlocked(const ctkPluginFrameworkEvent& fe);
  109. };
  110. #endif // CTKPLUGINFRAMEWORKPRIVATE_P_H