ctkDICOMCoreTest1.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // Qt includes
  16. #include <QCoreApplication>
  17. #include <QTextStream>
  18. // ctkDICOMCore includes
  19. #include "ctkDICOMDatabase.h"
  20. // STD includes
  21. #include <iostream>
  22. #include <cstdlib>
  23. int ctkDICOMCoreTest1(int argc, char * argv []) {
  24. QCoreApplication app(argc, argv);
  25. QTextStream out(stdout);
  26. try
  27. {
  28. ctkDICOMDatabase myCTK( argv[1] );
  29. out << "open db success\n";
  30. /// make sure it is empty and properly initialized
  31. if (! myCTK.initializeDatabase() ) {
  32. out << "ERROR: basic DB init failed";
  33. return EXIT_FAILURE;
  34. };
  35. /// insert some sample data
  36. if (! myCTK.initializeDatabase(argv[2]) ) {
  37. out << "ERROR: sample DB init failed";
  38. return EXIT_FAILURE;
  39. };
  40. myCTK.closeDatabase();
  41. }
  42. catch (std::exception e)
  43. {
  44. out << "ERROR: " << e.what();
  45. return EXIT_FAILURE;
  46. }
  47. return EXIT_SUCCESS;
  48. }