ctkDicomAbstractHost.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #include "ctkDicomAbstractHost.h"
  16. #include "ctkDicomHostServer.h"
  17. #include "ctkDicomAppService.h"
  18. class ctkDicomAbstractHostPrivate
  19. {
  20. public:
  21. ctkDicomAbstractHostPrivate(ctkDicomAbstractHost* hostInterface, int HostPort, int AppPort);
  22. ~ctkDicomAbstractHostPrivate();
  23. int HostPort;
  24. int AppPort;
  25. ctkDicomHostServer* Server;
  26. ctkDicomAppInterface* AppService;
  27. // ctkDicomAppHosting::Status
  28. };
  29. //----------------------------------------------------------------------------
  30. // ctkDicomAbstractHostPrivate methods
  31. //----------------------------------------------------------------------------
  32. ctkDicomAbstractHostPrivate::ctkDicomAbstractHostPrivate(
  33. ctkDicomAbstractHost* hostInterface, int hostPort, int appPort) : HostPort(hostPort), AppPort(appPort)
  34. {
  35. // start server
  36. if (this->HostPort==0)
  37. {
  38. this->HostPort = 8080;
  39. }
  40. if (this->AppPort==0)
  41. {
  42. this->AppPort = 8081;
  43. }
  44. this->Server = new ctkDicomHostServer(hostInterface,hostPort);
  45. this->AppService = new ctkDicomAppService(appPort, "/ApplicationInterface");
  46. }
  47. //----------------------------------------------------------------------------
  48. ctkDicomAbstractHostPrivate::~ctkDicomAbstractHostPrivate()
  49. {
  50. delete this->Server;
  51. this->Server = 0;
  52. //do not delete AppService, deleted somewhere else before?
  53. //delete this->AppService;
  54. //this->AppService = 0;
  55. }
  56. //----------------------------------------------------------------------------
  57. // ctkDicomAbstractHost methods
  58. //----------------------------------------------------------------------------
  59. ctkDicomAbstractHost::ctkDicomAbstractHost(int hostPort, int appPort) :
  60. d_ptr(new ctkDicomAbstractHostPrivate(this, hostPort, appPort))
  61. {
  62. }
  63. //----------------------------------------------------------------------------
  64. int ctkDicomAbstractHost::getHostPort() const
  65. {
  66. Q_D(const ctkDicomAbstractHost);
  67. return d->HostPort;
  68. }
  69. //----------------------------------------------------------------------------
  70. int ctkDicomAbstractHost::getAppPort() const
  71. {
  72. Q_D(const ctkDicomAbstractHost);
  73. return d->AppPort;
  74. }
  75. //----------------------------------------------------------------------------
  76. ctkDicomAbstractHost::~ctkDicomAbstractHost()
  77. {
  78. }
  79. //----------------------------------------------------------------------------
  80. ctkDicomAppInterface* ctkDicomAbstractHost::getDicomAppService() const
  81. {
  82. Q_D(const ctkDicomAbstractHost);
  83. return d->AppService;
  84. }