ctkPluginFrameworkContext_p.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 CTKPLUGINFRAMEWORKCONTEXT_P_H
  16. #define CTKPLUGINFRAMEWORKCONTEXT_P_H
  17. #include <QDebug>
  18. #include <QMutex>
  19. #include "ctkPluginFrameworkFactory.h"
  20. #include "ctkPluginFramework.h"
  21. #include "ctkPluginStorage_p.h"
  22. #include "ctkPlugins_p.h"
  23. #include "ctkPluginFrameworkListeners_p.h"
  24. #include "ctkPluginFrameworkDebug_p.h"
  25. class ctkPlugin;
  26. class ctkPluginStorage;
  27. class ctkServices;
  28. /**
  29. * \ingroup PluginFramework
  30. */
  31. class ctkPluginFrameworkContext
  32. {
  33. public:
  34. /**
  35. * All plugins in this framework.
  36. */
  37. ctkPlugins* plugins;
  38. /**
  39. * All listeners in this framework.
  40. */
  41. ctkPluginFrameworkListeners listeners;
  42. /**
  43. * All registered services in this framework.
  44. */
  45. ctkServices* services;
  46. /**
  47. * System plugin
  48. */
  49. QSharedPointer<ctkPluginFramework> systemPlugin;
  50. /**
  51. * ctkPlugin storage
  52. */
  53. ctkPluginStorage* storage;
  54. /**
  55. * Private Plugin data storage
  56. */
  57. QDir dataStorage;
  58. /**
  59. * First framework init
  60. */
  61. bool firstInit;
  62. /**
  63. * Framework id.
  64. */
  65. int id;
  66. /**
  67. * global lock.
  68. */
  69. static QMutex globalFwLock;
  70. /**
  71. * Id to use for next instance of plugin framework.
  72. */
  73. static int globalId;
  74. ctkProperties props;
  75. /**
  76. * Debug handle.
  77. */
  78. ctkPluginFrameworkDebug debug;
  79. /**
  80. * Contruct a framework context
  81. *
  82. */
  83. ctkPluginFrameworkContext(const ctkProperties& initProps);
  84. ~ctkPluginFrameworkContext();
  85. /**
  86. * Initialize the framework
  87. *
  88. */
  89. void init();
  90. /**
  91. * Undo as much as possible of what init() does.
  92. *
  93. */
  94. void uninit();
  95. /**
  96. *
  97. */
  98. int getId() const;
  99. /**
  100. * Get private plugin data storage file handle
  101. */
  102. QFileInfo getDataStorage(long id);
  103. /**
  104. * Check that the plugin belongs to this framework instance.
  105. *
  106. */
  107. void checkOurPlugin(ctkPlugin* plugin) const;
  108. /**
  109. * Check that the plugin specified can resolve all its
  110. * Require-ctkPlugin constraints.
  111. *
  112. * @param plugin ctkPlugin to check, must be in INSTALLED state
  113. *
  114. * @throws ctkPluginException
  115. */
  116. void resolvePlugin(ctkPluginPrivate* plugin);
  117. /**
  118. * Log message for debugging framework
  119. *
  120. */
  121. QDebug log() const;
  122. private:
  123. QSet<ctkPluginPrivate*> tempResolved;
  124. bool initialized;
  125. /**
  126. * Delete framework directory if it exists.
  127. *
  128. */
  129. void deleteFWDir();
  130. void checkRequirePlugin(ctkPluginPrivate* plugin);
  131. void initProperties();
  132. };
  133. #endif // CTKPLUGINFRAMEWORKCONTEXT_P_H