comparison Sources/OnStoredInstanceCallback.cpp @ 96:627b8a19fb9f

orthanc.RegisterIncomingCStoreInstanceFilter()
author Alain Mazy <am@osimis.io>
date Fri, 15 Oct 2021 18:36:24 +0200
parents 0b3ef425db31
children eb6ac5a801d1
comparison
equal deleted inserted replaced
95:c17cdaf687e3 96:627b8a19fb9f
34 try 34 try
35 { 35 {
36 PythonLock lock; 36 PythonLock lock;
37 37
38 /** 38 /**
39 * Construct an instance object of the "orthanc.RestOutput" 39 * Construct an instance object of the "orthanc.DicomInstance"
40 * class. This is done by calling the constructor function 40 * class. This is done by calling the constructor function
41 * "sdk_OrthancPluginRestOutput_Type". 41 * "sdk_OrthancPluginDicomInstance_Type".
42 **/ 42 **/
43 PythonObject args(lock, PyTuple_New(2)); 43 PythonObject args(lock, PyTuple_New(2));
44 PyTuple_SetItem(args.GetPyObject(), 0, PyLong_FromSsize_t((intptr_t) instance)); 44 PyTuple_SetItem(args.GetPyObject(), 0, PyLong_FromSsize_t((intptr_t) instance));
45 PyTuple_SetItem(args.GetPyObject(), 1, PyBool_FromLong(true /* borrowed, don't destruct */)); 45 PyTuple_SetItem(args.GetPyObject(), 1, PyBool_FromLong(true /* borrowed, don't destruct */));
46 PyObject *pInst = PyObject_CallObject((PyObject*) GetOrthancPluginDicomInstanceType(), args.GetPyObject()); 46 PyObject *pInst = PyObject_CallObject((PyObject*) GetOrthancPluginDicomInstanceType(), args.GetPyObject());
47 47
48 /** 48 /**
49 * Construct the arguments tuple (output, uri) 49 * Construct the arguments tuple (instance, instanceId)
50 **/ 50 **/
51 PythonString str(lock, instanceId); 51 PythonString str(lock, instanceId);
52 52
53 PythonObject args2(lock, PyTuple_New(2)); 53 PythonObject args2(lock, PyTuple_New(2));
54 PyTuple_SetItem(args2.GetPyObject(), 0, pInst); 54 PyTuple_SetItem(args2.GetPyObject(), 0, pInst);
57 PythonObject result(lock, PyObject_CallObject(storedInstanceCallback_, args2.GetPyObject())); 57 PythonObject result(lock, PyObject_CallObject(storedInstanceCallback_, args2.GetPyObject()));
58 58
59 std::string traceback; 59 std::string traceback;
60 if (lock.HasErrorOccurred(traceback)) 60 if (lock.HasErrorOccurred(traceback))
61 { 61 {
62 OrthancPlugins::LogError("Error in the Python on-change callback, " 62 OrthancPlugins::LogError("Error in the Python on-stored-instance callback, "
63 "traceback:\n" + traceback); 63 "traceback:\n" + traceback);
64 return OrthancPluginErrorCode_Plugin; 64 return OrthancPluginErrorCode_Plugin;
65 } 65 }
66 else 66 else
67 { 67 {