Mercurial > hg > orthanc-stone
annotate Applications/StoneApplicationContext.cpp @ 1006:4f28d9459e31 toa2019092001
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 20 Sep 2019 12:13:10 +0200 |
parents | 4f2416d519b4 |
children | b537002f83a9 2d8ab34c8c91 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
288 | 22 #include "StoneApplicationContext.h" |
0 | 23 |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
24 #include <Core/OrthancException.h> |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
25 |
0 | 26 namespace OrthancStone |
27 { | |
418 | 28 void StoneApplicationContext::InitializeOrthanc() |
29 { | |
30 if (webService_ == NULL) | |
31 { | |
32 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
33 } | |
34 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
35 orthanc_.reset(new Deprecated::OrthancApiClient(broker_, *webService_, orthancBaseUrl_)); |
418 | 36 } |
37 | |
38 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
39 Deprecated::IWebService& StoneApplicationContext::GetWebService() |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
40 { |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
41 if (webService_ == NULL) |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
42 { |
418 | 43 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
44 } |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
45 |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
46 return *webService_; |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
47 } |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
48 |
418 | 49 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
50 Deprecated::OrthancApiClient& StoneApplicationContext::GetOrthancApiClient() |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
51 { |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
52 if (orthanc_.get() == NULL) |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
53 { |
418 | 54 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
55 } |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
56 |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
57 return *orthanc_; |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
58 } |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
59 |
418 | 60 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
61 void StoneApplicationContext::SetWebService(Deprecated::IWebService& webService) |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
62 { |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
63 webService_ = &webService; |
418 | 64 InitializeOrthanc(); |
65 } | |
66 | |
67 | |
68 void StoneApplicationContext::SetOrthancBaseUrl(const std::string& baseUrl) | |
69 { | |
70 // Make sure the base url ends with "/" | |
71 if (baseUrl.empty() || | |
72 baseUrl[baseUrl.size() - 1] != '/') | |
73 { | |
74 orthancBaseUrl_ = baseUrl + "/"; | |
75 } | |
76 else | |
77 { | |
78 orthancBaseUrl_ = baseUrl; | |
79 } | |
80 | |
81 if (webService_ != NULL) | |
82 { | |
83 InitializeOrthanc(); | |
84 } | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
85 } |
0 | 86 } |