annotate Sources/ReceivedInstanceCallback.cpp @ 177:008be55355a4

regenerating the wrapper after patching SDK
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Jun 2024 18:16:26 +0200
parents c8de83fe7faa
children f8dc8dd2da76
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
1 /**
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
2 * Python plugin for Orthanc
166
6fada29b6759 updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 155
diff changeset
3 * Copyright (C) 2020-2023 Osimis S.A., Belgium
6fada29b6759 updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 155
diff changeset
4 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
155
71d305c29cfa updated year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 114
diff changeset
5 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
6 *
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
11 *
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
16 *
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
19 **/
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
20
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
21
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
22 #include "ReceivedInstanceCallback.h"
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
23
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
24 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
25 #include "ICallbackRegistration.h"
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
26 #include "PythonString.h"
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
27
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
28
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
29 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 10, 0)
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
30
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
31 #include <Compatibility.h> // For std::unique_ptr<>
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
32
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
33 static PyObject* receivedInstanceCallback_ = NULL;
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
34
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
35
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
36 static OrthancPluginReceivedInstanceAction ReceivedInstanceCallback(
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
37 OrthancPluginMemoryBuffer64* modifiedDicomBuffer /* out */,
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
38 const void* receivedDicomBuffer,
103
d2259c4cd677 added origin in ReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
39 uint64_t receivedDicomBufferSize,
d2259c4cd677 added origin in ReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
40 OrthancPluginInstanceOrigin origin)
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
41 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
42 try
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
43 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
44 PythonLock lock;
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
45
103
d2259c4cd677 added origin in ReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
46 PythonObject args(lock, PyTuple_New(2));
d2259c4cd677 added origin in ReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
47
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
48 PyTuple_SetItem(args.GetPyObject(), 0, PyBytes_FromStringAndSize(reinterpret_cast<const char*>(receivedDicomBuffer), receivedDicomBufferSize));
103
d2259c4cd677 added origin in ReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
49 PyTuple_SetItem(args.GetPyObject(), 1, PyLong_FromLong(origin));
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
50
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
51 PythonObject result(lock, PyObject_CallObject(receivedInstanceCallback_, args.GetPyObject()));
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
52
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
53 std::string traceback;
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
54 if (lock.HasErrorOccurred(traceback))
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
55 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
56 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python received instance callback, traceback:\n" + traceback);
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
57 return OrthancPluginReceivedInstanceAction_KeepAsIs;
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
58 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
59 else if (!PyTuple_Check(result.GetPyObject()) || PyTuple_Size(result.GetPyObject()) != 2)
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
60 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
61 ORTHANC_PLUGINS_LOG_ERROR("The Python received instance callback has not returned a tuple as expected");
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
62 return OrthancPluginReceivedInstanceAction_KeepAsIs;
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
63 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
64 else
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
65 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
66 PyObject* returnCode = PyTuple_GET_ITEM(result.GetPyObject(), 0);
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
67 PyObject* modifiedDicom = PyTuple_GET_ITEM(result.GetPyObject(), 1);
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
68
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
69 if (!PyLong_Check(returnCode))
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
70 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
71 ORTHANC_PLUGINS_LOG_ERROR("The Python received instance callback has not returned an int as the first element of the return tuple");
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
72 return OrthancPluginReceivedInstanceAction_KeepAsIs;
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
73 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
74
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
75 OrthancPluginReceivedInstanceAction resultCode = static_cast<OrthancPluginReceivedInstanceAction>(PyLong_AsLong(returnCode));
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
76
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
77 if (resultCode == OrthancPluginReceivedInstanceAction_KeepAsIs ||
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
78 resultCode == OrthancPluginReceivedInstanceAction_Discard)
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
79 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
80 return resultCode;
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
81 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
82 else
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
83 {
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
84 char* pythonBuffer = NULL;
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
85 Py_ssize_t pythonSize = 0;
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
86 if (PyBytes_AsStringAndSize(modifiedDicom, &pythonBuffer, &pythonSize) == 1)
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
87 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
88 ORTHANC_PLUGINS_LOG_ERROR("Cannot access the byte buffer returned by the Python received instance callback");
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
89 return OrthancPluginReceivedInstanceAction_KeepAsIs;
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
90 }
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
91 else
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
92 {
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
93 OrthancPluginCreateMemoryBuffer64(OrthancPlugins::GetGlobalContext(), modifiedDicomBuffer, pythonSize);
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
94
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
95 if (pythonSize != 0)
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
96 {
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
97 if (modifiedDicomBuffer->data == NULL)
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
98 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
99 ORTHANC_PLUGINS_LOG_ERROR("Cannot allocate memory in the Python received instance callback");
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
100 return OrthancPluginReceivedInstanceAction_KeepAsIs;
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
101 }
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
102 else
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
103 {
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
104 memcpy(modifiedDicomBuffer->data, pythonBuffer, pythonSize);
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
105 }
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
106 }
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
107
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
108 return OrthancPluginReceivedInstanceAction_Modify;
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
109 }
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
110 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
111 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
112 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
113 catch (OrthancPlugins::PluginException& e)
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
114 {
171
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
115 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python received instance callback: " +
c8de83fe7faa removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 166
diff changeset
116 std::string(e.What(OrthancPlugins::GetGlobalContext())));
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
117 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
118
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
119 return OrthancPluginReceivedInstanceAction_KeepAsIs;
99
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
120 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
121
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
122
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
123 PyObject* RegisterReceivedInstanceCallback(PyObject* module, PyObject* args)
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
124 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
125 // The GIL is locked at this point (no need to create "PythonLock")
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
126
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
127 class Registration : public ICallbackRegistration
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
128 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
129 public:
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
130 virtual void Register() ORTHANC_OVERRIDE
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
131 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
132 OrthancPluginRegisterReceivedInstanceCallback(
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
133 OrthancPlugins::GetGlobalContext(), ReceivedInstanceCallback);
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
134 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
135 };
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
136
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
137 Registration registration;
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
138 return ICallbackRegistration::Apply(
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
139 registration, args, receivedInstanceCallback_, "Python received instance callback");
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
140 }
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
141
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
142
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
143 void FinalizeReceivedInstanceCallback()
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
144 {
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
145 ICallbackRegistration::Unregister(receivedInstanceCallback_);
465bf098554b new callback: orthanc.RegisterReceivedInstanceCallback()
Alain Mazy <am@osimis.io>
parents:
diff changeset
146 }
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
147
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
148 #else
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
149
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
150 #warning OrthancPluginRegisterReceivedInstanceCallback() is not supported
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
151
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
152 PyObject* RegisterReceivedInstanceCallback(PyObject* module, PyObject* args)
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
153 {
102
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
154 PyErr_SetString(PyExc_RuntimeError, "The version of your Orthanc SDK doesn't provide OrthancPluginRegisterReceivedInstanceCallback()");
ed994991a20b improved error handling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
155 return NULL;
100
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
156 }
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
157
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
158 void FinalizeReceivedInstanceCallback()
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
159 {
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
160 }
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
161
e2b2e1d4e1bb fixed compatibility with Orthanc SDK 1.8.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
162 #endif