Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Oracle/WebAssemblyOracle.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Oracle/WebAssemblyOracle.h@7f16987131e1 |
children | 37d90bd69f31 |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
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. | |
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 | |
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 | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "../OrthancStone.h" | |
25 | |
26 #if !defined(ORTHANC_ENABLE_WASM) | |
27 # error The macro ORTHANC_ENABLE_WASM must be defined | |
28 #endif | |
29 | |
30 #if ORTHANC_ENABLE_WASM != 1 | |
31 # error This file can only compiled for WebAssembly | |
32 #endif | |
33 | |
34 #include "../Messages/IObservable.h" | |
35 #include "../Messages/IMessageEmitter.h" | |
36 #include "IOracle.h" | |
37 | |
38 #if ORTHANC_ENABLE_DCMTK == 1 | |
39 # include "../Toolbox/ParsedDicomCache.h" | |
40 #endif | |
41 | |
42 #include <WebServiceParameters.h> | |
43 | |
44 #include <Enumerations.h> | |
45 | |
46 namespace OrthancStone | |
47 { | |
48 class GetOrthancImageCommand; | |
49 class GetOrthancWebViewerJpegCommand; | |
50 class HttpCommand; | |
51 class OrthancRestApiCommand; | |
52 class ParseDicomFromWadoCommand; | |
53 | |
54 class WebAssemblyOracle : | |
55 public IOracle, | |
56 public IMessageEmitter | |
57 { | |
58 private: | |
59 typedef std::map<std::string, std::string> HttpHeaders; | |
60 | |
61 class TimeoutContext; | |
62 class FetchContext; | |
63 class FetchCommand; | |
64 | |
65 void SetOrthancUrl(FetchCommand& command, | |
66 const std::string& uri) const; | |
67 | |
68 void Execute(boost::weak_ptr<IObserver> receiver, | |
69 HttpCommand* command); | |
70 | |
71 void Execute(boost::weak_ptr<IObserver> receiver, | |
72 OrthancRestApiCommand* command); | |
73 | |
74 void Execute(boost::weak_ptr<IObserver> receiver, | |
75 GetOrthancImageCommand* command); | |
76 | |
77 void Execute(boost::weak_ptr<IObserver> receiver, | |
78 GetOrthancWebViewerJpegCommand* command); | |
79 | |
80 void Execute(boost::weak_ptr<IObserver> receiver, | |
81 ParseDicomFromWadoCommand* command); | |
82 | |
83 IObservable oracleObservable_; | |
84 bool isLocalOrthanc_; | |
85 std::string localOrthancRoot_; | |
86 Orthanc::WebServiceParameters remoteOrthanc_; | |
87 | |
88 #if ORTHANC_ENABLE_DCMTK == 1 | |
89 std::unique_ptr<ParsedDicomCache> dicomCache_; | |
90 #endif | |
91 | |
92 public: | |
93 WebAssemblyOracle() : | |
94 isLocalOrthanc_(false) | |
95 { | |
96 } | |
97 | |
98 virtual void EmitMessage(boost::weak_ptr<IObserver> observer, | |
99 const IMessage& message) ORTHANC_OVERRIDE | |
100 { | |
101 oracleObservable_.EmitMessage(observer, message); | |
102 } | |
103 | |
104 virtual bool Schedule(boost::shared_ptr<IObserver> receiver, | |
105 IOracleCommand* command) ORTHANC_OVERRIDE; | |
106 | |
107 IObservable& GetOracleObservable() | |
108 { | |
109 return oracleObservable_; | |
110 } | |
111 | |
112 void SetLocalOrthanc(const std::string& root) | |
113 { | |
114 isLocalOrthanc_ = true; | |
115 localOrthancRoot_ = root; | |
116 } | |
117 | |
118 void SetRemoteOrthanc(const Orthanc::WebServiceParameters& orthanc) | |
119 { | |
120 isLocalOrthanc_ = false; | |
121 remoteOrthanc_ = orthanc; | |
122 } | |
123 | |
124 void SetDicomCacheSize(size_t size); | |
125 }; | |
126 } |