ctkExampleDicomAppLogic_p.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 <ctkDicomAppInterface.h>
  19. #include <ctkDicomHostInterface.h>
  20. #include <stdexcept>
  21. template <class TServiceType>
  22. class ServiceAccessor {
  23. public:
  24. ServiceAccessor(ctkPluginContext* context, const QString& clazz) : context(context), clazz(clazz)
  25. {
  26. }
  27. TServiceType* operator->()
  28. {
  29. ctkServiceReference* serviceRef = context->getServiceReference(clazz);
  30. if (!serviceRef)
  31. {
  32. // this will change after merging changes from branch plugin_framework
  33. throw std::runtime_error("No Dicom Host Service found");
  34. }
  35. return qobject_cast<TServiceType*>(context->getService(serviceRef));
  36. }
  37. TServiceType* operator*()
  38. {
  39. return operator->();
  40. }
  41. private:
  42. ctkPluginContext* context;
  43. const QString clazz;
  44. };
  45. class ctkExampleDicomAppLogic :
  46. public ctkDicomAppInterface
  47. {
  48. Q_OBJECT
  49. public:
  50. ctkExampleDicomAppLogic(ServiceAccessor<ctkDicomHostInterface> host);
  51. ~ctkExampleDicomAppLogic();
  52. // ctkDicomAppInterface
  53. ctkDicomWG23::State getState();
  54. bool setState(ctkDicomWG23::State newState);
  55. bool bringToFront(const QRect& requestedScreenArea);
  56. // ctkDicomExchangeInterface
  57. bool notifyDataAvailable(ctkDicomWG23::AvailableData data, bool lastData);
  58. QList<ctkDicomWG23::ObjectLocator>* getData(
  59. QList<QUuid> objectUUIDs,
  60. QList<QString> acceptableTransferSyntaxUIDs,
  61. bool includeBulkData);
  62. void releaseData(QList<QUuid> objectUUIDs);
  63. // some logic
  64. void do_something();
  65. signals:
  66. void stateChanged(int);
  67. protected slots:
  68. void changeState(int);
  69. private:
  70. ServiceAccessor<ctkDicomHostInterface> host;
  71. }; // ctkExampleDicomAppLogic
  72. #endif // ctkExampleDicomAppLogic_P_H