ctkCmdLineModuleCache_p.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 CTKCMDLINEMODULECACHE_H
  16. #define CTKCMDLINEMODULECACHE_H
  17. #include <QScopedPointer>
  18. struct ctkCmdLineModuleCachePrivate;
  19. class QUrl;
  20. /**
  21. * \class ctkCmdLineModuleCache
  22. * \brief Private non-exported class to contain a cache of
  23. * XML descriptions and time-stamps.
  24. * \ingroup CommandLineModulesCore_API
  25. */
  26. class ctkCmdLineModuleCache
  27. {
  28. public:
  29. ctkCmdLineModuleCache(const QString& cacheDir);
  30. ~ctkCmdLineModuleCache();
  31. /**
  32. * @brief Returns the directory containing the cached information.
  33. * @return a directory path
  34. */
  35. QString cacheDir() const;
  36. /**
  37. * @brief Returns the cached XML associated with a module.
  38. * @param moduleLocation QUrl representing the location,
  39. * for example a file path for a local process.
  40. * @return QByteArray the XML
  41. */
  42. QByteArray rawXmlDescription(const QUrl& moduleLocation) const;
  43. /**
  44. * @brief Returns the time stamp associated with a module.
  45. * @param moduleLocation QUrl representing the location,
  46. * for example a file path for a local process.
  47. * @return time since epoch
  48. */
  49. qint64 timeStamp(const QUrl& moduleLocation) const;
  50. /**
  51. * @brief Adds a modules XML and timestamp to the cache.
  52. * @param moduleLocation QUrl representing the location,
  53. * for example a file path for a local process.
  54. * @param timestamp the time
  55. * @param xmlDescription the XML
  56. */
  57. void cacheXmlDescription(const QUrl& moduleLocation, qint64 timestamp, const QByteArray& xmlDescription);
  58. /**
  59. * @brief Removes an entry from the cache.
  60. * @param moduleLocation QUrl representing the location,
  61. * for example a file path for a local process.
  62. */
  63. void removeCacheEntry(const QUrl& moduleLocation);
  64. private:
  65. QScopedPointer<ctkCmdLineModuleCachePrivate> d;
  66. };
  67. #endif // CTKCMDLINEMODULECACHE_H