ctkExampleDicomAppLogic_p.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 CTKEXAMPLEDICOMAPPLOGIC_P_H
  16. #define CTKEXAMPLEDICOMAPPLOGIC_P_H
  17. #include <ctkPluginActivator.h>
  18. #include <ctkServiceReference.h>
  19. #include <ctkDicomAppInterface.h>
  20. #include <ctkDicomHostInterface.h>
  21. #include <stdexcept>
  22. template <class TServiceType>
  23. class ServiceAccessor {
  24. public:
  25. ServiceAccessor(ctkPluginContext* context, const QString& clazz) : context(context), clazz(clazz)
  26. {
  27. }
  28. TServiceType* operator->()
  29. {
  30. ctkServiceReference serviceRef = context->getServiceReference(clazz);
  31. return qobject_cast<TServiceType*>(context->getService(serviceRef));
  32. }
  33. TServiceType* operator*()
  34. {
  35. return operator->();
  36. }
  37. private:
  38. ctkPluginContext* context;
  39. const QString clazz;
  40. };
  41. class ctkExampleDicomAppLogic :
  42. public ctkDicomAppInterface
  43. {
  44. Q_OBJECT
  45. public:
  46. ctkExampleDicomAppLogic(ServiceAccessor<ctkDicomHostInterface> host);
  47. ~ctkExampleDicomAppLogic();
  48. // ctkDicomAppInterface
  49. ctkDicomAppHosting::State getState();
  50. bool setState(ctkDicomAppHosting::State newState);
  51. bool bringToFront(const QRect& requestedScreenArea);
  52. // ctkDicomExchangeInterface
  53. bool notifyDataAvailable(ctkDicomAppHosting::AvailableData data, bool lastData);
  54. QList<ctkDicomAppHosting::ObjectLocator> getData(
  55. QList<QUuid> objectUUIDs,
  56. QList<QString> acceptableTransferSyntaxUIDs,
  57. bool includeBulkData);
  58. void releaseData(QList<QUuid> objectUUIDs);
  59. // some logic
  60. void do_something();
  61. signals:
  62. void stateChanged(int);
  63. protected slots:
  64. void changeState(int);
  65. private:
  66. ServiceAccessor<ctkDicomHostInterface> host;
  67. }; // ctkExampleDicomAppLogic
  68. #endif // ctkExampleDicomAppLogic_P_H