ctkDicomAbstractHost.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 CTKDICOMABSTRACTHOST_H
  16. #define CTKDICOMABSTRACTHOST_H
  17. #include <ctkDicomHostInterface.h>
  18. #include <ctkDicomAppInterface.h>
  19. #include <QScopedPointer>
  20. #include <org_commontk_dah_host_Export.h>
  21. class ctkDicomAbstractHostPrivate;
  22. class ctkDicomObjectLocatorCache;
  23. /**
  24. * @brief Provides a basic implementation for an application host.
  25. *
  26. * It starts a http server and serves one hosted application. Multiple instances
  27. * can be used for hosting multiple applications.
  28. *
  29. * The methods of the ctkDicomHostInterface have to be implemented for the business logic,
  30. *
  31. */
  32. class org_commontk_dah_host_EXPORT ctkDicomAbstractHost : public QObject, public ctkDicomHostInterface
  33. {
  34. Q_OBJECT
  35. Q_INTERFACES(ctkDicomHostInterface)
  36. public:
  37. /**
  38. * @brief Starts the soap server on the specified port or choose port automatically.
  39. *
  40. * @param hostPort
  41. * @param appPort
  42. */
  43. ctkDicomAbstractHost(int hostPort = 0, int appPort = 0);
  44. /**
  45. * @brief
  46. *
  47. */
  48. virtual ~ctkDicomAbstractHost();
  49. /**
  50. * @brief Gets the host port.
  51. *
  52. * @return int
  53. */
  54. int getHostPort() const;
  55. /**
  56. * @brief Gets the hosted application port.
  57. *
  58. * @return int
  59. */
  60. int getAppPort() const;
  61. /**
  62. * @brief Handles transitions form one state to the other.
  63. * When a new state notification arrives from the hosted app,
  64. * it goes through a state machine check and triggers signals depending on the appropriate response.
  65. *
  66. * The developer must connect to these signals to react to new state. The signal #stateChangedReceived is not to be used for this, it is just there for propagating new states for information only.
  67. *
  68. * @see appReady() releaseAvailableResources() startProgress() resumed() completed() suspended() canceled() exited() stateChangedReceived()
  69. * @param state
  70. */
  71. virtual void notifyStateChanged(ctkDicomAppHosting::State state);
  72. /**
  73. * @brief Gets the internal representation of the application state.
  74. * Does not call the client. For that purpose call ctkDicomAppInterface::getState() instead.
  75. *
  76. * @return ctkDicomAppHosting::State
  77. */
  78. ctkDicomAppHosting::State getApplicationState() const;
  79. /**
  80. * @brief Gets the application service in order to call methods on the hosted app.
  81. *
  82. * @return ctkDicomAppInterface *
  83. */
  84. ctkDicomAppInterface* getDicomAppService() const;
  85. /**
  86. * @brief Gets ctkDicomAppHosting::ObjectLocators from the hosted app.
  87. *
  88. * @param objectUUIDs
  89. * @param acceptableTransferSyntaxUIDs
  90. * @param includeBulkData
  91. * @return QList<ctkDicomAppHosting::ObjectLocator>
  92. */
  93. virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
  94. const QList<QUuid>& objectUUIDs,
  95. const QList<QString>& acceptableTransferSyntaxUIDs,
  96. bool includeBulkData);
  97. /**
  98. * @brief
  99. *
  100. * @return ctkDicomObjectLocatorCache *
  101. */
  102. ctkDicomObjectLocatorCache* objectLocatorCache() const;
  103. /**
  104. * @brief
  105. *
  106. * @param availableData
  107. * @param lastData
  108. * @return bool
  109. */
  110. bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
  111. Q_SIGNALS:
  112. /**
  113. * @brief Emitted when the ctkDicomAppHosting::IDLE state notification has been received, and the previous state was EXIT, IDLE or CANCELED.
  114. * @todo: perhaps also send this when completed. Needs discussion.
  115. *
  116. */
  117. void appReady();
  118. /**
  119. * @brief Emitted when the ctkDicomAppHosting::IDLE state notification has been received, and the previous state was COMPLETED.
  120. *
  121. */
  122. void releaseAvailableResources();
  123. /**
  124. * @brief Emitted when the ctkDicomAppHosting::INPROGRESS state notification has been received, and previous state IDLE.
  125. *
  126. */
  127. void startProgress();
  128. /**
  129. * @brief Emitted when the ctkDicomAppHosting::INPROGRESS state notification has been received, and previous state SUSPENDED.
  130. *
  131. */
  132. void resumed();
  133. /**
  134. * @brief Emitted when the ctkDicomAppHosting::COMPLETED state notification has been received.
  135. *
  136. */
  137. void completed();
  138. /**
  139. * @brief Emitted when the ctkDicomAppHosting::SUSPENDED state notification has been received.
  140. *
  141. */
  142. void suspended();
  143. /**
  144. * @brief Emitted when the ctkDicomAppHosting::CANCELED state notification has been received.
  145. *
  146. */
  147. void canceled();
  148. /**
  149. * @brief Emitted when the ctkDicomAppHosting::EXIT state notification has been received.
  150. *
  151. */
  152. void exited();
  153. /**
  154. * @brief Emitted after any new state has been received.
  155. * The event is sent after all the others have been sent through the state machine.
  156. *
  157. * @param state
  158. */
  159. void stateChangedReceived(ctkDicomAppHosting::State state);
  160. /**
  161. * @brief
  162. *
  163. * @param status
  164. */
  165. void statusReceived(const ctkDicomAppHosting::Status& status);
  166. private:
  167. Q_DECLARE_PRIVATE(ctkDicomAbstractHost)
  168. const QScopedPointer<ctkDicomAbstractHostPrivate> d_ptr; /**< TODO */
  169. };
  170. #endif // CTKDICOMABSTRACTHOST_H