ctkPluginFrameworkContext_p.h 3.1 KB

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