Mercurial > hg > orthanc-stone
annotate Applications/StoneApplicationContext.cpp @ 427:3f9017db1738 am-vsol-upgrade-radiography-export
wip
author | am@osimis.io |
---|---|
date | Fri, 23 Nov 2018 16:06:23 +0100 |
parents | c23df8b3433b |
children | b70e9be013e4 |
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 | |
134
4cff7b1ed31d
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
51
diff
changeset
|
5 * Copyright (C) 2017-2018 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 | |
35 orthanc_.reset(new OrthancApiClient(broker_, *webService_, orthancBaseUrl_)); | |
36 } | |
37 | |
38 | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
39 IWebService& StoneApplicationContext::GetWebService() |
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 |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
50 OrthancApiClient& StoneApplicationContext::GetOrthancApiClient() |
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 |
61 void StoneApplicationContext::SetWebService(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 } |