comparison Sources/Autogenerated/sdk_OrthancPluginFindAnswers.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 OrthancPluginFindAnswers* object_;
26 bool borrowed_;
27 } sdk_OrthancPluginFindAnswers_Object;
28
29
30
31 // Forward declaration of the methods
32 static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindAddAnswer(
33 sdk_OrthancPluginFindAnswers_Object* self, PyObject *args);
34 static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindMarkIncomplete(
35 sdk_OrthancPluginFindAnswers_Object* self, PyObject *args);
36
37
38 static PyMethodDef sdk_OrthancPluginFindAnswers_Methods[] = {
39 { "FindAddAnswer",
40 (PyCFunction) sdk_OrthancPluginFindAnswers_OrthancPluginFindAddAnswer, METH_VARARGS,
41 "Generated from C function OrthancPluginFindAddAnswer()" },
42 { "FindMarkIncomplete",
43 (PyCFunction) sdk_OrthancPluginFindAnswers_OrthancPluginFindMarkIncomplete, METH_VARARGS,
44 "Generated from C function OrthancPluginFindMarkIncomplete()" },
45 { NULL } /* Sentinel */
46 };
47
48
49 static int sdk_OrthancPluginFindAnswers_Constructor(
50 sdk_OrthancPluginFindAnswers_Object *self, PyObject *args, PyObject *kwds)
51 {
52 OrthancPlugins::LogInfo("Creating Python object of class OrthancPluginFindAnswers");
53
54 self->object_ = NULL;
55 self->borrowed_ = false;
56
57 long long object = 0;
58 unsigned char borrowed = false;
59
60 if (PyArg_ParseTuple(args, "Lb", &object, &borrowed))
61 {
62 self->object_ = reinterpret_cast<OrthancPluginFindAnswers*>(static_cast<intptr_t>(object));
63 self->borrowed_ = borrowed;
64 return 0;
65 }
66 else
67 {
68 PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor");
69 return -1;
70 }
71 }
72
73
74 /**
75 * Static global structure => the fields that are beyond the last
76 * initialized field are set to zero.
77 * https://stackoverflow.com/a/11152199/881731
78 **/
79 static PyTypeObject sdk_OrthancPluginFindAnswers_Type = {
80 PyVarObject_HEAD_INIT(NULL, 0)
81 "orthanc.FindAnswers", /* tp_name */
82 sizeof(sdk_OrthancPluginFindAnswers_Object), /* tp_basicsize */
83 };
84
85
86
87
88 // Actual implementation of the methods
89 static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindAddAnswer(
90 sdk_OrthancPluginFindAnswers_Object* self, PyObject *args)
91 {
92 OrthancPlugins::LogInfo("Calling method OrthancPluginFindAddAnswer() on object of class OrthancPluginFindAnswers");
93
94 if (self->object_ == NULL)
95 {
96 // TODO: RAISE
97 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
98 PyErr_SetString(PyExc_ValueError, "Invalid object");
99 return NULL;
100 }
101
102 Py_buffer arg0;
103
104 if (!PyArg_ParseTuple(args, "s*", &arg0))
105 {
106 // TODO => RAISE : https://stackoverflow.com/questions/60832317
107 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)");
108 return NULL;
109 }
110 OrthancPluginErrorCode code = OrthancPluginFindAddAnswer(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len);
111 PyBuffer_Release(&arg0);
112
113 if (code == OrthancPluginErrorCode_Success)
114 {
115 Py_INCREF(Py_None);
116 return Py_None;
117 }
118 else
119 {
120 // TODO => RAISE : https://stackoverflow.com/questions/60832317
121 //PythonLock::RaiseException(module, code);
122 PyErr_SetString(PyExc_ValueError, "Internal error");
123 return NULL;
124 }
125 }
126
127 static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindMarkIncomplete(
128 sdk_OrthancPluginFindAnswers_Object* self, PyObject *args)
129 {
130 OrthancPlugins::LogInfo("Calling method OrthancPluginFindMarkIncomplete() on object of class OrthancPluginFindAnswers");
131
132 if (self->object_ == NULL)
133 {
134 // TODO: RAISE
135 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
136 PyErr_SetString(PyExc_ValueError, "Invalid object");
137 return NULL;
138 }
139
140
141 OrthancPluginErrorCode code = OrthancPluginFindMarkIncomplete(OrthancPlugins::GetGlobalContext(), self->object_);
142
143
144 if (code == OrthancPluginErrorCode_Success)
145 {
146 Py_INCREF(Py_None);
147 return Py_None;
148 }
149 else
150 {
151 // TODO => RAISE : https://stackoverflow.com/questions/60832317
152 //PythonLock::RaiseException(module, code);
153 PyErr_SetString(PyExc_ValueError, "Internal error");
154 return NULL;
155 }
156 }
157
158
159
160 static void RegisterOrthancPluginFindAnswersClass(PyObject* module)
161 {
162 sdk_OrthancPluginFindAnswers_Type.tp_new = PyType_GenericNew;
163 sdk_OrthancPluginFindAnswers_Type.tp_flags = Py_TPFLAGS_DEFAULT;
164 sdk_OrthancPluginFindAnswers_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginFindAnswers";
165 sdk_OrthancPluginFindAnswers_Type.tp_methods = sdk_OrthancPluginFindAnswers_Methods;
166 sdk_OrthancPluginFindAnswers_Type.tp_init = (initproc) sdk_OrthancPluginFindAnswers_Constructor;
167
168
169 if (PyType_Ready(&sdk_OrthancPluginFindAnswers_Type) < 0)
170 {
171 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginFindAnswers");
172 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
173 }
174
175 Py_INCREF(&sdk_OrthancPluginFindAnswers_Type);
176 if (PyModule_AddObject(module, "FindAnswers", (PyObject *)&sdk_OrthancPluginFindAnswers_Type) < 0)
177 {
178 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginFindAnswers");
179 Py_DECREF(&sdk_OrthancPluginFindAnswers_Type);
180 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
181 }
182 }
183
184
185 PyObject* GetOrthancPluginFindAnswersType()
186 {
187 return (PyObject*) &sdk_OrthancPluginFindAnswers_Type;
188 }