comparison Framework/Toolbox/OrthancWebService.cpp @ 58:468c48eaa01c wasm

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 May 2017 17:35:52 +0200
parents d20e25cfcf3a
children 288c948199e5
comparison
equal deleted inserted replaced
57:d20e25cfcf3a 58:468c48eaa01c
38 OrthancWebService::OrthancWebService(const Orthanc::WebServiceParameters& parameters) 38 OrthancWebService::OrthancWebService(const Orthanc::WebServiceParameters& parameters)
39 { 39 {
40 orthanc_.reset(new OrthancPlugins::OrthancHttpConnection(parameters)); 40 orthanc_.reset(new OrthancPlugins::OrthancHttpConnection(parameters));
41 } 41 }
42 42
43 void OrthancWebService::ScheduleGetRequest(IRequestObserver& observer, 43 void OrthancWebService::ScheduleGetRequest(ICallback& callback,
44 const std::string& uri, 44 const std::string& uri,
45 Orthanc::IDynamicObject* payload) 45 Orthanc::IDynamicObject* payload)
46 { 46 {
47 std::auto_ptr<Orthanc::IDynamicObject> tmp(payload); 47 std::auto_ptr<Orthanc::IDynamicObject> tmp(payload);
48 48
49 try 49 try
50 { 50 {
51 std::string answer; 51 std::string answer;
52 orthanc_->RestApiGet(answer, uri); 52 orthanc_->RestApiGet(answer, uri);
53 observer.NotifyAnswer(answer, tmp.release()); 53 callback.NotifyAnswer(uri, answer, tmp.release());
54 } 54 }
55 catch (Orthanc::OrthancException&) 55 catch (Orthanc::OrthancException&)
56 { 56 {
57 observer.NotifyError(tmp.release()); 57 callback.NotifyError(uri, tmp.release());
58 } 58 }
59 } 59 }
60 60
61 void OrthancWebService::SchedulePostRequest(IRequestObserver& observer, 61 void OrthancWebService::SchedulePostRequest(ICallback& callback,
62 const std::string& uri, 62 const std::string& uri,
63 const std::string& body, 63 const std::string& body,
64 Orthanc::IDynamicObject* payload) 64 Orthanc::IDynamicObject* payload)
65 { 65 {
66 std::auto_ptr<Orthanc::IDynamicObject> tmp(payload); 66 std::auto_ptr<Orthanc::IDynamicObject> tmp(payload);
67 67
68 try 68 try
69 { 69 {
70 std::string answer; 70 std::string answer;
71 orthanc_->RestApiPost(answer, uri, body); 71 orthanc_->RestApiPost(answer, uri, body);
72 observer.NotifyAnswer(answer, tmp.release()); 72 callback.NotifyAnswer(uri, answer, tmp.release());
73 } 73 }
74 catch (Orthanc::OrthancException&) 74 catch (Orthanc::OrthancException&)
75 { 75 {
76 observer.NotifyError(tmp.release()); 76 callback.NotifyError(uri, tmp.release());
77 } 77 }
78 } 78 }
79 } 79 }