ctkPluginStorage_p.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 CTKPLUGINSTORAGE_P_H
  16. #define CTKPLUGINSTORAGE_P_H
  17. #include <QList>
  18. #include <QStringList>
  19. #include "ctkPluginDatabase_p.h"
  20. // Qt class forward declarations
  21. class QIODevice;
  22. // CTK class forward declarations
  23. class ctkPluginArchive;
  24. class ctkPluginFrameworkContext;
  25. /**
  26. * \ingroup PluginFramework
  27. *
  28. * Storage of all plugin meta-data and resources
  29. */
  30. class ctkPluginStorage
  31. {
  32. private:
  33. QMutex archivesLock;
  34. /**
  35. * Plugin id sorted list of all active plugin archives.
  36. */
  37. QList<ctkPluginArchive*> archives;
  38. /**
  39. * Framework handle.
  40. */
  41. ctkPluginFrameworkContext* framework;
  42. /**
  43. * SQLite db caching plug-in metadata and resources
  44. */
  45. ctkPluginDatabase pluginDatabase;
  46. public:
  47. /**
  48. * Create a container for all plugin data in this framework.
  49. * Try to restore all saved plugin archive state.
  50. *
  51. */
  52. ctkPluginStorage(ctkPluginFrameworkContext* framework);
  53. /**
  54. * Return the framework context.
  55. */
  56. ctkPluginFrameworkContext* getFrameworkContext() const;
  57. /**
  58. * Insert a plugin (shared library) into the persistent storage
  59. *
  60. * @param location Location of the plugin.
  61. * @param localPath Path to the plugin on the local file system
  62. * @return Plugin archive object.
  63. */
  64. ctkPluginArchive* insertPlugin(const QUrl& location, const QString& localPath);
  65. /**
  66. * Insert a new plugin (shared library) into the persistent
  67. * storagedata as an update
  68. * to an existing plugin archive. To commit this data a call to
  69. * <code>replacePluginArchive</code> is needed.
  70. *
  71. * @param old ctkPluginArchive to be replaced.
  72. * @param localPath Path to a plugin on the local file system.
  73. * @return Plugin archive object.
  74. */
  75. ctkPluginArchive* updatePluginArchive(ctkPluginArchive* old, const QString& localPath);
  76. /**
  77. * Replace old plugin archive with a new updated plugin archive, that
  78. * was created with updatePluginArchive.
  79. *
  80. * @param oldPA ctkPluginArchive to be replaced.
  81. * @param newPA new ctkPluginArchive.
  82. */
  83. void replacePluginArchive(ctkPluginArchive* oldPA, ctkPluginArchive* newPA);
  84. /**
  85. * Persist the plugin start level.
  86. *
  87. * @param Plugin archive object
  88. */
  89. void setStartLevel(ctkPluginArchive* pa);
  90. /**
  91. * Persist the last modification (state change) time
  92. *
  93. * @param Plugin archive object
  94. */
  95. void setLastModified(ctkPluginArchive* pa);
  96. /**
  97. * Persist the auto start setting.
  98. *
  99. * @param Plugin archive object
  100. */
  101. void setAutostartSetting(ctkPluginArchive* pa);
  102. /**
  103. * Remove plugin archive from archives list and persistent storage.
  104. * The plugin archive is deleted and must not be used afterwards, if
  105. * this method returns \a true.
  106. *
  107. * @param pa Plugin archive to remove.
  108. * @return true if element was removed.
  109. */
  110. bool removeArchive(ctkPluginArchive* pa);
  111. /**
  112. * Get all plugin archive objects.
  113. *
  114. * @return QList of all PluginArchives.
  115. */
  116. QList<ctkPluginArchive*> getAllPluginArchives() const;
  117. /**
  118. * Get all plugins to start at next launch of framework.
  119. * This list is sorted in increasing plugin id order.
  120. *
  121. * @return A List with plugin locations.
  122. */
  123. QList<QString> getStartOnLaunchPlugins();
  124. QByteArray getPluginResource(long pluginId, const QString& res) const;
  125. QStringList findResourcesPath(long pluginId, const QString& path) const;
  126. /**
  127. * Close this plugin storage and all bundles in it.
  128. */
  129. void close();
  130. ~ctkPluginStorage();
  131. };
  132. #endif // CTKPLUGINSTORAGE_P_H