annotate Framework/Toolbox/OrthancApiClient.h @ 271:46c5296d867e am-2

OracleWebService and BasicSdlApplicationContext using the same global mutex
author am@osimis.io
date Thu, 23 Aug 2018 17:12:54 +0200
parents 2d64f4d39610
children 3897f9f28cfa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
1 /**
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
6 *
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
11 *
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
16 *
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
19 **/
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
20
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
21
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
22 #pragma once
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
23
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
24 #include <boost/shared_ptr.hpp>
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
25 #include <json/json.h>
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
26
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
27 #include "IWebService.h"
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
28 #include "../Messages/IObservable.h"
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
29
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
30
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
31 namespace OrthancStone
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
32 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
33 class OrthancApiClient:
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
34 public IObservable
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
35 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
36 protected:
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
37 class BaseRequest;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
38 class GetJsonRequest;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
39
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
40 struct InternalGetJsonResponseReadyMessage;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
41 struct InternalGetJsonResponseErrorMessage;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
42
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
43 public:
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
44 struct GetJsonResponseReadyMessage : public IMessage
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
45 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
46 Json::Value response_;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
47 std::string uri_;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
48
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
49 GetJsonResponseReadyMessage(MessageType messageType,
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
50 const std::string& uri,
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
51 const Json::Value& response)
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
52 : IMessage(messageType),
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 270
diff changeset
53 response_(response),
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 270
diff changeset
54 uri_(uri)
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
55 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
56 }
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
57 };
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
58
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
59 public:
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
60
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
61 enum Mode
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
62 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
63 Mode_GetJson
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
64 };
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
65
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
66 protected:
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
67 IWebService& orthanc_;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
68 class WebCallback;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
69 boost::shared_ptr<WebCallback> webCallback_; // This is a PImpl pattern
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
70 std::set<BaseRequest*> requestsInProgress_;
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
71
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
72 // int ScheduleGetJsonRequest(const std::string& uri);
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
73
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
74 void ReleaseRequest(BaseRequest* request);
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
75
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
76 public:
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
77 OrthancApiClient(MessageBroker& broker,
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
78 IWebService& orthanc);
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
79 virtual ~OrthancApiClient() {}
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
80
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
81 // schedule a GET request expecting a JSON request.
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
82 // once the response is ready, it will emit a OrthancApiClient::GetJsonResponseReadyMessage message whose messageType is specified in the call
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
83 void ScheduleGetJsonRequest(IObserver& responseObserver, const std::string& uri, MessageType messageToEmitWhenResponseReady);
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
84
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
85 void ScheduleGetStudyIds(IObserver& responseObserver) {ScheduleGetJsonRequest(responseObserver, "/studies", MessageType_OrthancApi_GetStudyIds_Ready);}
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
86 void ScheduleGetStudy(IObserver& responseObserver, const std::string& studyId) {ScheduleGetJsonRequest(responseObserver, "/studies/" + studyId, MessageType_OrthancApi_GetStudy_Ready);}
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
87 void ScheduleGetSeries(IObserver& responseObserver, const std::string& seriesId) {ScheduleGetJsonRequest(responseObserver, "/series/" + seriesId, MessageType_OrthancApi_GetSeries_Ready);}
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
88
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
89 };
2d64f4d39610 backup (work in progress)
am@osimis.io
parents:
diff changeset
90 }