ctkPluginStorage_p.h 4.1 KB

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