ctkPluginFrameworkContext_p.h 3.2 KB

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