ctkDicomAbstractApp.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 CTKDICOMABSTRACTAPP_H
  16. #define CTKDICOMABSTRACTAPP_H
  17. #include <ctkDicomAppInterface.h>
  18. #include <QScopedPointer>
  19. #include <org_commontk_dah_app_Export.h>
  20. class ctkDicomAbstractAppPrivate;
  21. struct ctkDicomHostInterface;
  22. class ctkPluginContext;
  23. class ctkDicomObjectLocatorCache;
  24. /**
  25. * @brief Provides a basic implementation for an application app.
  26. *
  27. * The methods of the ctkDicomAppInterface have to be implemented for the business logic.
  28. *
  29. * @todo Provide helper/convenience methods to ease application development.
  30. *
  31. *
  32. */
  33. class org_commontk_dah_app_EXPORT ctkDicomAbstractApp : public QObject, public ctkDicomAppInterface
  34. {
  35. Q_OBJECT
  36. Q_INTERFACES(ctkDicomAppInterface)
  37. public:
  38. /**
  39. * @brief
  40. *
  41. * @param context
  42. */
  43. ctkDicomAbstractApp(ctkPluginContext* context);
  44. /**
  45. * @brief
  46. *
  47. */
  48. virtual ~ctkDicomAbstractApp();
  49. /**
  50. * @brief Method triggered by the host. Changes the state of the hosted application.
  51. *
  52. * Goes through the transitions and emits signals when relevant to trigger actions. Checks for the legality of a transition.
  53. *
  54. * @see startProgress() resumeProgress() suspendProgress() cancelProgress() exitHostedApp() releaseResources()
  55. * @param newState
  56. * @return bool true if state received and not illegal in the transition diagram from the reference, false if illegal or not recognized.
  57. */
  58. virtual bool setState(ctkDicomAppHosting::State newState);
  59. /**
  60. * @brief Sends the current state the app is in to the hosting system.
  61. *
  62. * @return ctkDicomAppHosting::State
  63. */
  64. virtual ctkDicomAppHosting::State getState();
  65. /**
  66. * @brief Gets ctkDicomAppHosting::ObjectLocators from the hosting system.
  67. *
  68. * @param objectUUIDs
  69. * @param acceptableTransferSyntaxUIDs
  70. * @param includeBulkData
  71. * @return QList<ctkDicomAppHosting::ObjectLocator>
  72. */
  73. virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
  74. const QList<QUuid>& objectUUIDs,
  75. const QList<QString>& acceptableTransferSyntaxUIDs,
  76. bool includeBulkData);
  77. /**
  78. * @brief
  79. *
  80. * @return ctkDicomObjectLocatorCache *
  81. */
  82. ctkDicomObjectLocatorCache* objectLocatorCache()const;
  83. /**
  84. * @brief
  85. *
  86. * @param availableData
  87. * @param lastData
  88. * @return bool
  89. */
  90. bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
  91. protected:
  92. /**
  93. * @brief Gets a handle to the host, in order to call methods on it.
  94. *
  95. * @return ctkDicomHostInterface *
  96. */
  97. virtual ctkDicomHostInterface* getHostInterface() const;
  98. /**
  99. * @brief Sets the internal representation of the current state.
  100. *
  101. * @param state
  102. */
  103. void setInternalState(ctkDicomAppHosting::State state);
  104. signals:
  105. /**
  106. * @brief ctkDicomAppHosting::INPROGRESS state received and legal.
  107. *
  108. * the slot connected to this is responsible for notifying the hosting service that it is really in progress by a call to getHostInterface()->notifyStateChanged(ctkDicomAppHosting::INPROGRESS);
  109. *
  110. */
  111. void startProgress();
  112. /**
  113. * @brief ctkDicomAppHosting::INPROGRESS state received when the app is in the ctkDicomAppHosting::SUSPENDED state.
  114. *
  115. * Corresponding slot responsible for calling getHostInterface()->notifyStateChanged(ctkDicomAppHosting::INPROGRESS); when resumed.
  116. *
  117. */
  118. void resumeProgress();
  119. /**
  120. * @brief ctkDicomAppHosting::SUSPENDED state received.
  121. *
  122. * Corresponding slot responsible for calling getHostInterface()->notifyStateChanged(ctkDicomAppHosting::SUSPENDED); when resources have been released.
  123. *
  124. */
  125. void suspendProgress();
  126. /**
  127. * @brief ctkDicomAppHosting::CANCELED state received.
  128. *
  129. * The CANCELED state is particular because it leads to ctkDicomAppHosting::IDLE when the app has canceled the process.
  130. * Therefore the notification the app entered this CANCELED state is sent straight away by the setState method.
  131. *
  132. * The slot connected to this signal MUST NOT notify CANCELED, but MUST notify IDLE when the resources have been released.
  133. *
  134. */
  135. void cancelProgress();
  136. /**
  137. * @brief ctkDicomAppHosting::EXIT state received and legal.
  138. *
  139. * An EXIT notification is sent by setState, no communication with the hosting system is needed anymore.
  140. * A slot connected to this should stop the application process for good.
  141. *
  142. */
  143. void exitHostedApp();
  144. /**
  145. * @brief ctkDicomAppHosting::IDLE state received and legal.
  146. *
  147. * It means the current state was COMPLETED, and it is now time to release the resources, the hosting system doesn't need them any more.
  148. *
  149. */
  150. void releaseResources();
  151. private:
  152. Q_DECLARE_PRIVATE(ctkDicomAbstractApp)
  153. const QScopedPointer<ctkDicomAbstractAppPrivate> d_ptr; /**< TODO */
  154. };
  155. #endif // CTKDICOMABSTRACTAPP_H