# HG changeset patch # User Sebastien Jodogne # Date 1720011411 -7200 # Node ID f8dc8dd2da768564c6405feead20f852a6f8a0c3 # Parent 2db6c1f6417fa6d2be6cea0ff755b595e49a8688 documented orthanc.RegisterIncomingCStoreInstanceFilter() and orthanc.RegisterReceivedInstanceCallback() diff -r 2db6c1f6417f -r f8dc8dd2da76 CodeAnalysis/CustomFunctions.json --- a/CodeAnalysis/CustomFunctions.json Wed Jul 03 14:39:25 2024 +0200 +++ b/CodeAnalysis/CustomFunctions.json Wed Jul 03 14:56:51 2024 +0200 @@ -299,5 +299,49 @@ } ], "return_sdk_type" : "void" + }, + + { + "comment" : "New in release 4.0", + "short_name" : "RegisterIncomingCStoreInstanceFilter", + "implementation" : "RegisterIncomingCStoreInstanceFilter", + "documentation" : { + "description" : [ "Register a callback to filter incoming DICOM instances received by Orthanc through C-STORE." ], + "args" : { + "callback" : "The callback function." + } + }, + "args" : [ + { + "sdk_name" : "callback", + "sdk_type" : "Callable", + "callable_type" : "IncomingCStoreInstanceFilter", + "callable_protocol_args" : "received_dicom: DicomInstance", + "callable_protocol_return" : "int" + } + ], + "return_sdk_type" : "void" + }, + + { + "comment" : "New in release 4.0", + "short_name" : "RegisterReceivedInstanceCallback", + "implementation" : "RegisterReceivedInstanceCallback", + "documentation" : { + "description" : [ "Register a callback to keep/discard/modify a DICOM instance received by Orthanc from any source (C-STORE or REST API)." ], + "args" : { + "callback" : "The callback function." + } + }, + "args" : [ + { + "sdk_name" : "callback", + "sdk_type" : "Callable", + "callable_type" : "ReceivedInstanceCallback", + "callable_protocol_args" : "received_dicom: bytes, origin: InstanceOrigin", + "callable_protocol_return" : "tuple(ReceivedInstanceAction, bytes)" + } + ], + "return_sdk_type" : "void" } ] diff -r 2db6c1f6417f -r f8dc8dd2da76 Sources/Autogenerated/orthanc.pyi --- a/Sources/Autogenerated/orthanc.pyi Wed Jul 03 14:39:25 2024 +0200 +++ b/Sources/Autogenerated/orthanc.pyi Wed Jul 03 14:56:51 2024 +0200 @@ -2200,6 +2200,20 @@ """ ... +class IncomingCStoreInstanceFilter(typing.Protocol): + def __call__(self, received_dicom: DicomInstance) -> int: + ... + +# Register a callback to filter incoming DICOM instances received by Orthanc through C-STORE +def RegisterIncomingCStoreInstanceFilter(callback: IncomingCStoreInstanceFilter) -> None: + """ + Register a callback to filter incoming DICOM instances received by Orthanc through C-STORE. + + Args: + callback (IncomingCStoreInstanceFilter): The callback function. + """ + ... + class IncomingHttpRequestFilter(typing.Protocol): def __call__(self, uri: str, method: HttpMethod, ip: str, headers: dict, get: dict) -> bool: ... @@ -2285,6 +2299,20 @@ """ ... +class ReceivedInstanceCallback(typing.Protocol): + def __call__(self, received_dicom: bytes, origin: InstanceOrigin) -> tuple(ReceivedInstanceAction, bytes): + ... + +# Register a callback to keep/discard/modify a DICOM instance received by Orthanc from any source (C-STORE or REST API) +def RegisterReceivedInstanceCallback(callback: ReceivedInstanceCallback) -> None: + """ + Register a callback to keep/discard/modify a DICOM instance received by Orthanc from any source (C-STORE or REST API). + + Args: + callback (ReceivedInstanceCallback): The callback function. + """ + ... + class RestCallback(typing.Protocol): def __call__(self, output: RestOutput, url: str, method: HttpMethod, groups: dict, get: dict, headers: dict, body: bytes=None) -> None: ... diff -r 2db6c1f6417f -r f8dc8dd2da76 Sources/Autogenerated/sdk_GlobalFunctions.impl.h --- a/Sources/Autogenerated/sdk_GlobalFunctions.impl.h Wed Jul 03 14:39:25 2024 +0200 +++ b/Sources/Autogenerated/sdk_GlobalFunctions.impl.h Wed Jul 03 14:56:51 2024 +0200 @@ -26,11 +26,13 @@ extern PyObject *CreateImageFromBuffer(PyObject* module, PyObject *args); extern PyObject *LookupDictionary(PyObject* module, PyObject *args); extern PyObject *RegisterFindCallback(PyObject* module, PyObject *args); +extern PyObject *RegisterIncomingCStoreInstanceFilter(PyObject* module, PyObject *args); extern PyObject *RegisterIncomingHttpRequestFilter(PyObject* module, PyObject *args); extern PyObject *RegisterMoveCallback(PyObject* module, PyObject *args); extern PyObject *RegisterMoveCallback2(PyObject* module, PyObject *args); extern PyObject *RegisterOnChangeCallback(PyObject* module, PyObject *args); extern PyObject *RegisterOnStoredInstanceCallback(PyObject* module, PyObject *args); +extern PyObject *RegisterReceivedInstanceCallback(PyObject* module, PyObject *args); extern PyObject *RegisterRestCallback(PyObject* module, PyObject *args); extern PyObject *RegisterStorageArea(PyObject* module, PyObject *args); extern PyObject *RegisterWorklistCallback(PyObject* module, PyObject *args); @@ -2033,6 +2035,8 @@ "Implemented in C++ function LookupDictionary()" }, { "RegisterFindCallback", RegisterFindCallback, METH_VARARGS, "Implemented in C++ function RegisterFindCallback()" }, + { "RegisterIncomingCStoreInstanceFilter", RegisterIncomingCStoreInstanceFilter, METH_VARARGS, + "Implemented in C++ function RegisterIncomingCStoreInstanceFilter()" }, { "RegisterIncomingHttpRequestFilter", RegisterIncomingHttpRequestFilter, METH_VARARGS, "Implemented in C++ function RegisterIncomingHttpRequestFilter()" }, { "RegisterMoveCallback", RegisterMoveCallback, METH_VARARGS, @@ -2043,6 +2047,8 @@ "Implemented in C++ function RegisterOnChangeCallback()" }, { "RegisterOnStoredInstanceCallback", RegisterOnStoredInstanceCallback, METH_VARARGS, "Implemented in C++ function RegisterOnStoredInstanceCallback()" }, + { "RegisterReceivedInstanceCallback", RegisterReceivedInstanceCallback, METH_VARARGS, + "Implemented in C++ function RegisterReceivedInstanceCallback()" }, { "RegisterRestCallback", RegisterRestCallback, METH_VARARGS, "Implemented in C++ function RegisterRestCallback()" }, { "RegisterStorageArea", RegisterStorageArea, METH_VARARGS, diff -r 2db6c1f6417f -r f8dc8dd2da76 Sources/IncomingInstanceFilter.cpp --- a/Sources/IncomingInstanceFilter.cpp Wed Jul 03 14:39:25 2024 +0200 +++ b/Sources/IncomingInstanceFilter.cpp Wed Jul 03 14:56:51 2024 +0200 @@ -21,6 +21,8 @@ #include "IncomingInstanceFilter.h" +#include "PythonHeaderWrapper.h" + #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" #include "Autogenerated/sdk.h" #include "ICallbackRegistration.h" diff -r 2db6c1f6417f -r f8dc8dd2da76 Sources/IncomingInstanceFilter.h --- a/Sources/IncomingInstanceFilter.h Wed Jul 03 14:39:25 2024 +0200 +++ b/Sources/IncomingInstanceFilter.h Wed Jul 03 14:56:51 2024 +0200 @@ -21,8 +21,4 @@ #pragma once -#include "PythonHeaderWrapper.h" - -PyObject* RegisterIncomingCStoreInstanceFilter(PyObject* module, PyObject* args); - void FinalizeIncomingCStoreInstanceFilter(); diff -r 2db6c1f6417f -r f8dc8dd2da76 Sources/Plugin.cpp --- a/Sources/Plugin.cpp Wed Jul 03 14:39:25 2024 +0200 +++ b/Sources/Plugin.cpp Wed Jul 03 14:56:51 2024 +0200 @@ -277,20 +277,6 @@ std::list functions; - - /** - * New in release 4.0 - **/ - - { - PyMethodDef f = { "RegisterIncomingCStoreInstanceFilter", RegisterIncomingCStoreInstanceFilter, METH_VARARGS, "" }; - functions.push_back(f); - } - - { - PyMethodDef f = { "RegisterReceivedInstanceCallback", RegisterReceivedInstanceCallback, METH_VARARGS, "" }; - functions.push_back(f); - } /** * New in release 4.1 diff -r 2db6c1f6417f -r f8dc8dd2da76 Sources/ReceivedInstanceCallback.cpp --- a/Sources/ReceivedInstanceCallback.cpp Wed Jul 03 14:39:25 2024 +0200 +++ b/Sources/ReceivedInstanceCallback.cpp Wed Jul 03 14:56:51 2024 +0200 @@ -21,6 +21,8 @@ #include "ReceivedInstanceCallback.h" +#include "PythonHeaderWrapper.h" + #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" #include "ICallbackRegistration.h" #include "PythonString.h" diff -r 2db6c1f6417f -r f8dc8dd2da76 Sources/ReceivedInstanceCallback.h --- a/Sources/ReceivedInstanceCallback.h Wed Jul 03 14:39:25 2024 +0200 +++ b/Sources/ReceivedInstanceCallback.h Wed Jul 03 14:56:51 2024 +0200 @@ -21,8 +21,4 @@ #pragma once -#include "PythonHeaderWrapper.h" - void FinalizeReceivedInstanceCallback(); - -PyObject* RegisterReceivedInstanceCallback(PyObject* module, PyObject* args);