ctkDICOMDatabase.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 <QSqlDatabase>
  19. #include "ctkDICOMCoreExport.h"
  20. class ctkDICOMDatabasePrivate;
  21. class DcmDataset;
  22. class CTK_DICOM_CORE_EXPORT ctkDICOMDatabase : public QObject
  23. {
  24. Q_OBJECT
  25. public:
  26. explicit ctkDICOMDatabase();
  27. explicit ctkDICOMDatabase(QString databaseFile);
  28. virtual ~ctkDICOMDatabase();
  29. const QSqlDatabase& database() const;
  30. const QString lastError() const;
  31. const QString databaseFilename() const;
  32. const QString databaseDirectory() const;
  33. ///
  34. /// open the SQLite database in @param file. If the file does not
  35. /// exist, a new database is created and initialized with the
  36. /// default schema
  37. virtual void openDatabase(const QString file);
  38. ///
  39. /// close the database. It must not be used afterwards.
  40. void closeDatabase();
  41. ///
  42. /// delete all data and reinitialize the database.
  43. bool initializeDatabase(const char* schemaFile = ":/dicom/dicom-schema.sql");
  44. /**
  45. * Will create an entry in the appropriate tables for this dataset.
  46. */
  47. void insert ( DcmDataset* dataset, QString filename );
  48. /**
  49. * Insert into the database if not already exsting.
  50. */
  51. void insert ( DcmDataset *dataset );
  52. protected:
  53. QScopedPointer<ctkDICOMDatabasePrivate> d_ptr;
  54. private:
  55. Q_DECLARE_PRIVATE(ctkDICOMDatabase);
  56. Q_DISABLE_COPY(ctkDICOMDatabase);
  57. };
  58. #endif