ctkDicomAbstractExchangeCache.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. // CTK includes
  16. #include "ctkDicomAbstractExchangeCache.h"
  17. #include "ctkDicomAppHostingTypesHelper.h"
  18. #include "ctkDicomAvailableDataHelper.h"
  19. #include <ctkDicomObjectLocatorCache.h>
  20. class ctkDicomAbstractExchangeCachePrivate
  21. {
  22. public:
  23. ctkDicomAbstractExchangeCachePrivate();
  24. ~ctkDicomAbstractExchangeCachePrivate();
  25. ctkDicomObjectLocatorCache ObjectLocatorCache;
  26. ctkDicomAppHosting::AvailableData IncomingAvailableData;
  27. bool lastIncomingData ;
  28. };
  29. //----------------------------------------------------------------------------
  30. // ctkDicomAbstractExchangeCachePrivate methods
  31. //----------------------------------------------------------------------------
  32. ctkDicomAbstractExchangeCachePrivate::ctkDicomAbstractExchangeCachePrivate() : lastIncomingData(false)
  33. {
  34. }
  35. //----------------------------------------------------------------------------
  36. ctkDicomAbstractExchangeCachePrivate::~ctkDicomAbstractExchangeCachePrivate()
  37. {
  38. }
  39. //----------------------------------------------------------------------------
  40. // ctkDicomAbstractExchangeCache methods
  41. //----------------------------------------------------------------------------
  42. ctkDicomAbstractExchangeCache::ctkDicomAbstractExchangeCache() :
  43. d_ptr(new ctkDicomAbstractExchangeCachePrivate)
  44. {
  45. connect(this, SIGNAL(internalDataAvailable()), SIGNAL(dataAvailable()), Qt::QueuedConnection);
  46. }
  47. //----------------------------------------------------------------------------
  48. ctkDicomAbstractExchangeCache::~ctkDicomAbstractExchangeCache()
  49. {
  50. }
  51. //----------------------------------------------------------------------------
  52. QList<ctkDicomAppHosting::ObjectLocator> ctkDicomAbstractExchangeCache::getData(
  53. const QList<QUuid>& objectUUIDs,
  54. const QList<QString>& acceptableTransferSyntaxUIDs,
  55. bool includeBulkData)
  56. {
  57. Q_UNUSED(acceptableTransferSyntaxUIDs);
  58. Q_UNUSED(includeBulkData);
  59. return this->objectLocatorCache()->getData(objectUUIDs);
  60. }
  61. //----------------------------------------------------------------------------
  62. ctkDicomObjectLocatorCache* ctkDicomAbstractExchangeCache::objectLocatorCache() const
  63. {
  64. Q_D(const ctkDicomAbstractExchangeCache);
  65. return const_cast<ctkDicomObjectLocatorCache*>(&d->ObjectLocatorCache);
  66. }
  67. //----------------------------------------------------------------------------
  68. bool ctkDicomAbstractExchangeCache::publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData)
  69. {
  70. if (!this->objectLocatorCache()->isCached(availableData))
  71. {
  72. return false;
  73. }
  74. bool success = this->getOtherSideExchangeService()->notifyDataAvailable(availableData, lastData);
  75. if(!success)
  76. {
  77. return false;
  78. }
  79. return true;
  80. }
  81. //----------------------------------------------------------------------------
  82. void ctkDicomAbstractExchangeCache::releaseData(const QList<QUuid>& objectUUIDs)
  83. {
  84. Q_UNUSED(objectUUIDs)
  85. }
  86. //----------------------------------------------------------------------------
  87. const ctkDicomAppHosting::AvailableData& ctkDicomAbstractExchangeCache::getIncomingAvailableData() const
  88. {
  89. Q_D(const ctkDicomAbstractExchangeCache);
  90. return d->IncomingAvailableData;
  91. }
  92. //----------------------------------------------------------------------------
  93. bool ctkDicomAbstractExchangeCache::lastIncomingData() const
  94. {
  95. Q_D(const ctkDicomAbstractExchangeCache);
  96. return d->lastIncomingData;
  97. }
  98. //----------------------------------------------------------------------------
  99. bool ctkDicomAbstractExchangeCache::notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData)
  100. {
  101. Q_D(ctkDicomAbstractExchangeCache);
  102. ctkDicomAvailableDataHelper::appendToAvailableData(d->IncomingAvailableData, data);
  103. d->lastIncomingData = lastData;
  104. emit internalDataAvailable();
  105. return true;
  106. }
  107. //----------------------------------------------------------------------------
  108. void ctkDicomAbstractExchangeCache::cleanIncomingData()
  109. {
  110. Q_D(ctkDicomAbstractExchangeCache);
  111. d->IncomingAvailableData = ctkDicomAppHosting::AvailableData();
  112. d->lastIncomingData = false;
  113. }