comparison Sources/Autogenerated/sdk_OrthancPluginWorklistQuery.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 OrthancPluginWorklistQuery* object_;
26 bool borrowed_;
27 } sdk_OrthancPluginWorklistQuery_Object;
28
29
30
31 // Forward declaration of the methods
32 static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistIsMatch(
33 sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args);
34 static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistGetDicomQuery(
35 sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args);
36
37
38 static PyMethodDef sdk_OrthancPluginWorklistQuery_Methods[] = {
39 { "WorklistIsMatch",
40 (PyCFunction) sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistIsMatch, METH_VARARGS,
41 "Generated from C function OrthancPluginWorklistIsMatch()" },
42 { "WorklistGetDicomQuery",
43 (PyCFunction) sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistGetDicomQuery, METH_VARARGS,
44 "Generated from C function OrthancPluginWorklistGetDicomQuery()" },
45 { NULL } /* Sentinel */
46 };
47
48
49 static int sdk_OrthancPluginWorklistQuery_Constructor(
50 sdk_OrthancPluginWorklistQuery_Object *self, PyObject *args, PyObject *kwds)
51 {
52 OrthancPlugins::LogInfo("Creating Python object of class OrthancPluginWorklistQuery");
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<OrthancPluginWorklistQuery*>(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_OrthancPluginWorklistQuery_Type = {
80 PyVarObject_HEAD_INIT(NULL, 0)
81 "orthanc.WorklistQuery", /* tp_name */
82 sizeof(sdk_OrthancPluginWorklistQuery_Object), /* tp_basicsize */
83 };
84
85
86
87
88 // Actual implementation of the methods
89 static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistIsMatch(
90 sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args)
91 {
92 OrthancPlugins::LogInfo("Calling method OrthancPluginWorklistIsMatch() on object of class OrthancPluginWorklistQuery");
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 long value = OrthancPluginWorklistIsMatch(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len);
111 PyBuffer_Release(&arg0);
112 return PyLong_FromLong(value);
113 }
114
115 static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistGetDicomQuery(
116 sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args)
117 {
118 OrthancPlugins::LogInfo("Calling method OrthancPluginWorklistGetDicomQuery() on object of class OrthancPluginWorklistQuery");
119
120 if (self->object_ == NULL)
121 {
122 // TODO: RAISE
123 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
124 PyErr_SetString(PyExc_ValueError, "Invalid object");
125 return NULL;
126 }
127
128
129 OrthancPlugins::MemoryBuffer buffer;
130 OrthancPluginErrorCode code = OrthancPluginWorklistGetDicomQuery(OrthancPlugins::GetGlobalContext(), *buffer, self->object_);
131
132 if (code == OrthancPluginErrorCode_Success)
133 {
134 return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize());
135 }
136 else
137 {
138 // TODO => RAISE : https://stackoverflow.com/questions/60832317
139 //PythonLock::RaiseException(module, OrthancPluginErrorCode_InternalError);
140 PyErr_SetString(PyExc_ValueError, "Internal error");
141 return NULL;
142 }
143 }
144
145
146
147 static void RegisterOrthancPluginWorklistQueryClass(PyObject* module)
148 {
149 sdk_OrthancPluginWorklistQuery_Type.tp_new = PyType_GenericNew;
150 sdk_OrthancPluginWorklistQuery_Type.tp_flags = Py_TPFLAGS_DEFAULT;
151 sdk_OrthancPluginWorklistQuery_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginWorklistQuery";
152 sdk_OrthancPluginWorklistQuery_Type.tp_methods = sdk_OrthancPluginWorklistQuery_Methods;
153 sdk_OrthancPluginWorklistQuery_Type.tp_init = (initproc) sdk_OrthancPluginWorklistQuery_Constructor;
154
155
156 if (PyType_Ready(&sdk_OrthancPluginWorklistQuery_Type) < 0)
157 {
158 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginWorklistQuery");
159 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
160 }
161
162 Py_INCREF(&sdk_OrthancPluginWorklistQuery_Type);
163 if (PyModule_AddObject(module, "WorklistQuery", (PyObject *)&sdk_OrthancPluginWorklistQuery_Type) < 0)
164 {
165 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginWorklistQuery");
166 Py_DECREF(&sdk_OrthancPluginWorklistQuery_Type);
167 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
168 }
169 }
170
171
172 PyObject* GetOrthancPluginWorklistQueryType()
173 {
174 return (PyObject*) &sdk_OrthancPluginWorklistQuery_Type;
175 }