comparison Sources/Autogenerated/sdk_OrthancPluginStorageArea.impl.h @ 1:fef9a239df5c

adding auto-generated files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Mar 2020 18:50:10 +0100
parents
children b2bbb516056e
comparison
equal deleted inserted replaced
0:7ed502b17b8f 1:fef9a239df5c
1 /**
2 * Python plugin for Orthanc
3 * Copyright (C) 2017-2020 Osimis S.A., Belgium
4 *
5 * This program is free software: you can redistribute it and/or
6 * modify it under the terms of the GNU Affero General Public License
7 * as published by the Free Software Foundation, either version 3 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 **/
18
19
20 typedef struct
21 {
22 PyObject_HEAD
23
24 /* Type-specific fields go here. */
25 OrthancPluginStorageArea* object_;
26 bool borrowed_;
27 } sdk_OrthancPluginStorageArea_Object;
28
29
30
31 // Forward declaration of the methods
32 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaCreate(
33 sdk_OrthancPluginStorageArea_Object* self, PyObject *args);
34 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRead(
35 sdk_OrthancPluginStorageArea_Object* self, PyObject *args);
36 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRemove(
37 sdk_OrthancPluginStorageArea_Object* self, PyObject *args);
38 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginReconstructMainDicomTags(
39 sdk_OrthancPluginStorageArea_Object* self, PyObject *args);
40
41
42 static PyMethodDef sdk_OrthancPluginStorageArea_Methods[] = {
43 { "StorageAreaCreate",
44 (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaCreate, METH_VARARGS,
45 "Generated from C function OrthancPluginStorageAreaCreate()" },
46 { "StorageAreaRead",
47 (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRead, METH_VARARGS,
48 "Generated from C function OrthancPluginStorageAreaRead()" },
49 { "StorageAreaRemove",
50 (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRemove, METH_VARARGS,
51 "Generated from C function OrthancPluginStorageAreaRemove()" },
52 { "ReconstructMainDicomTags",
53 (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginReconstructMainDicomTags, METH_VARARGS,
54 "Generated from C function OrthancPluginReconstructMainDicomTags()" },
55 { NULL } /* Sentinel */
56 };
57
58
59 static int sdk_OrthancPluginStorageArea_Constructor(
60 sdk_OrthancPluginStorageArea_Object *self, PyObject *args, PyObject *kwds)
61 {
62 OrthancPlugins::LogInfo("Creating Python object of class OrthancPluginStorageArea");
63
64 self->object_ = NULL;
65 self->borrowed_ = false;
66
67 long long object = 0;
68 unsigned char borrowed = false;
69
70 if (PyArg_ParseTuple(args, "Lb", &object, &borrowed))
71 {
72 self->object_ = reinterpret_cast<OrthancPluginStorageArea*>(static_cast<intptr_t>(object));
73 self->borrowed_ = borrowed;
74 return 0;
75 }
76 else
77 {
78 PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor");
79 return -1;
80 }
81 }
82
83
84 /**
85 * Static global structure => the fields that are beyond the last
86 * initialized field are set to zero.
87 * https://stackoverflow.com/a/11152199/881731
88 **/
89 static PyTypeObject sdk_OrthancPluginStorageArea_Type = {
90 PyVarObject_HEAD_INIT(NULL, 0)
91 "orthanc.StorageArea", /* tp_name */
92 sizeof(sdk_OrthancPluginStorageArea_Object), /* tp_basicsize */
93 };
94
95
96
97
98 // Actual implementation of the methods
99 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaCreate(
100 sdk_OrthancPluginStorageArea_Object* self, PyObject *args)
101 {
102 OrthancPlugins::LogInfo("Calling method OrthancPluginStorageAreaCreate() on object of class OrthancPluginStorageArea");
103
104 if (self->object_ == NULL)
105 {
106 // TODO: RAISE
107 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
108 PyErr_SetString(PyExc_ValueError, "Invalid object");
109 return NULL;
110 }
111
112 const char* arg0 = NULL;
113 Py_buffer arg1;
114 unsigned long long arg2 = 0;
115 long int arg3 = 0;
116
117 if (!PyArg_ParseTuple(args, "ss*Kl", &arg0, &arg1, &arg2, &arg3))
118 {
119 // TODO => RAISE : https://stackoverflow.com/questions/60832317
120 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (4 arguments expected)");
121 return NULL;
122 }
123 OrthancPluginErrorCode code = OrthancPluginStorageAreaCreate(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1.buf, arg2, static_cast<OrthancPluginContentType>(arg3));
124 PyBuffer_Release(&arg1);
125
126 if (code == OrthancPluginErrorCode_Success)
127 {
128 Py_INCREF(Py_None);
129 return Py_None;
130 }
131 else
132 {
133 // TODO => RAISE : https://stackoverflow.com/questions/60832317
134 //PythonLock::RaiseException(module, code);
135 PyErr_SetString(PyExc_ValueError, "Internal error");
136 return NULL;
137 }
138 }
139
140 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRead(
141 sdk_OrthancPluginStorageArea_Object* self, PyObject *args)
142 {
143 OrthancPlugins::LogInfo("Calling method OrthancPluginStorageAreaRead() on object of class OrthancPluginStorageArea");
144
145 if (self->object_ == NULL)
146 {
147 // TODO: RAISE
148 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
149 PyErr_SetString(PyExc_ValueError, "Invalid object");
150 return NULL;
151 }
152
153 const char* arg0 = NULL;
154 long int arg1 = 0;
155
156 if (!PyArg_ParseTuple(args, "sl", &arg0, &arg1))
157 {
158 // TODO => RAISE : https://stackoverflow.com/questions/60832317
159 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)");
160 return NULL;
161 }
162 OrthancPlugins::MemoryBuffer buffer;
163 OrthancPluginErrorCode code = OrthancPluginStorageAreaRead(OrthancPlugins::GetGlobalContext(), *buffer, self->object_, arg0, static_cast<OrthancPluginContentType>(arg1));
164
165 if (code == OrthancPluginErrorCode_Success)
166 {
167 return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize());
168 }
169 else
170 {
171 // TODO => RAISE : https://stackoverflow.com/questions/60832317
172 //PythonLock::RaiseException(module, OrthancPluginErrorCode_InternalError);
173 PyErr_SetString(PyExc_ValueError, "Internal error");
174 return NULL;
175 }
176 }
177
178 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRemove(
179 sdk_OrthancPluginStorageArea_Object* self, PyObject *args)
180 {
181 OrthancPlugins::LogInfo("Calling method OrthancPluginStorageAreaRemove() on object of class OrthancPluginStorageArea");
182
183 if (self->object_ == NULL)
184 {
185 // TODO: RAISE
186 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
187 PyErr_SetString(PyExc_ValueError, "Invalid object");
188 return NULL;
189 }
190
191 const char* arg0 = NULL;
192 long int arg1 = 0;
193
194 if (!PyArg_ParseTuple(args, "sl", &arg0, &arg1))
195 {
196 // TODO => RAISE : https://stackoverflow.com/questions/60832317
197 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)");
198 return NULL;
199 }
200 OrthancPluginErrorCode code = OrthancPluginStorageAreaRemove(OrthancPlugins::GetGlobalContext(), self->object_, arg0, static_cast<OrthancPluginContentType>(arg1));
201
202
203 if (code == OrthancPluginErrorCode_Success)
204 {
205 Py_INCREF(Py_None);
206 return Py_None;
207 }
208 else
209 {
210 // TODO => RAISE : https://stackoverflow.com/questions/60832317
211 //PythonLock::RaiseException(module, code);
212 PyErr_SetString(PyExc_ValueError, "Internal error");
213 return NULL;
214 }
215 }
216
217 static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginReconstructMainDicomTags(
218 sdk_OrthancPluginStorageArea_Object* self, PyObject *args)
219 {
220 OrthancPlugins::LogInfo("Calling method OrthancPluginReconstructMainDicomTags() on object of class OrthancPluginStorageArea");
221
222 if (self->object_ == NULL)
223 {
224 // TODO: RAISE
225 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
226 PyErr_SetString(PyExc_ValueError, "Invalid object");
227 return NULL;
228 }
229
230 long int arg0 = 0;
231
232 if (!PyArg_ParseTuple(args, "l", &arg0))
233 {
234 // TODO => RAISE : https://stackoverflow.com/questions/60832317
235 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)");
236 return NULL;
237 }
238 OrthancPluginErrorCode code = OrthancPluginReconstructMainDicomTags(OrthancPlugins::GetGlobalContext(), self->object_, static_cast<OrthancPluginResourceType>(arg0));
239
240
241 if (code == OrthancPluginErrorCode_Success)
242 {
243 Py_INCREF(Py_None);
244 return Py_None;
245 }
246 else
247 {
248 // TODO => RAISE : https://stackoverflow.com/questions/60832317
249 //PythonLock::RaiseException(module, code);
250 PyErr_SetString(PyExc_ValueError, "Internal error");
251 return NULL;
252 }
253 }
254
255
256
257 static void RegisterOrthancPluginStorageAreaClass(PyObject* module)
258 {
259 sdk_OrthancPluginStorageArea_Type.tp_new = PyType_GenericNew;
260 sdk_OrthancPluginStorageArea_Type.tp_flags = Py_TPFLAGS_DEFAULT;
261 sdk_OrthancPluginStorageArea_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginStorageArea";
262 sdk_OrthancPluginStorageArea_Type.tp_methods = sdk_OrthancPluginStorageArea_Methods;
263 sdk_OrthancPluginStorageArea_Type.tp_init = (initproc) sdk_OrthancPluginStorageArea_Constructor;
264
265
266 if (PyType_Ready(&sdk_OrthancPluginStorageArea_Type) < 0)
267 {
268 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginStorageArea");
269 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
270 }
271
272 Py_INCREF(&sdk_OrthancPluginStorageArea_Type);
273 if (PyModule_AddObject(module, "StorageArea", (PyObject *)&sdk_OrthancPluginStorageArea_Type) < 0)
274 {
275 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginStorageArea");
276 Py_DECREF(&sdk_OrthancPluginStorageArea_Type);
277 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
278 }
279 }
280
281
282 PyObject* GetOrthancPluginStorageAreaType()
283 {
284 return (PyObject*) &sdk_OrthancPluginStorageArea_Type;
285 }