comparison Framework/Oracle/WebAssemblyOracle.h @ 1242:b9b5d4378874 broker

working of WebAssemblyOracle
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 06 Jan 2020 18:08:05 +0100
parents b9f2a111c5b9
children 608983cc2512
comparison
equal deleted inserted replaced
1241:a4bb8c2dd211 1242:b9b5d4378874
34 #include "GetOrthancWebViewerJpegCommand.h" 34 #include "GetOrthancWebViewerJpegCommand.h"
35 #include "HttpCommand.h" 35 #include "HttpCommand.h"
36 #include "IOracle.h" 36 #include "IOracle.h"
37 #include "OrthancRestApiCommand.h" 37 #include "OrthancRestApiCommand.h"
38 38
39 #include <Core/WebServiceParameters.h>
40
39 41
40 namespace OrthancStone 42 namespace OrthancStone
41 { 43 {
42 class WebAssemblyOracle : 44 class WebAssemblyOracle :
43 public IOracle, 45 public IOracle,
44 public IObservable,
45 public IMessageEmitter 46 public IMessageEmitter
46 { 47 {
47 private: 48 private:
48 typedef std::map<std::string, std::string> HttpHeaders; 49 typedef std::map<std::string, std::string> HttpHeaders;
49 50
50 class TimeoutContext; 51 class TimeoutContext;
51 class FetchContext; 52 class FetchContext;
52 class FetchCommand; 53 class FetchCommand;
54
55 void SetOrthancUrl(FetchCommand& command,
56 const std::string& uri) const;
53 57
54 void Execute(boost::weak_ptr<IObserver> receiver, 58 void Execute(boost::weak_ptr<IObserver> receiver,
55 HttpCommand* command); 59 HttpCommand* command);
56 60
57 void Execute(boost::weak_ptr<IObserver> receiver, 61 void Execute(boost::weak_ptr<IObserver> receiver,
61 GetOrthancImageCommand* command); 65 GetOrthancImageCommand* command);
62 66
63 void Execute(boost::weak_ptr<IObserver> receiver, 67 void Execute(boost::weak_ptr<IObserver> receiver,
64 GetOrthancWebViewerJpegCommand* command); 68 GetOrthancWebViewerJpegCommand* command);
65 69
66 IObservable oracleObservable_; 70 IObservable oracleObservable_;
67 std::string orthancRoot_; 71 bool isLocalOrthanc_;
72 std::string localOrthancRoot_;
73 Orthanc::WebServiceParameters remoteOrthanc_;
68 74
69 public: 75 public:
76 WebAssemblyOracle() :
77 isLocalOrthanc_(false)
78 {
79 }
80
70 virtual void EmitMessage(boost::weak_ptr<IObserver> observer, 81 virtual void EmitMessage(boost::weak_ptr<IObserver> observer,
71 const IMessage& message) ORTHANC_OVERRIDE 82 const IMessage& message) ORTHANC_OVERRIDE
72 { 83 {
73 oracleObservable_.EmitMessage(observer, message); 84 oracleObservable_.EmitMessage(observer, message);
74 } 85 }
79 IObservable& GetOracleObservable() 90 IObservable& GetOracleObservable()
80 { 91 {
81 return oracleObservable_; 92 return oracleObservable_;
82 } 93 }
83 94
84 void SetOrthancRoot(const std::string& root) 95 void SetLocalOrthanc(const std::string& root)
85 { 96 {
86 orthancRoot_ = root; 97 isLocalOrthanc_ = true;
98 localOrthancRoot_ = root;
99 }
100
101 void SetRemoteOrthanc(const Orthanc::WebServiceParameters& orthanc)
102 {
103 isLocalOrthanc_ = false;
104 remoteOrthanc_ = orthanc;
87 } 105 }
88 }; 106 };
89 } 107 }