comparison Sources/Autogenerated/sdk_OrthancPluginPeers.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 OrthancPluginPeers* object_;
26 bool borrowed_;
27 } sdk_OrthancPluginPeers_Object;
28
29
30
31 // Forward declaration of the methods
32 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeersCount(
33 sdk_OrthancPluginPeers_Object* self, PyObject *args);
34 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerName(
35 sdk_OrthancPluginPeers_Object* self, PyObject *args);
36 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUrl(
37 sdk_OrthancPluginPeers_Object* self, PyObject *args);
38 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUserProperty(
39 sdk_OrthancPluginPeers_Object* self, PyObject *args);
40
41
42 static PyMethodDef sdk_OrthancPluginPeers_Methods[] = {
43 { "GetPeersCount",
44 (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeersCount, METH_VARARGS,
45 "Generated from C function OrthancPluginGetPeersCount()" },
46 { "GetPeerName",
47 (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeerName, METH_VARARGS,
48 "Generated from C function OrthancPluginGetPeerName()" },
49 { "GetPeerUrl",
50 (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeerUrl, METH_VARARGS,
51 "Generated from C function OrthancPluginGetPeerUrl()" },
52 { "GetPeerUserProperty",
53 (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeerUserProperty, METH_VARARGS,
54 "Generated from C function OrthancPluginGetPeerUserProperty()" },
55 { NULL } /* Sentinel */
56 };
57
58
59 static int sdk_OrthancPluginPeers_Constructor(
60 sdk_OrthancPluginPeers_Object *self, PyObject *args, PyObject *kwds)
61 {
62 OrthancPlugins::LogInfo("Creating Python object of class OrthancPluginPeers");
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<OrthancPluginPeers*>(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_OrthancPluginPeers_Type = {
90 PyVarObject_HEAD_INIT(NULL, 0)
91 "orthanc.Peers", /* tp_name */
92 sizeof(sdk_OrthancPluginPeers_Object), /* tp_basicsize */
93 };
94
95
96 static void sdk_OrthancPluginPeers_Destructor(PyObject *self)
97 {
98 OrthancPlugins::LogInfo("Destroying Python object of class OrthancPluginPeers");
99
100 sdk_OrthancPluginPeers_Object& tmp = *((sdk_OrthancPluginPeers_Object*) self);
101
102 if (tmp.object_ != NULL &&
103 !tmp.borrowed_)
104 {
105 OrthancPluginFreePeers(OrthancPlugins::GetGlobalContext(), tmp.object_);
106 tmp.object_ = NULL;
107 }
108
109 Py_TYPE(self)->tp_free((PyObject *)self);
110 }
111
112
113 // Actual implementation of the methods
114 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeersCount(
115 sdk_OrthancPluginPeers_Object* self, PyObject *args)
116 {
117 OrthancPlugins::LogInfo("Calling method OrthancPluginGetPeersCount() on object of class OrthancPluginPeers");
118
119 if (self->object_ == NULL)
120 {
121 // TODO: RAISE
122 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
123 PyErr_SetString(PyExc_ValueError, "Invalid object");
124 return NULL;
125 }
126
127
128 long value = OrthancPluginGetPeersCount(OrthancPlugins::GetGlobalContext(), self->object_);
129
130 return PyLong_FromLong(value);
131 }
132
133 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerName(
134 sdk_OrthancPluginPeers_Object* self, PyObject *args)
135 {
136 OrthancPlugins::LogInfo("Calling method OrthancPluginGetPeerName() on object of class OrthancPluginPeers");
137
138 if (self->object_ == NULL)
139 {
140 // TODO: RAISE
141 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
142 PyErr_SetString(PyExc_ValueError, "Invalid object");
143 return NULL;
144 }
145
146 unsigned long arg0 = 0;
147
148 if (!PyArg_ParseTuple(args, "k", &arg0))
149 {
150 // TODO => RAISE : https://stackoverflow.com/questions/60832317
151 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)");
152 return NULL;
153 }
154 const char* s = OrthancPluginGetPeerName(OrthancPlugins::GetGlobalContext(), self->object_, arg0);
155
156 if (s == NULL)
157 {
158 Py_INCREF(Py_None);
159 return Py_None;
160 }
161 else
162 {
163 return PyUnicode_FromString(s);
164 }
165 }
166
167 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUrl(
168 sdk_OrthancPluginPeers_Object* self, PyObject *args)
169 {
170 OrthancPlugins::LogInfo("Calling method OrthancPluginGetPeerUrl() on object of class OrthancPluginPeers");
171
172 if (self->object_ == NULL)
173 {
174 // TODO: RAISE
175 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
176 PyErr_SetString(PyExc_ValueError, "Invalid object");
177 return NULL;
178 }
179
180 unsigned long arg0 = 0;
181
182 if (!PyArg_ParseTuple(args, "k", &arg0))
183 {
184 // TODO => RAISE : https://stackoverflow.com/questions/60832317
185 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)");
186 return NULL;
187 }
188 const char* s = OrthancPluginGetPeerUrl(OrthancPlugins::GetGlobalContext(), self->object_, arg0);
189
190 if (s == NULL)
191 {
192 Py_INCREF(Py_None);
193 return Py_None;
194 }
195 else
196 {
197 return PyUnicode_FromString(s);
198 }
199 }
200
201 static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUserProperty(
202 sdk_OrthancPluginPeers_Object* self, PyObject *args)
203 {
204 OrthancPlugins::LogInfo("Calling method OrthancPluginGetPeerUserProperty() on object of class OrthancPluginPeers");
205
206 if (self->object_ == NULL)
207 {
208 // TODO: RAISE
209 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
210 PyErr_SetString(PyExc_ValueError, "Invalid object");
211 return NULL;
212 }
213
214 unsigned long arg0 = 0;
215 const char* arg1 = NULL;
216
217 if (!PyArg_ParseTuple(args, "ks", &arg0, &arg1))
218 {
219 // TODO => RAISE : https://stackoverflow.com/questions/60832317
220 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)");
221 return NULL;
222 }
223 const char* s = OrthancPluginGetPeerUserProperty(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1);
224
225 if (s == NULL)
226 {
227 Py_INCREF(Py_None);
228 return Py_None;
229 }
230 else
231 {
232 return PyUnicode_FromString(s);
233 }
234 }
235
236
237
238 static void RegisterOrthancPluginPeersClass(PyObject* module)
239 {
240 sdk_OrthancPluginPeers_Type.tp_new = PyType_GenericNew;
241 sdk_OrthancPluginPeers_Type.tp_flags = Py_TPFLAGS_DEFAULT;
242 sdk_OrthancPluginPeers_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginPeers";
243 sdk_OrthancPluginPeers_Type.tp_methods = sdk_OrthancPluginPeers_Methods;
244 sdk_OrthancPluginPeers_Type.tp_init = (initproc) sdk_OrthancPluginPeers_Constructor;
245
246 /**
247 * "tp_dealloc is called when the reference count of the object goes
248 * down to zero. This is where you destroy the object and its
249 * members. It should then free the memory occupied by the object by
250 * calling tp_free."
251 * https://stackoverflow.com/a/24863227/881731
252 **/
253 sdk_OrthancPluginPeers_Type.tp_dealloc = sdk_OrthancPluginPeers_Destructor;
254
255 if (PyType_Ready(&sdk_OrthancPluginPeers_Type) < 0)
256 {
257 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginPeers");
258 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
259 }
260
261 Py_INCREF(&sdk_OrthancPluginPeers_Type);
262 if (PyModule_AddObject(module, "Peers", (PyObject *)&sdk_OrthancPluginPeers_Type) < 0)
263 {
264 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginPeers");
265 Py_DECREF(&sdk_OrthancPluginPeers_Type);
266 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
267 }
268 }
269
270
271 PyObject* GetOrthancPluginPeersType()
272 {
273 return (PyObject*) &sdk_OrthancPluginPeers_Type;
274 }