Mercurial > hg > orthanc
annotate OrthancCppClient/OrthancConnection.h @ 840:256e1530eb0f jpeg
fix build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Jun 2014 20:11:04 +0200 |
parents | 2d0a347e8cfc |
children | 6e7e5ed91c2d |
rev | line source |
---|---|
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
689 | 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Belgium |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * program give permission to link the code of its release with the |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * in the program, then also delete it here. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * General Public License for more details. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 **/ |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #pragma once |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "../Core/HttpClient.h" |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include "Patient.h" |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 namespace OrthancClient |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 { |
573 | 41 /** |
42 * {summary}{Connection to an instance of %Orthanc.} | |
593
9d2592c08919
documentation completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
573
diff
changeset
|
43 * {description}{This class encapsulates a connection to a remote instance |
573 | 44 * of %Orthanc through its REST API.} |
45 **/ | |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
480
diff
changeset
|
46 class LAAW_API OrthancConnection : |
480
482cde3f3c14
sample of c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
479
diff
changeset
|
47 public boost::noncopyable, |
482cde3f3c14
sample of c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
479
diff
changeset
|
48 private Orthanc::ArrayFilledByThreads::IFiller |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 private: |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 Orthanc::HttpClient client_; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 std::string orthancUrl_; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 Orthanc::ArrayFilledByThreads patients_; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 Json::Value content_; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 void ReadPatients(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 virtual size_t GetFillerSize() |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 return content_.size(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 virtual Orthanc::IDynamicObject* GetFillerItem(size_t index); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 public: |
573 | 66 /** |
67 * {summary}{Create a connection to an instance of %Orthanc.} | |
68 * {param}{orthancUrl URL to which the REST API of %Orthanc is listening.} | |
69 **/ | |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 OrthancConnection(const char* orthancUrl); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
573 | 72 /** |
73 * {summary}{Create a connection to an instance of %Orthanc, with authentication.} | |
74 * {param}{orthancUrl URL to which the REST API of %Orthanc is listening.} | |
75 * {param}{username The username.} | |
76 * {param}{password The password.} | |
77 **/ | |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 OrthancConnection(const char* orthancUrl, |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 const char* username, |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 const char* password); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
506
6e4bd06c17c5
the wrapper is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
500
diff
changeset
|
82 virtual ~OrthancConnection() |
6e4bd06c17c5
the wrapper is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
500
diff
changeset
|
83 { |
6e4bd06c17c5
the wrapper is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
500
diff
changeset
|
84 } |
6e4bd06c17c5
the wrapper is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
500
diff
changeset
|
85 |
573 | 86 /** |
87 * {summary}{Returns the number of threads for this connection.} | |
88 * {description}{Returns the number of simultaneous connections | |
89 * that are used when downloading information from this instance | |
90 * of %Orthanc.} | |
91 * {returns}{The number of threads.} | |
92 **/ | |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
480
diff
changeset
|
93 uint32_t GetThreadCount() const |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 return patients_.GetThreadCount(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
573 | 98 /** |
99 * {summary}{Sets the number of threads for this connection.} | |
100 * {description}{Sets the number of simultaneous connections | |
101 * that are used when downloading information from this instance | |
102 * of %Orthanc.} | |
103 * {param}{threadCount The number of threads.} | |
104 **/ | |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
480
diff
changeset
|
105 void SetThreadCount(uint32_t threadCount) |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 patients_.SetThreadCount(threadCount); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
573 | 110 /** |
593
9d2592c08919
documentation completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
573
diff
changeset
|
111 * {summary}{Reload the list of the patients.} |
573 | 112 * {description}{This method will reload the list of the patients from the remote instance of %Orthanc. Pay attention to the fact that the patients that have been previously returned by GetPatient() will be invalidated.} |
113 **/ | |
593
9d2592c08919
documentation completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
573
diff
changeset
|
114 void Reload() |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 { |
540 | 116 ReadPatients(); |
117 patients_.Invalidate(); | |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
500 | 120 LAAW_API_INTERNAL const Orthanc::HttpClient& GetHttpClient() const |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 return client_; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 |
573 | 125 /** |
126 * {summary}{Returns the URL of this instance of %Orthanc.} | |
127 * {description}{Returns the URL of the remote %Orthanc instance to which this object is connected.} | |
128 * {returns}{The URL.} | |
129 **/ | |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
480
diff
changeset
|
130 const char* GetOrthancUrl() const |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 { |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
480
diff
changeset
|
132 return orthancUrl_.c_str(); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 |
573 | 135 /** |
136 * {summary}{Returns the number of patients.} | |
137 * {description}{Returns the number of patients that are stored in the remote instance of %Orthanc.} | |
138 * {returns}{The number of patients.} | |
139 **/ | |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
480
diff
changeset
|
140 uint32_t GetPatientCount() |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 { |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 return patients_.GetSize(); |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 } |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
573 | 145 /** |
146 * {summary}{Get some patient.} | |
147 * {description}{This method will return an object that contains information about some patient. The patients are indexed by a number between 0 (inclusive) and the result of GetPatientCount() (exclusive).} | |
148 * {param}{index The index of the patient of interest.} | |
149 * {returns}{The patient.} | |
150 **/ | |
496
7f7a2d174acb
preparing Laaw packaging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
480
diff
changeset
|
151 Patient& GetPatient(uint32_t index); |
540 | 152 |
573 | 153 /** |
154 * {summary}{Delete some patient.} | |
155 * {description}{Delete some patient from the remote instance of %Orthanc. Pay attention to the fact that the patients that have been previously returned by GetPatient() will be invalidated.} | |
156 * {param}{index The index of the patient of interest.} | |
157 * {returns}{The patient.} | |
158 **/ | |
540 | 159 void DeletePatient(uint32_t index) |
160 { | |
161 GetPatient(index).Delete(); | |
593
9d2592c08919
documentation completed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
573
diff
changeset
|
162 Reload(); |
540 | 163 } |
164 | |
573 | 165 /** |
166 * {summary}{Send a DICOM file.} | |
167 * {description}{This method will store a DICOM file in the remote instance of %Orthanc. Pay attention to the fact that the patients that have been previously returned by GetPatient() will be invalidated.} | |
168 * {param}{filename Path to the DICOM file} | |
169 **/ | |
540 | 170 void StoreFile(const char* filename); |
171 | |
573 | 172 /** |
173 * {summary}{Send a DICOM file that is contained inside a memory buffer.} | |
174 * {description}{This method will store a DICOM file in the remote instance of %Orthanc. Pay attention to the fact that the patients that have been previously returned by GetPatient() will be invalidated.} | |
175 * {param}{dicom The memory buffer containing the DICOM file.} | |
176 * {param}{size The size of the DICOM file.} | |
177 **/ | |
540 | 178 void Store(const void* dicom, uint64_t size); |
479
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 }; |
0cd977e94479
initial commit of the c++ client
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 } |