Mercurial > hg > orthanc-python
comparison Sources/Autogenerated/sdk_OrthancPluginFindQuery.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 OrthancPluginFindQuery* object_; | |
26 bool borrowed_; | |
27 } sdk_OrthancPluginFindQuery_Object; | |
28 | |
29 | |
30 | |
31 // Forward declaration of the methods | |
32 static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQuerySize( | |
33 sdk_OrthancPluginFindQuery_Object* self, PyObject *args); | |
34 static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryTagName( | |
35 sdk_OrthancPluginFindQuery_Object* self, PyObject *args); | |
36 static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryValue( | |
37 sdk_OrthancPluginFindQuery_Object* self, PyObject *args); | |
38 | |
39 | |
40 static PyMethodDef sdk_OrthancPluginFindQuery_Methods[] = { | |
41 { "GetFindQuerySize", | |
42 (PyCFunction) sdk_OrthancPluginFindQuery_OrthancPluginGetFindQuerySize, METH_VARARGS, | |
43 "Generated from C function OrthancPluginGetFindQuerySize()" }, | |
44 { "GetFindQueryTagName", | |
45 (PyCFunction) sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryTagName, METH_VARARGS, | |
46 "Generated from C function OrthancPluginGetFindQueryTagName()" }, | |
47 { "GetFindQueryValue", | |
48 (PyCFunction) sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryValue, METH_VARARGS, | |
49 "Generated from C function OrthancPluginGetFindQueryValue()" }, | |
50 { NULL } /* Sentinel */ | |
51 }; | |
52 | |
53 | |
54 static int sdk_OrthancPluginFindQuery_Constructor( | |
55 sdk_OrthancPluginFindQuery_Object *self, PyObject *args, PyObject *kwds) | |
56 { | |
57 OrthancPlugins::LogInfo("Creating Python object of class OrthancPluginFindQuery"); | |
58 | |
59 self->object_ = NULL; | |
60 self->borrowed_ = false; | |
61 | |
62 long long object = 0; | |
63 unsigned char borrowed = false; | |
64 | |
65 if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) | |
66 { | |
67 self->object_ = reinterpret_cast<OrthancPluginFindQuery*>(static_cast<intptr_t>(object)); | |
68 self->borrowed_ = borrowed; | |
69 return 0; | |
70 } | |
71 else | |
72 { | |
73 PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); | |
74 return -1; | |
75 } | |
76 } | |
77 | |
78 | |
79 /** | |
80 * Static global structure => the fields that are beyond the last | |
81 * initialized field are set to zero. | |
82 * https://stackoverflow.com/a/11152199/881731 | |
83 **/ | |
84 static PyTypeObject sdk_OrthancPluginFindQuery_Type = { | |
85 PyVarObject_HEAD_INIT(NULL, 0) | |
86 "orthanc.FindQuery", /* tp_name */ | |
87 sizeof(sdk_OrthancPluginFindQuery_Object), /* tp_basicsize */ | |
88 }; | |
89 | |
90 | |
91 | |
92 | |
93 // Actual implementation of the methods | |
94 static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQuerySize( | |
95 sdk_OrthancPluginFindQuery_Object* self, PyObject *args) | |
96 { | |
97 OrthancPlugins::LogInfo("Calling method OrthancPluginGetFindQuerySize() on object of class OrthancPluginFindQuery"); | |
98 | |
99 if (self->object_ == NULL) | |
100 { | |
101 // TODO: RAISE | |
102 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer); | |
103 PyErr_SetString(PyExc_ValueError, "Invalid object"); | |
104 return NULL; | |
105 } | |
106 | |
107 | |
108 long value = OrthancPluginGetFindQuerySize(OrthancPlugins::GetGlobalContext(), self->object_); | |
109 | |
110 return PyLong_FromLong(value); | |
111 } | |
112 | |
113 static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryTagName( | |
114 sdk_OrthancPluginFindQuery_Object* self, PyObject *args) | |
115 { | |
116 OrthancPlugins::LogInfo("Calling method OrthancPluginGetFindQueryTagName() on object of class OrthancPluginFindQuery"); | |
117 | |
118 if (self->object_ == NULL) | |
119 { | |
120 // TODO: RAISE | |
121 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer); | |
122 PyErr_SetString(PyExc_ValueError, "Invalid object"); | |
123 return NULL; | |
124 } | |
125 | |
126 unsigned long arg0 = 0; | |
127 | |
128 if (!PyArg_ParseTuple(args, "k", &arg0)) | |
129 { | |
130 // TODO => RAISE : https://stackoverflow.com/questions/60832317 | |
131 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); | |
132 return NULL; | |
133 } | |
134 OrthancPlugins::OrthancString s; | |
135 s.Assign(OrthancPluginGetFindQueryTagName(OrthancPlugins::GetGlobalContext(), self->object_, arg0)); | |
136 | |
137 if (s.GetContent() == NULL) | |
138 { | |
139 // TODO => RAISE : https://stackoverflow.com/questions/60832317 | |
140 //PythonLock::RaiseException(module, OrthancPluginErrorCode_InternalError); | |
141 PyErr_SetString(PyExc_ValueError, "Internal error"); | |
142 return NULL; | |
143 } | |
144 else | |
145 { | |
146 return PyUnicode_FromString(s.GetContent()); | |
147 } | |
148 } | |
149 | |
150 static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryValue( | |
151 sdk_OrthancPluginFindQuery_Object* self, PyObject *args) | |
152 { | |
153 OrthancPlugins::LogInfo("Calling method OrthancPluginGetFindQueryValue() on object of class OrthancPluginFindQuery"); | |
154 | |
155 if (self->object_ == NULL) | |
156 { | |
157 // TODO: RAISE | |
158 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer); | |
159 PyErr_SetString(PyExc_ValueError, "Invalid object"); | |
160 return NULL; | |
161 } | |
162 | |
163 unsigned long arg0 = 0; | |
164 | |
165 if (!PyArg_ParseTuple(args, "k", &arg0)) | |
166 { | |
167 // TODO => RAISE : https://stackoverflow.com/questions/60832317 | |
168 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); | |
169 return NULL; | |
170 } | |
171 OrthancPlugins::OrthancString s; | |
172 s.Assign(OrthancPluginGetFindQueryValue(OrthancPlugins::GetGlobalContext(), self->object_, arg0)); | |
173 | |
174 if (s.GetContent() == NULL) | |
175 { | |
176 // TODO => RAISE : https://stackoverflow.com/questions/60832317 | |
177 //PythonLock::RaiseException(module, OrthancPluginErrorCode_InternalError); | |
178 PyErr_SetString(PyExc_ValueError, "Internal error"); | |
179 return NULL; | |
180 } | |
181 else | |
182 { | |
183 return PyUnicode_FromString(s.GetContent()); | |
184 } | |
185 } | |
186 | |
187 | |
188 | |
189 static void RegisterOrthancPluginFindQueryClass(PyObject* module) | |
190 { | |
191 sdk_OrthancPluginFindQuery_Type.tp_new = PyType_GenericNew; | |
192 sdk_OrthancPluginFindQuery_Type.tp_flags = Py_TPFLAGS_DEFAULT; | |
193 sdk_OrthancPluginFindQuery_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginFindQuery"; | |
194 sdk_OrthancPluginFindQuery_Type.tp_methods = sdk_OrthancPluginFindQuery_Methods; | |
195 sdk_OrthancPluginFindQuery_Type.tp_init = (initproc) sdk_OrthancPluginFindQuery_Constructor; | |
196 | |
197 | |
198 if (PyType_Ready(&sdk_OrthancPluginFindQuery_Type) < 0) | |
199 { | |
200 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginFindQuery"); | |
201 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
202 } | |
203 | |
204 Py_INCREF(&sdk_OrthancPluginFindQuery_Type); | |
205 if (PyModule_AddObject(module, "FindQuery", (PyObject *)&sdk_OrthancPluginFindQuery_Type) < 0) | |
206 { | |
207 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginFindQuery"); | |
208 Py_DECREF(&sdk_OrthancPluginFindQuery_Type); | |
209 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
210 } | |
211 } | |
212 | |
213 | |
214 PyObject* GetOrthancPluginFindQueryType() | |
215 { | |
216 return (PyObject*) &sdk_OrthancPluginFindQuery_Type; | |
217 } |