Mercurial > hg > orthanc-java
changeset 69:dcd69fbcc34b
wrapping OrthancPluginDequeueValue
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 21 Aug 2025 16:16:46 +0200 |
parents | 65c86e666eda |
children | e673eadccf7d |
files | CodeGeneration/CodeModel.py CodeGeneration/CustomFunctions.json CodeGeneration/CustomMethods.json Plugin/Plugin.cpp |
diffstat | 4 files changed, 79 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/CodeGeneration/CodeModel.py Wed Aug 20 19:32:33 2025 +0200 +++ b/CodeGeneration/CodeModel.py Thu Aug 21 16:16:46 2025 +0200 @@ -237,37 +237,39 @@ else: name = arg['sdk_name'] - if arg['sdk_type'] in [ 'int', 'int32_t', 'uint32_t' ]: + sdk_type = arg['sdk_type'] + + if sdk_type in [ 'int', 'int32_t', 'uint32_t' ]: result = { 'c_type' : 'jint', 'java_signature' : 'I', 'java_type' : 'int', } - elif arg['sdk_type'] == 'uint8_t': + elif sdk_type == 'uint8_t': result = { 'c_type' : 'jbyte', 'java_signature' : 'B', 'java_type' : 'byte', } - elif arg['sdk_type'] == 'uint16_t': + elif sdk_type == 'uint16_t': result = { 'c_type' : 'jshort', 'java_signature' : 'S', 'java_type' : 'short', } - elif arg['sdk_type'] in [ 'int64_t', 'uint64_t' ]: + elif sdk_type in [ 'int64_t', 'uint64_t' ]: result = { 'c_type' : 'jlong', 'java_signature' : 'J', 'java_type' : 'long', } - elif arg['sdk_type'] == 'float': + elif sdk_type == 'float': result = { 'c_type' : 'jfloat', 'java_signature' : 'F', 'java_type' : 'float', } - elif arg['sdk_type'] == 'const char *': + elif sdk_type == 'const char *': result = { 'c_accessor' : 'c_%s.GetValue()' % name, 'c_type' : 'jstring', @@ -275,7 +277,7 @@ 'java_signature' : 'Ljava/lang/String;', 'java_type' : 'String', } - elif arg['sdk_type'] == 'const_void_pointer_with_size': + elif sdk_type == 'const_void_pointer_with_size': # NB: The cast to "const char*" allows compatibility with functions whose # signatures were incorrect at the time they were introduced, notably: # - argument "body" of "OrthancPluginSendHttpStatus()" in 1.11.1 @@ -287,7 +289,7 @@ 'java_signature' : '[B', 'java_type' : 'byte[]', } - elif arg['sdk_type'] == 'enumeration': + elif sdk_type == 'enumeration': result = { 'c_accessor' : 'static_cast<%s>(%s)' % (arg['sdk_enumeration'], name), 'c_type' : 'jint', @@ -296,7 +298,8 @@ 'java_signature' : 'I', 'java_type' : 'int', } - elif arg['sdk_type'] == 'const void *': + sdk_type = arg['sdk_enumeration'] + elif sdk_type == 'const void *': result = { 'c_accessor' : 'c_%s.GetData()' % name, 'c_type' : 'jbyteArray', @@ -304,7 +307,7 @@ 'java_signature' : '[B', 'java_type' : 'byte[]', } - elif arg['sdk_type'] in [ 'object', 'const_object' ]: + elif sdk_type in [ 'object', 'const_object' ]: result = { 'c_accessor' : 'reinterpret_cast<%s*>(static_cast<intptr_t>(%s))' % (arg['sdk_class'], name), 'c_type' : 'jlong', @@ -318,7 +321,7 @@ result['name'] = name result['sdk_name'] = arg['sdk_name'] - result['sdk_type'] = arg['sdk_type'] + result['sdk_type'] = sdk_type if not 'java_wrapper_type' in result: result['java_wrapper_type'] = result['java_type']
--- a/CodeGeneration/CustomFunctions.json Wed Aug 20 19:32:33 2025 +0200 +++ b/CodeGeneration/CustomFunctions.json Thu Aug 21 16:16:46 2025 +0200 @@ -1,5 +1,6 @@ [ { + "comment" : "New in release 2.0", "c_function" : "OrthancPluginCustom_GetQueueSize", "sdk_functions" : [ "OrthancPluginGetQueueSize" ], "documentation" : { @@ -7,7 +8,7 @@ "args" : { "queueId" : "The identifier of the queue." }, - "return" : "The value, or None." + "return" : "The size of the queue." }, "args" : [ { @@ -20,6 +21,36 @@ }, { + "comment" : "New in release 2.0", + "c_function" : "OrthancPluginCustom_DequeueValue", + "sdk_functions" : [ "OrthancPluginDequeueValue" ], + "documentation" : { + "description" : [ "Dequeue a value from a queue." ], + "args" : { + "queueId" : "The identifier of the queue.", + "origin" : "The position from where the value is dequeued (back for LIFO, front for FIFO)." + }, + "return" : "The dequeued value as a byte array, or null if the queue was empty." + }, + "args" : [ + { + "sdk_name" : "queueId", + "sdk_type" : "const char *" + }, + { + "sdk_name" : "origin", + "sdk_type" : "enumeration", + "sdk_enumeration" : "OrthancPluginQueueOrigin" + } + ], + "return_sdk_type" : "java_object", + "return_sdk_class" : "byte[]", + "return_sdk_signature" : "[B", + "since_sdk" : [ 1, 12, 8 ] + }, + + { + "comment" : "New in release 2.0", "c_function" : "OrthancPluginCustom_GetKeyValue", "sdk_functions" : [ "OrthancPluginGetKeyValue" ], "documentation" : { @@ -28,7 +59,7 @@ "storeId" : "The key-value store.", "key" : "The key." }, - "return" : "The value as a byte array, or null." + "return" : "The value as a byte array, or null if the key does not exist." }, "args" : [ {
--- a/CodeGeneration/CustomMethods.json Wed Aug 20 19:32:33 2025 +0200 +++ b/CodeGeneration/CustomMethods.json Thu Aug 21 16:16:46 2025 +0200 @@ -1,6 +1,7 @@ { "OrthancPluginKeysValuesIterator" : [ { + "comment" : "New in release 2.0", "short_name" : "next", "c_function" : "OrthancPluginCustom_KeysValuesIteratorNext", "sdk_functions" : [ "OrthancPluginKeysValuesIteratorNext" ],
--- a/Plugin/Plugin.cpp Wed Aug 20 19:32:33 2025 +0200 +++ b/Plugin/Plugin.cpp Thu Aug 21 16:16:46 2025 +0200 @@ -455,6 +455,37 @@ #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 8) +jobject OrthancPluginCustom_DequeueValue(JNIEnv* env, + OrthancPluginContext* context, + char const* queueId, + OrthancPluginQueueOrigin origin) +{ + OrthancBytes value; + uint8_t found = false; + OrthancPluginErrorCode code = OrthancPluginDequeueValue(context, &found, value.GetMemoryBuffer(), queueId, origin); + + if (code == OrthancPluginErrorCode_Success) + { + if (found) + { + JavaEnvironment java(env); + return java.ConstructByteArray(value.GetSize(), value.GetData()); + } + else + { + // The C "NULL" value results in the Java "null" value + return NULL; + } + } + else + { + throw std::runtime_error(JavaEnvironment::GetRuntimeErrorMessage(context, code)); + } +} +#endif + + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 8) jobject OrthancPluginCustom_GetKeyValue(JNIEnv* env, OrthancPluginContext* context, const char * storeId,