comparison Sources/Autogenerated/sdk_OrthancPluginFindMatcher.impl.h @ 42:ff5b71166c15

adding missing files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 Jul 2020 14:40:50 +0200
parents
children 23f3099bed47
comparison
equal deleted inserted replaced
41:393d2da0722a 42:ff5b71166c15
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 OrthancPluginFindMatcher* object_;
26 bool borrowed_;
27 } sdk_OrthancPluginFindMatcher_Object;
28
29
30
31 // Forward declaration of the methods
32 static PyObject *sdk_OrthancPluginFindMatcher_OrthancPluginFindMatcherIsMatch(
33 sdk_OrthancPluginFindMatcher_Object* self, PyObject *args);
34
35
36 static PyMethodDef sdk_OrthancPluginFindMatcher_Methods[] = {
37 { "FindMatcherIsMatch",
38 (PyCFunction) sdk_OrthancPluginFindMatcher_OrthancPluginFindMatcherIsMatch, METH_VARARGS,
39 "Generated from C function OrthancPluginFindMatcherIsMatch()" },
40 { NULL } /* Sentinel */
41 };
42
43
44 static int sdk_OrthancPluginFindMatcher_Constructor(
45 sdk_OrthancPluginFindMatcher_Object *self, PyObject *args, PyObject *kwds)
46 {
47 PythonLock::LogCall("Creating Python object of class OrthancPluginFindMatcher");
48
49 self->object_ = NULL;
50 self->borrowed_ = false;
51
52 long long object = 0;
53 unsigned char borrowed = false;
54
55 if (PyArg_ParseTuple(args, "Lb", &object, &borrowed))
56 {
57 self->object_ = reinterpret_cast<OrthancPluginFindMatcher*>(static_cast<intptr_t>(object));
58 self->borrowed_ = borrowed;
59 return 0;
60 }
61 else
62 {
63 PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor");
64 return -1;
65 }
66 }
67
68
69 /**
70 * Static global structure => the fields that are beyond the last
71 * initialized field are set to zero.
72 * https://stackoverflow.com/a/11152199/881731
73 **/
74 static PyTypeObject sdk_OrthancPluginFindMatcher_Type = {
75 PyVarObject_HEAD_INIT(NULL, 0)
76 "orthanc.FindMatcher", /* tp_name */
77 sizeof(sdk_OrthancPluginFindMatcher_Object), /* tp_basicsize */
78 };
79
80
81 static void sdk_OrthancPluginFindMatcher_Destructor(PyObject *self)
82 {
83 PythonLock::LogCall("Destroying Python object of class OrthancPluginFindMatcher");
84
85 sdk_OrthancPluginFindMatcher_Object& tmp = *((sdk_OrthancPluginFindMatcher_Object*) self);
86
87 if (tmp.object_ != NULL &&
88 !tmp.borrowed_)
89 {
90 OrthancPluginFreeFindMatcher(OrthancPlugins::GetGlobalContext(), tmp.object_);
91 tmp.object_ = NULL;
92 }
93
94 Py_TYPE(self)->tp_free((PyObject *)self);
95 }
96
97
98 // Actual implementation of the methods
99 static PyObject *sdk_OrthancPluginFindMatcher_OrthancPluginFindMatcherIsMatch(
100 sdk_OrthancPluginFindMatcher_Object* self, PyObject *args)
101 {
102 PythonLock::LogCall("Calling method OrthancPluginFindMatcherIsMatch() on object of class OrthancPluginFindMatcher");
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 Py_buffer arg0;
113
114 if (!PyArg_ParseTuple(args, "s*", &arg0))
115 {
116 // TODO => RAISE : https://stackoverflow.com/questions/60832317
117 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)");
118 return NULL;
119 }
120 long value = OrthancPluginFindMatcherIsMatch(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len);
121 PyBuffer_Release(&arg0);
122 return PyLong_FromLong(value);
123 }
124
125
126
127 static void RegisterOrthancPluginFindMatcherClass(PyObject* module)
128 {
129 sdk_OrthancPluginFindMatcher_Type.tp_new = PyType_GenericNew;
130 sdk_OrthancPluginFindMatcher_Type.tp_flags = Py_TPFLAGS_DEFAULT;
131 sdk_OrthancPluginFindMatcher_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginFindMatcher";
132 sdk_OrthancPluginFindMatcher_Type.tp_methods = sdk_OrthancPluginFindMatcher_Methods;
133 sdk_OrthancPluginFindMatcher_Type.tp_init = (initproc) sdk_OrthancPluginFindMatcher_Constructor;
134
135 /**
136 * "tp_dealloc is called when the reference count of the object goes
137 * down to zero. This is where you destroy the object and its
138 * members. It should then free the memory occupied by the object by
139 * calling tp_free."
140 * https://stackoverflow.com/a/24863227/881731
141 **/
142 sdk_OrthancPluginFindMatcher_Type.tp_dealloc = sdk_OrthancPluginFindMatcher_Destructor;
143
144 if (PyType_Ready(&sdk_OrthancPluginFindMatcher_Type) < 0)
145 {
146 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginFindMatcher");
147 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
148 }
149
150 Py_INCREF(&sdk_OrthancPluginFindMatcher_Type);
151 if (PyModule_AddObject(module, "FindMatcher", (PyObject *)&sdk_OrthancPluginFindMatcher_Type) < 0)
152 {
153 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginFindMatcher");
154 Py_DECREF(&sdk_OrthancPluginFindMatcher_Type);
155 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
156 }
157 }
158
159
160 PyObject* GetOrthancPluginFindMatcherType()
161 {
162 return (PyObject*) &sdk_OrthancPluginFindMatcher_Type;
163 }