ctkDICOMDatabase.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkDICOMDatabase_h
  15. #define __ctkDICOMDatabase_h
  16. // Qt includes
  17. #include <QObject>
  18. #include <QStringList>
  19. #include <QSqlDatabase>
  20. #include "ctkDICOMCoreExport.h"
  21. class ctkDICOMDatabasePrivate;
  22. class DcmDataset;
  23. class CTK_DICOM_CORE_EXPORT ctkDICOMDatabase : public QObject
  24. {
  25. Q_OBJECT
  26. public:
  27. explicit ctkDICOMDatabase(QObject *parent = 0);
  28. explicit ctkDICOMDatabase(QString databaseFile);
  29. virtual ~ctkDICOMDatabase();
  30. const QSqlDatabase& database() const;
  31. const QString lastError() const;
  32. const QString databaseFilename() const;
  33. const QString databaseDirectory() const;
  34. bool isInMemory() const;
  35. ///
  36. /// open the SQLite database in @param databaseFile . If the file does not
  37. /// exist, a new database is created and initialized with the
  38. /// default schema
  39. ///
  40. /// @param databaseFile TODO
  41. /// @param connectionName TODO
  42. Q_INVOKABLE virtual void openDatabase(const QString databaseFile, const QString& connectionName = "DICOM-DB" );
  43. ///
  44. /// close the database. It must not be used afterwards.
  45. Q_INVOKABLE void closeDatabase();
  46. ///
  47. /// delete all data and reinitialize the database.
  48. Q_INVOKABLE bool initializeDatabase(const char* schemaFile = ":/dicom/dicom-schema.sql");
  49. ///
  50. /// \brief database accessors
  51. Q_INVOKABLE QStringList studiesForPatient (QString patientUID);
  52. Q_INVOKABLE QStringList seriesForStudy (QString studyUID);
  53. Q_INVOKABLE QStringList filesForSeries (QString seriesUID);
  54. ///
  55. /// \brief load the header from a file and allow access to elements
  56. Q_INVOKABLE void loadInstanceHeader (QString sopInstanceUID);
  57. Q_INVOKABLE void loadFileHeader (QString fileName);
  58. Q_INVOKABLE QStringList headerKeys ();
  59. Q_INVOKABLE QString headerValue (QString key);
  60. /**
  61. * Will create an entry in the appropriate tables for this dataset.
  62. */
  63. // void insert ( DcmDataset* dataset, QString filename );
  64. /**
  65. * Insert into the database if not already exsting.
  66. */
  67. void insert ( DcmDataset *dataset, bool storeFile = true);
  68. /***
  69. * Helper method: get the path that should be used to store this image.
  70. */
  71. QString pathForDataset( DcmDataset *dataset);
  72. signals:
  73. void databaseChanged();
  74. protected:
  75. QScopedPointer<ctkDICOMDatabasePrivate> d_ptr;
  76. private:
  77. Q_DECLARE_PRIVATE(ctkDICOMDatabase);
  78. Q_DISABLE_COPY(ctkDICOMDatabase);
  79. };
  80. #endif