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