ctkDicomAbstractApp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 <ctkDicomAbstractExchangeCache.h>
  18. #include <ctkDicomAppInterface.h>
  19. #include <QScopedPointer>
  20. #include <org_commontk_dah_hostedapp_Export.h>
  21. class ctkDicomAbstractAppPrivate;
  22. struct ctkDicomHostInterface;
  23. class ctkPluginContext;
  24. class ctkDicomObjectLocatorCache;
  25. #ifdef _MSC_VER
  26. // disable inheritance by dominance warnings
  27. #pragma warning( disable : 4250 )
  28. #endif
  29. /**
  30. * @brief Provides a basic implementation for an application app.
  31. *
  32. * The methods of the ctkDicomAppInterface have to be implemented for the business logic.
  33. *
  34. * @todo Provide helper/convenience methods to ease application development.
  35. *
  36. *
  37. */
  38. class org_commontk_dah_hostedapp_EXPORT ctkDicomAbstractApp : public ctkDicomAbstractExchangeCache, public ctkDicomAppInterface
  39. {
  40. Q_OBJECT
  41. Q_INTERFACES(ctkDicomAppInterface)
  42. public:
  43. /**
  44. * @brief
  45. *
  46. * @param context
  47. */
  48. ctkDicomAbstractApp(ctkPluginContext* context);
  49. /**
  50. * @brief
  51. *
  52. */
  53. virtual ~ctkDicomAbstractApp();
  54. /**
  55. * @brief Method triggered by the host. Changes the state of the hosted application.
  56. *
  57. * Goes through the transitions and emits signals when relevant to trigger actions. Checks for the legality of a transition.
  58. *
  59. * @see startProgress() resumeProgress() suspendProgress() cancelProgress() exitHostedApp() releaseResources()
  60. * @param newState
  61. * @return bool true if state received and not illegal in the transition diagram from the reference, false if illegal or not recognized.
  62. */
  63. virtual bool setState(ctkDicomAppHosting::State newState);
  64. /**
  65. * @brief Sends the current state the app is in to the hosting system.
  66. *
  67. * @return ctkDicomAppHosting::State
  68. */
  69. virtual ctkDicomAppHosting::State getState();
  70. /**
  71. * @brief Gets a handle to the host, in order to call methods on it.
  72. *
  73. * @return ctkDicomHostInterface *
  74. */
  75. virtual ctkDicomHostInterface* getHostInterface() const;
  76. ctkDicomExchangeInterface* getOtherSideExchangeService() const;
  77. /**
  78. * @brief Sets the internal representation of the current state.
  79. *
  80. * @param state
  81. */
  82. void setInternalState(ctkDicomAppHosting::State state);
  83. Q_SIGNALS:
  84. /**
  85. * @brief ctkDicomAppHosting::INPROGRESS state received and legal.
  86. *
  87. * 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);
  88. *
  89. */
  90. void startProgress();
  91. /**
  92. * @brief ctkDicomAppHosting::INPROGRESS state received when the app is in the ctkDicomAppHosting::SUSPENDED state.
  93. *
  94. * Corresponding slot responsible for calling getHostInterface()->notifyStateChanged(ctkDicomAppHosting::INPROGRESS); when resumed.
  95. *
  96. */
  97. void resumeProgress();
  98. /**
  99. * @brief ctkDicomAppHosting::SUSPENDED state received.
  100. *
  101. * Corresponding slot responsible for calling getHostInterface()->notifyStateChanged(ctkDicomAppHosting::SUSPENDED); when resources have been released.
  102. *
  103. */
  104. void suspendProgress();
  105. /**
  106. * @brief ctkDicomAppHosting::CANCELED state received.
  107. *
  108. * The CANCELED state is particular because it leads to ctkDicomAppHosting::IDLE when the app has canceled the process.
  109. * Therefore the notification the app entered this CANCELED state is sent straight away by the setState method.
  110. *
  111. * The slot connected to this signal MUST NOT notify CANCELED, but MUST notify IDLE when the resources have been released.
  112. *
  113. */
  114. void cancelProgress();
  115. /**
  116. * @brief ctkDicomAppHosting::EXIT state received and legal.
  117. *
  118. * An EXIT notification is sent by setState, no communication with the hosting system is needed anymore.
  119. * A slot connected to this should stop the application process for good.
  120. *
  121. */
  122. void exitHostedApp();
  123. /**
  124. * @brief ctkDicomAppHosting::IDLE state received and legal.
  125. *
  126. * 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.
  127. *
  128. */
  129. void releaseResources();
  130. private:
  131. Q_DECLARE_PRIVATE(ctkDicomAbstractApp)
  132. const QScopedPointer<ctkDicomAbstractAppPrivate> d_ptr; /**< TODO */
  133. };
  134. #endif // CTKDICOMABSTRACTAPP_H