From 899caad505fec648a21fcae809ff85c1ef35e5b8 Mon Sep 17 00:00:00 2001 From: cyjseagull Date: Mon, 21 Oct 2024 14:40:03 +0800 Subject: [PATCH] ppc_model adapt to gateway --- cpp/CMakeLists.txt | 6 +- cpp/ppc-framework/Helper.h | 14 +- .../ppc-gateway/CMakeLists.txt | 5 +- .../gateway/router/PeerRouterTable.cpp | 2 + .../wedpr/sdk/jni/demo/TransportDemo.java | 12 +- .../wedpr/sdk/jni/generated/FrontConfig.java | 12 +- .../wedpr/sdk/jni/generated/IFront.java | 11 + ...SWIGTYPE_p_std__vectorT_std__string_t.java | 30 - .../wedpr/sdk/jni/generated/StringVec.java | 163 + .../generated/wedpr_java_transportJNI.java | 39 +- .../sdk/jni/transport/IMessageBuilder.java | 9 + .../sdk/jni/transport/WeDPRTransport.java | 5 + .../sdk/jni/transport/impl/TransportImpl.java | 30 + .../src/wedpr_java_transportJAVA_wrap.cxx | 391 ++- .../java/swig/wedpr_java_transport.i | 2 + .../python/bindings/demo/transport_demo.py | 29 +- .../generated/wedpr_python_transport.py | 114 + .../transport/impl/message_impl.py | 6 + .../transport/impl/transport.py | 22 + .../src/wedpr_python_transportPYTHON_wrap.cxx | 2611 +++++++++++++++-- .../python/swig/wedpr_python_transport.i | 2 + python/ppc_common/ppc_protos/ppc_model.proto | 27 - python/ppc_model/common/initializer.py | 26 +- .../common/mock/mock_model_transport.py | 45 + .../ppc_model/common/mock/rpc_client_mock.py | 31 - python/ppc_model/common/model_result.py | 34 +- python/ppc_model/conf/application-sample.yml | 7 - .../test/feature_engineering_unittest.py | 31 +- .../vertical/active_party.py | 40 +- .../vertical/passive_party.py | 34 +- python/ppc_model/interface/model_base.py | 4 + python/ppc_model/network/grpc/__init__.py | 0 python/ppc_model/network/grpc/grpc_client.py | 82 - python/ppc_model/network/grpc/grpc_server.py | 17 - python/ppc_model/network/stub.py | 219 -- .../network/wedpr_model_transport.py | 94 + .../network/wedpr_model_transport_api.py | 23 + python/ppc_model/ppc_model_app.py | 9 - .../test_secure_lgbm_performance_training.py | 31 +- .../test/test_secure_lgbm_training.py | 37 +- .../ppc_model/secure_lgbm/vertical/booster.py | 53 +- python/ppc_model/secure_lr/test/test_lr.py | 21 +- .../test_secure_lr_performance_training.py | 33 +- .../secure_lr/test/test_secure_lr_training.py | 42 +- .../ppc_model/secure_lr/vertical/booster.py | 48 +- python/ppc_model/task/task_manager.py | 14 +- .../task/test/task_manager_unittest.py | 38 +- python/ppc_model_gateway/__init__.py | 0 python/ppc_model_gateway/clients/__init__.py | 0 .../clients/client_manager.py | 57 - .../conf/application-sample.yml | 19 - python/ppc_model_gateway/conf/logging.conf | 40 - python/ppc_model_gateway/config.py | 58 - .../ppc_model_gateway/endpoints/__init__.py | 0 .../endpoints/node_to_partner.py | 36 - .../endpoints/partner_to_node.py | 34 - .../endpoints/response_builder.py | 8 - .../ppc_model_gateway_app.py | 93 - python/ppc_model_gateway/test/__init__.py | 0 python/ppc_model_gateway/test/client.py | 41 - python/ppc_model_gateway/test/server.py | 37 - python/ppc_model_gateway/tools/gen_cert.sh | 70 - python/ppc_model_gateway/tools/start.sh | 32 - python/ppc_model_gateway/tools/stop.sh | 11 - 64 files changed, 3548 insertions(+), 1543 deletions(-) delete mode 100644 cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/SWIGTYPE_p_std__vectorT_std__string_t.java create mode 100644 cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/StringVec.java create mode 100644 python/ppc_model/common/mock/mock_model_transport.py delete mode 100644 python/ppc_model/common/mock/rpc_client_mock.py delete mode 100644 python/ppc_model/network/grpc/__init__.py delete mode 100644 python/ppc_model/network/grpc/grpc_client.py delete mode 100644 python/ppc_model/network/grpc/grpc_server.py delete mode 100644 python/ppc_model/network/stub.py create mode 100644 python/ppc_model/network/wedpr_model_transport.py create mode 100644 python/ppc_model/network/wedpr_model_transport_api.py delete mode 100644 python/ppc_model_gateway/__init__.py delete mode 100644 python/ppc_model_gateway/clients/__init__.py delete mode 100644 python/ppc_model_gateway/clients/client_manager.py delete mode 100644 python/ppc_model_gateway/conf/application-sample.yml delete mode 100644 python/ppc_model_gateway/conf/logging.conf delete mode 100644 python/ppc_model_gateway/config.py delete mode 100644 python/ppc_model_gateway/endpoints/__init__.py delete mode 100644 python/ppc_model_gateway/endpoints/node_to_partner.py delete mode 100644 python/ppc_model_gateway/endpoints/partner_to_node.py delete mode 100644 python/ppc_model_gateway/endpoints/response_builder.py delete mode 100644 python/ppc_model_gateway/ppc_model_gateway_app.py delete mode 100644 python/ppc_model_gateway/test/__init__.py delete mode 100644 python/ppc_model_gateway/test/client.py delete mode 100644 python/ppc_model_gateway/test/server.py delete mode 100644 python/ppc_model_gateway/tools/gen_cert.sh delete mode 100644 python/ppc_model_gateway/tools/start.sh delete mode 100644 python/ppc_model_gateway/tools/stop.sh diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 67650d29..f56ae093 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -80,12 +80,12 @@ set(TRANSPORT_SDK_SOURCE_LIST set(ALL_SOURCE_LIST ${SDK_SOURCE_LIST} + ${TRANSPORT_SDK_SOURCE_LIST} wedpr-crypto/ppc-crypto - wedpr-protocol wedpr-helper/libhelper wedpr-helper/ppc-tools wedpr-storage/ppc-io wedpr-storage/ppc-storage - wedpr-transport/ppc-gateway wedpr-transport/ppc-front - wedpr-transport/ppc-http wedpr-transport/ppc-rpc wedpr-transport/sdk + wedpr-transport/ppc-gateway + wedpr-transport/ppc-http wedpr-computing/ppc-psi wedpr-computing/ppc-mpc wedpr-computing/ppc-pir ${CEM_SOURCE} wedpr-initializer wedpr-main) diff --git a/cpp/ppc-framework/Helper.h b/cpp/ppc-framework/Helper.h index d084cff7..6684fa04 100644 --- a/cpp/ppc-framework/Helper.h +++ b/cpp/ppc-framework/Helper.h @@ -42,7 +42,17 @@ inline std::string_view printP2PIDElegantly(std::string_view p2pId) noexcept template inline std::string_view printNodeID(T const& nodeID) { - size_t offset = nodeID.size() >= 15 ? 15 : nodeID.size(); - return std::string_view((const char*)nodeID.data(), offset); + return std::string_view((const char*)nodeID.data(), nodeID.size()); +} + +template +inline std::string printCollection(T const& collection) +{ + std::ostringstream oss; + for (auto const& it : collection) + { + oss << it << ","; + } + return oss.str(); } } // namespace ppc \ No newline at end of file diff --git a/cpp/wedpr-transport/ppc-gateway/CMakeLists.txt b/cpp/wedpr-transport/ppc-gateway/CMakeLists.txt index 2d4b7364..dc81e28d 100644 --- a/cpp/wedpr-transport/ppc-gateway/CMakeLists.txt +++ b/cpp/wedpr-transport/ppc-gateway/CMakeLists.txt @@ -9,8 +9,9 @@ file(GLOB_RECURSE SRCS ppc-gateway/*.cpp) add_library(${GATEWAY_TARGET} ${SRCS}) -target_link_libraries(${GATEWAY_TARGET} PUBLIC ${TOOLS_TARGET} jsoncpp_static Boost::filesystem ${BCOS_BOOSTSSL_TARGET} ${BCOS_UTILITIES_TARGET} - ${HTTP_TARGET} ${PROTOCOL_TARGET} +target_link_libraries(${GATEWAY_TARGET} PUBLIC ${TOOLS_TARGET} jsoncpp_static Boost::filesystem + ${BCOS_BOOSTSSL_TARGET} ${BCOS_UTILITIES_TARGET} + ${PROTOCOL_TARGET} ${TARS_PROTOCOL_TARGET} ${PB_PROTOCOL_TARGET} TBB::tbb) diff --git a/cpp/wedpr-transport/ppc-gateway/ppc-gateway/gateway/router/PeerRouterTable.cpp b/cpp/wedpr-transport/ppc-gateway/ppc-gateway/gateway/router/PeerRouterTable.cpp index cc04bb08..b7988588 100644 --- a/cpp/wedpr-transport/ppc-gateway/ppc-gateway/gateway/router/PeerRouterTable.cpp +++ b/cpp/wedpr-transport/ppc-gateway/ppc-gateway/gateway/router/PeerRouterTable.cpp @@ -180,6 +180,8 @@ std::vector PeerRouterTable::selectTargetNodes( targetNodeList.insert(std::string(it.first.begin(), it.first.end())); } } + PEER_ROUTER_LOG(INFO) << LOG_DESC("selectTargetNodes, result: ") + << printCollection(targetNodeList); return std::vector(targetNodeList.begin(), targetNodeList.end()); } diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/demo/TransportDemo.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/demo/TransportDemo.java index 6bd5713d..87482370 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/demo/TransportDemo.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/demo/TransportDemo.java @@ -23,9 +23,12 @@ import com.webank.wedpr.sdk.jni.transport.handlers.MessageCallback; import com.webank.wedpr.sdk.jni.transport.handlers.MessageDispatcherCallback; import com.webank.wedpr.sdk.jni.transport.handlers.MessageErrorCallback; +import com.webank.wedpr.sdk.jni.transport.impl.RouteType; import com.webank.wedpr.sdk.jni.transport.impl.TransportImpl; import com.webank.wedpr.sdk.jni.transport.model.TransportEndPoint; +import java.util.List; import lombok.SneakyThrows; +import org.apache.commons.lang3.StringUtils; public class TransportDemo { public static class MessageDispatcherCallbackImpl extends MessageDispatcherCallback { @@ -140,8 +143,9 @@ public static void main(String[] args) throws Exception { WeDPRTransport transport = TransportImpl.build(transportConfig); transport.start(); + String component = "WEDPR_COMPONENT_TEST"; + transport.registerComponent(component); System.out.println("####### start the transport success"); - // send Message to the gateway String topic = "testTopic"; MessageDispatcherCallback messageDispatcherCallback = @@ -179,6 +183,12 @@ public static void main(String[] args) throws Exception { + ", payload: " + new String(msg.getPayload()) + "####"); + // selectNodeListByPolicy + List nodeList = + transport.selectNodeListByPolicy( + RouteType.ROUTE_THROUGH_COMPONENT, null, component, null); + System.out.println( + "###### selectNodeListByPolicy result: " + StringUtils.join(nodeList, ",")); i++; } catch (Exception e) { System.out.println("#### exception: " + e.getMessage()); diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/FrontConfig.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/FrontConfig.java index 32fb72fc..af3b8bcb 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/FrontConfig.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/FrontConfig.java @@ -94,22 +94,22 @@ public SWIGTYPE_p_ppc__protocol__INodeInfo__Ptr generateNodeInfo() { wedpr_java_transportJNI.FrontConfig_generateNodeInfo(swigCPtr, this), true); } - public SWIGTYPE_p_std__vectorT_std__string_t getComponents() { - return new SWIGTYPE_p_std__vectorT_std__string_t( + public StringVec getComponents() { + return new StringVec( wedpr_java_transportJNI.FrontConfig_getComponents(swigCPtr, this), false); } - public void setComponents(SWIGTYPE_p_std__vectorT_std__string_t components) { + public void setComponents(StringVec components) { wedpr_java_transportJNI.FrontConfig_setComponents( - swigCPtr, this, SWIGTYPE_p_std__vectorT_std__string_t.getCPtr(components)); + swigCPtr, this, StringVec.getCPtr(components), components); } public void addComponent(String component) { wedpr_java_transportJNI.FrontConfig_addComponent(swigCPtr, this, component); } - public SWIGTYPE_p_std__vectorT_std__string_t mutableComponents() { - return new SWIGTYPE_p_std__vectorT_std__string_t( + public StringVec mutableComponents() { + return new StringVec( wedpr_java_transportJNI.FrontConfig_mutableComponents(swigCPtr, this), false); } diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFront.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFront.java index 935dd715..35bad809 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFront.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/IFront.java @@ -223,4 +223,15 @@ public void registerComponent(String component) { public void unRegisterComponent(String component) { wedpr_java_transportJNI.IFront_unRegisterComponent(swigCPtr, this, component); } + + public StringVec selectNodesByRoutePolicy(short routeType, MessageOptionalHeader routeInfo) { + return new StringVec( + wedpr_java_transportJNI.IFront_selectNodesByRoutePolicy( + swigCPtr, + this, + routeType, + MessageOptionalHeader.getCPtr(routeInfo), + routeInfo), + true); + } } diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/SWIGTYPE_p_std__vectorT_std__string_t.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/SWIGTYPE_p_std__vectorT_std__string_t.java deleted file mode 100644 index 2ab7be1f..00000000 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/SWIGTYPE_p_std__vectorT_std__string_t.java +++ /dev/null @@ -1,30 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (https://www.swig.org). - * Version 4.2.1 - * - * Do not make changes to this file unless you know what you are doing - modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package com.webank.wedpr.sdk.jni.generated; - -public class SWIGTYPE_p_std__vectorT_std__string_t { - private transient long swigCPtr; - - protected SWIGTYPE_p_std__vectorT_std__string_t( - long cPtr, @SuppressWarnings("unused") boolean futureUse) { - swigCPtr = cPtr; - } - - protected SWIGTYPE_p_std__vectorT_std__string_t() { - swigCPtr = 0; - } - - protected static long getCPtr(SWIGTYPE_p_std__vectorT_std__string_t obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected static long swigRelease(SWIGTYPE_p_std__vectorT_std__string_t obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/StringVec.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/StringVec.java new file mode 100644 index 00000000..1138ae64 --- /dev/null +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/StringVec.java @@ -0,0 +1,163 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (https://www.swig.org). + * Version 4.2.1 + * + * Do not make changes to this file unless you know what you are doing - modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package com.webank.wedpr.sdk.jni.generated; + +public class StringVec extends java.util.AbstractList implements java.util.RandomAccess { + private transient long swigCPtr; + protected transient boolean swigCMemOwn; + + protected StringVec(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(StringVec obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected static long swigRelease(StringVec obj) { + long ptr = 0; + if (obj != null) { + if (!obj.swigCMemOwn) + throw new RuntimeException("Cannot release ownership as memory is not owned"); + ptr = obj.swigCPtr; + obj.swigCMemOwn = false; + obj.delete(); + } + return ptr; + } + + @SuppressWarnings({"deprecation", "removal"}) + protected void finalize() { + delete(); + } + + public synchronized void delete() { + if (swigCPtr != 0) { + if (swigCMemOwn) { + swigCMemOwn = false; + wedpr_java_transportJNI.delete_StringVec(swigCPtr); + } + swigCPtr = 0; + } + } + + public StringVec(String[] initialElements) { + this(); + reserve(initialElements.length); + + for (String element : initialElements) { + add(element); + } + } + + public StringVec(Iterable initialElements) { + this(); + for (String element : initialElements) { + add(element); + } + } + + public String get(int index) { + return doGet(index); + } + + public String set(int index, String e) { + return doSet(index, e); + } + + public boolean add(String e) { + modCount++; + doAdd(e); + return true; + } + + public void add(int index, String e) { + modCount++; + doAdd(index, e); + } + + public String remove(int index) { + modCount++; + return doRemove(index); + } + + protected void removeRange(int fromIndex, int toIndex) { + modCount++; + doRemoveRange(fromIndex, toIndex); + } + + public int size() { + return doSize(); + } + + public int capacity() { + return doCapacity(); + } + + public void reserve(int n) { + doReserve(n); + } + + public StringVec() { + this(wedpr_java_transportJNI.new_StringVec__SWIG_0(), true); + } + + public StringVec(StringVec other) { + this(wedpr_java_transportJNI.new_StringVec__SWIG_1(StringVec.getCPtr(other), other), true); + } + + public boolean isEmpty() { + return wedpr_java_transportJNI.StringVec_isEmpty(swigCPtr, this); + } + + public void clear() { + wedpr_java_transportJNI.StringVec_clear(swigCPtr, this); + } + + public StringVec(int count, String value) { + this(wedpr_java_transportJNI.new_StringVec__SWIG_2(count, value), true); + } + + private int doCapacity() { + return wedpr_java_transportJNI.StringVec_doCapacity(swigCPtr, this); + } + + private void doReserve(int n) { + wedpr_java_transportJNI.StringVec_doReserve(swigCPtr, this, n); + } + + private int doSize() { + return wedpr_java_transportJNI.StringVec_doSize(swigCPtr, this); + } + + private void doAdd(String x) { + wedpr_java_transportJNI.StringVec_doAdd__SWIG_0(swigCPtr, this, x); + } + + private void doAdd(int index, String x) { + wedpr_java_transportJNI.StringVec_doAdd__SWIG_1(swigCPtr, this, index, x); + } + + private String doRemove(int index) { + return wedpr_java_transportJNI.StringVec_doRemove(swigCPtr, this, index); + } + + private String doGet(int index) { + return wedpr_java_transportJNI.StringVec_doGet(swigCPtr, this, index); + } + + private String doSet(int index, String val) { + return wedpr_java_transportJNI.StringVec_doSet(swigCPtr, this, index, val); + } + + private void doRemoveRange(int fromIndex, int toIndex) { + wedpr_java_transportJNI.StringVec_doRemoveRange(swigCPtr, this, fromIndex, toIndex); + } +} diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/wedpr_java_transportJNI.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/wedpr_java_transportJNI.java index 81c85a3c..82e57708 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/wedpr_java_transportJNI.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/generated/wedpr_java_transportJNI.java @@ -146,6 +146,40 @@ public static final native void ibytes_doRemoveRange( public static final native void delete_ibytes(long jarg1); + public static final native long new_StringVec__SWIG_0(); + + public static final native long new_StringVec__SWIG_1(long jarg1, StringVec jarg1_); + + public static final native boolean StringVec_isEmpty(long jarg1, StringVec jarg1_); + + public static final native void StringVec_clear(long jarg1, StringVec jarg1_); + + public static final native long new_StringVec__SWIG_2(int jarg1, String jarg2); + + public static final native int StringVec_doCapacity(long jarg1, StringVec jarg1_); + + public static final native void StringVec_doReserve(long jarg1, StringVec jarg1_, int jarg2); + + public static final native int StringVec_doSize(long jarg1, StringVec jarg1_); + + public static final native void StringVec_doAdd__SWIG_0( + long jarg1, StringVec jarg1_, String jarg2); + + public static final native void StringVec_doAdd__SWIG_1( + long jarg1, StringVec jarg1_, int jarg2, String jarg3); + + public static final native String StringVec_doRemove(long jarg1, StringVec jarg1_, int jarg2); + + public static final native String StringVec_doGet(long jarg1, StringVec jarg1_, int jarg2); + + public static final native String StringVec_doSet( + long jarg1, StringVec jarg1_, int jarg2, String jarg3); + + public static final native void StringVec_doRemoveRange( + long jarg1, StringVec jarg1_, int jarg2, int jarg3); + + public static final native void delete_StringVec(long jarg1); + public static final native long Error_buildError__SWIG_0( byte[] jarg1, byte[] jarg2, int jarg3, int jarg4, String jarg5); @@ -239,7 +273,7 @@ public static final native void FrontConfig_setGrpcConfig( public static final native long FrontConfig_getComponents(long jarg1, FrontConfig jarg1_); public static final native void FrontConfig_setComponents( - long jarg1, FrontConfig jarg1_, long jarg2); + long jarg1, FrontConfig jarg1_, long jarg2, StringVec jarg2_); public static final native void FrontConfig_addComponent( long jarg1, FrontConfig jarg1_, String jarg2); @@ -748,6 +782,9 @@ public static final native void IFront_registerComponent( public static final native void IFront_unRegisterComponent( long jarg1, IFront jarg1_, String jarg2); + public static final native long IFront_selectNodesByRoutePolicy( + long jarg1, IFront jarg1_, short jarg2, long jarg3, MessageOptionalHeader jarg3_); + public static final native void delete_IFrontBuilder(long jarg1); public static final native long IFrontBuilder_buildClient( diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/IMessageBuilder.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/IMessageBuilder.java index e4c75358..1618c84c 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/IMessageBuilder.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/IMessageBuilder.java @@ -43,4 +43,13 @@ public static MessageOptionalHeader buildRouteInfo( routeInfo.disOwnMemory(); return routeInfo; } + + @SneakyThrows(Exception.class) + public static MessageOptionalHeader buildRouteInfo( + MessageOptionalHeaderBuilder routeInfoBuilder) { + // return the ownership to cpp, since it is created by cpp + MessageOptionalHeader routeInfo = routeInfoBuilder.build(); + routeInfo.disOwnMemory(); + return routeInfo; + } } diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/WeDPRTransport.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/WeDPRTransport.java index 5e0545e4..b1e03756 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/WeDPRTransport.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/WeDPRTransport.java @@ -20,6 +20,8 @@ import com.webank.wedpr.sdk.jni.transport.handlers.MessageCallback; import com.webank.wedpr.sdk.jni.transport.handlers.MessageDispatcherCallback; import com.webank.wedpr.sdk.jni.transport.handlers.MessageErrorCallback; +import com.webank.wedpr.sdk.jni.transport.impl.RouteType; +import java.util.List; public interface WeDPRTransport { // start the transport @@ -182,4 +184,7 @@ void pushByInst(String topic, String dstInst, int seq, byte[] payload, int timeo IMessage pop(String topic, int timeout) throws WeDPRSDKException; IMessage peek(String topic); + + List selectNodeListByPolicy( + RouteType routeType, String dstInst, String dstComponent, String dstNode); } diff --git a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/impl/TransportImpl.java b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/impl/TransportImpl.java index 17679b24..7f3ceb28 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/impl/TransportImpl.java +++ b/cpp/wedpr-transport/sdk-wrapper/java/bindings/src/main/java/com/webank/wedpr/sdk/jni/transport/impl/TransportImpl.java @@ -29,6 +29,8 @@ import com.webank.wedpr.sdk.jni.transport.handlers.MessageDispatcherCallback; import com.webank.wedpr.sdk.jni.transport.handlers.MessageErrorCallback; import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; import lombok.SneakyThrows; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -424,4 +426,32 @@ public IMessage peek(String topic) { } return IMessageBuilder.build(msg); } + + @Override + public List selectNodeListByPolicy( + RouteType routeType, String dstInst, String dstComponent, String dstNode) { + MessageOptionalHeader routeInfo = + IMessageBuilder.buildRouteInfo(this.transport.routeInfoBuilder()); + if (StringUtils.isNotBlank(dstInst)) { + routeInfo.setDstInst(dstInst); + } + if (StringUtils.isNotBlank(dstComponent)) { + routeInfo.setComponentType(dstComponent); + } + if (StringUtils.isNotBlank(dstNode)) { + routeInfo.setDstNodeBuffer(dstNode.getBytes(), BigInteger.valueOf(dstNode.length())); + } + StringVec result = + this.transport + .getFront() + .selectNodesByRoutePolicy((short) routeType.ordinal(), routeInfo); + if (result == null) { + return null; + } + List nodeList = new ArrayList<>(); + for (int i = 0; i < result.size(); i++) { + nodeList.add(result.get(i)); + } + return nodeList; + } } diff --git a/cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.cxx b/cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.cxx index 36134a4e..699684c9 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.cxx +++ b/cpp/wedpr-transport/sdk-wrapper/java/src/wedpr_java_transportJAVA_wrap.cxx @@ -1056,6 +1056,68 @@ SWIGINTERN void std_vector_Sl_int8_t_Sg__doRemoveRange(std::vector< int8_t > *se throw std::out_of_range("vector index out of range"); } } +SWIGINTERN std::vector< std::string > *new_std_vector_Sl_std_string_Sg___SWIG_2(jint count,std::string const &value){ + if (count < 0) + throw std::out_of_range("vector count must be positive"); + return new std::vector< std::string >(static_cast::size_type>(count), value); + } +SWIGINTERN jint std_vector_Sl_std_string_Sg__doCapacity(std::vector< std::string > *self){ + return SWIG_VectorSize(self->capacity()); + } +SWIGINTERN void std_vector_Sl_std_string_Sg__doReserve(std::vector< std::string > *self,jint n){ + if (n < 0) + throw std::out_of_range("vector reserve size must be positive"); + self->reserve(n); + } +SWIGINTERN jint std_vector_Sl_std_string_Sg__doSize(std::vector< std::string > const *self){ + return SWIG_VectorSize(self->size()); + } +SWIGINTERN void std_vector_Sl_std_string_Sg__doAdd__SWIG_0(std::vector< std::string > *self,std::vector< std::string >::value_type const &x){ + self->push_back(x); + } +SWIGINTERN void std_vector_Sl_std_string_Sg__doAdd__SWIG_1(std::vector< std::string > *self,jint index,std::vector< std::string >::value_type const &x){ + jint size = static_cast(self->size()); + if (0 <= index && index <= size) { + self->insert(self->begin() + index, x); + } else { + throw std::out_of_range("vector index out of range"); + } + } +SWIGINTERN std::vector< std::string >::value_type std_vector_Sl_std_string_Sg__doRemove(std::vector< std::string > *self,jint index){ + jint size = static_cast(self->size()); + if (0 <= index && index < size) { + std::string const old_value = (*self)[index]; + self->erase(self->begin() + index); + return old_value; + } else { + throw std::out_of_range("vector index out of range"); + } + } +SWIGINTERN std::vector< std::string >::value_type const &std_vector_Sl_std_string_Sg__doGet(std::vector< std::string > *self,jint index){ + jint size = static_cast(self->size()); + if (index >= 0 && index < size) + return (*self)[index]; + else + throw std::out_of_range("vector index out of range"); + } +SWIGINTERN std::vector< std::string >::value_type std_vector_Sl_std_string_Sg__doSet(std::vector< std::string > *self,jint index,std::vector< std::string >::value_type const &val){ + jint size = static_cast(self->size()); + if (index >= 0 && index < size) { + std::string const old_value = (*self)[index]; + (*self)[index] = val; + return old_value; + } + else + throw std::out_of_range("vector index out of range"); + } +SWIGINTERN void std_vector_Sl_std_string_Sg__doRemoveRange(std::vector< std::string > *self,jint fromIndex,jint toIndex){ + jint size = static_cast(self->size()); + if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) { + self->erase(self->begin() + fromIndex, self->begin() + toIndex); + } else { + throw std::out_of_range("vector index out of range"); + } + } struct SWIG_null_deleter { void operator() (void const *) const { @@ -2309,6 +2371,308 @@ SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1tra } +SWIGEXPORT jlong JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_new_1StringVec_1_1SWIG_10(JNIEnv *jenv, jclass jcls) { + jlong jresult = 0 ; + std::vector< std::string > *result = 0 ; + + (void)jenv; + (void)jcls; + result = (std::vector< std::string > *)new std::vector< std::string >(); + *(std::vector< std::string > **)&jresult = result; + return jresult; +} + + +SWIGEXPORT jlong JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_new_1StringVec_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { + jlong jresult = 0 ; + std::vector< std::string > *arg1 = 0 ; + std::vector< std::string > *result = 0 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + if (!arg1) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "std::vector< std::string > const & is null"); + return 0; + } + result = (std::vector< std::string > *)new std::vector< std::string >((std::vector< std::string > const &)*arg1); + *(std::vector< std::string > **)&jresult = result; + return jresult; +} + + +SWIGEXPORT jboolean JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1isEmpty(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { + jboolean jresult = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + result = (bool)((std::vector< std::string > const *)arg1)->empty(); + jresult = (jboolean)result; + return jresult; +} + + +SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1clear(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + (arg1)->clear(); +} + + +SWIGEXPORT jlong JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_new_1StringVec_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jint jarg1, jstring jarg2) { + jlong jresult = 0 ; + jint arg1 ; + std::string *arg2 = 0 ; + std::vector< std::string > *result = 0 ; + + (void)jenv; + (void)jcls; + arg1 = jarg1; + if(!jarg2) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); + return 0; + } + const char *arg2_pstr = (const char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2_pstr) return 0; + std::string arg2_str(arg2_pstr); + arg2 = &arg2_str; + jenv->ReleaseStringUTFChars(jarg2, arg2_pstr); + try { + result = (std::vector< std::string > *)new_std_vector_Sl_std_string_Sg___SWIG_2(SWIG_STD_MOVE(arg1),(std::string const &)*arg2); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return 0; + } + *(std::vector< std::string > **)&jresult = result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doCapacity(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { + jint jresult = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + try { + result = std_vector_Sl_std_string_Sg__doCapacity(arg1); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return 0; + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doReserve(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint arg2 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + arg2 = jarg2; + try { + std_vector_Sl_std_string_Sg__doReserve(arg1,SWIG_STD_MOVE(arg2)); + } catch(std::length_error &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return ; + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return ; + } +} + + +SWIGEXPORT jint JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doSize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { + jint jresult = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + try { + result = std_vector_Sl_std_string_Sg__doSize((std::vector< std::string > const *)arg1); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return 0; + } + jresult = result; + return jresult; +} + + +SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doAdd_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) { + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::value_type *arg2 = 0 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + if(!jarg2) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); + return ; + } + const char *arg2_pstr = (const char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2_pstr) return ; + std::vector< std::string >::value_type arg2_str(arg2_pstr); + arg2 = &arg2_str; + jenv->ReleaseStringUTFChars(jarg2, arg2_pstr); + std_vector_Sl_std_string_Sg__doAdd__SWIG_0(arg1,(std::string const &)*arg2); +} + + +SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doAdd_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jstring jarg3) { + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint arg2 ; + std::vector< std::string >::value_type *arg3 = 0 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + arg2 = jarg2; + if(!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); + return ; + } + const char *arg3_pstr = (const char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3_pstr) return ; + std::vector< std::string >::value_type arg3_str(arg3_pstr); + arg3 = &arg3_str; + jenv->ReleaseStringUTFChars(jarg3, arg3_pstr); + try { + std_vector_Sl_std_string_Sg__doAdd__SWIG_1(arg1,SWIG_STD_MOVE(arg2),(std::string const &)*arg3); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return ; + } +} + + +SWIGEXPORT jstring JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doRemove(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { + jstring jresult = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint arg2 ; + std::vector< std::string >::value_type result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + arg2 = jarg2; + try { + result = std_vector_Sl_std_string_Sg__doRemove(arg1,SWIG_STD_MOVE(arg2)); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return 0; + } + jresult = jenv->NewStringUTF((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT jstring JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doGet(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) { + jstring jresult = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint arg2 ; + std::vector< std::string >::value_type *result = 0 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + arg2 = jarg2; + try { + result = (std::vector< std::string >::value_type *) &std_vector_Sl_std_string_Sg__doGet(arg1,SWIG_STD_MOVE(arg2)); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return 0; + } + jresult = jenv->NewStringUTF(result->c_str()); + return jresult; +} + + +SWIGEXPORT jstring JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doSet(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jstring jarg3) { + jstring jresult = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint arg2 ; + std::vector< std::string >::value_type *arg3 = 0 ; + std::vector< std::string >::value_type result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + arg2 = jarg2; + if(!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string"); + return 0; + } + const char *arg3_pstr = (const char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3_pstr) return 0; + std::vector< std::string >::value_type arg3_str(arg3_pstr); + arg3 = &arg3_str; + jenv->ReleaseStringUTFChars(jarg3, arg3_pstr); + try { + result = std_vector_Sl_std_string_Sg__doSet(arg1,SWIG_STD_MOVE(arg2),(std::string const &)*arg3); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return 0; + } + jresult = jenv->NewStringUTF((&result)->c_str()); + return jresult; +} + + +SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_StringVec_1doRemoveRange(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3) { + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + jint arg2 ; + jint arg3 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(std::vector< std::string > **)&jarg1; + arg2 = jarg2; + arg3 = jarg3; + try { + std_vector_Sl_std_string_Sg__doRemoveRange(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3)); + } catch(std::out_of_range &_e) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, (&_e)->what()); + return ; + } +} + + +SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_delete_1StringVec(JNIEnv *jenv, jclass jcls, jlong jarg1) { + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(std::vector< std::string > **)&jarg1; + delete arg1; +} + + SWIGEXPORT jlong JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_Error_1buildError_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jbyteArray jarg2, jint jarg3, jint jarg4, jstring jarg5) { jlong jresult = 0 ; char *arg1 = (char *) 0 ; @@ -3078,7 +3442,7 @@ SWIGEXPORT jlong JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1tr } -SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_FrontConfig_1setComponents(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { +SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_FrontConfig_1setComponents(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) { ppc::front::FrontConfig *arg1 = (ppc::front::FrontConfig *) 0 ; std::vector< std::string > *arg2 = 0 ; std::shared_ptr< ppc::front::FrontConfig > *smartarg1 = 0 ; @@ -3086,6 +3450,7 @@ SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1tra (void)jenv; (void)jcls; (void)jarg1_; + (void)jarg2_; smartarg1 = *(std::shared_ptr< ppc::front::FrontConfig > **)&jarg1; arg1 = (ppc::front::FrontConfig *)(smartarg1 ? smartarg1->get() : 0); @@ -6734,6 +7099,30 @@ SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1tra } +SWIGEXPORT jlong JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_IFront_1selectNodesByRoutePolicy(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jshort jarg2, jlong jarg3, jobject jarg3_) { + jlong jresult = 0 ; + ppc::front::IFront *arg1 = (ppc::front::IFront *) 0 ; + int16_t arg2 ; + ppc::protocol::MessageOptionalHeader::Ptr *arg3 = 0 ; + std::shared_ptr< ppc::front::IFront > *smartarg1 = 0 ; + ppc::protocol::MessageOptionalHeader::Ptr tempnull3 ; + std::vector< std::string > result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + (void)jarg3_; + + smartarg1 = *(std::shared_ptr< ppc::front::IFront > **)&jarg1; + arg1 = (ppc::front::IFront *)(smartarg1 ? smartarg1->get() : 0); + arg2 = (int16_t)jarg2; + arg3 = jarg3 ? *(ppc::protocol::MessageOptionalHeader::Ptr **)&jarg3 : &tempnull3; + result = (arg1)->selectNodesByRoutePolicy(arg2,(ppc::protocol::MessageOptionalHeader::Ptr const &)*arg3); + *(std::vector< std::string > **)&jresult = new std::vector< std::string >(result); + return jresult; +} + + SWIGEXPORT void JNICALL Java_com_webank_wedpr_sdk_jni_generated_wedpr_1java_1transportJNI_delete_1IFrontBuilder(JNIEnv *jenv, jclass jcls, jlong jarg1) { ppc::front::IFrontBuilder *arg1 = (ppc::front::IFrontBuilder *) 0 ; diff --git a/cpp/wedpr-transport/sdk-wrapper/java/swig/wedpr_java_transport.i b/cpp/wedpr-transport/sdk-wrapper/java/swig/wedpr_java_transport.i index fd0a6d1c..91b8570c 100644 --- a/cpp/wedpr-transport/sdk-wrapper/java/swig/wedpr_java_transport.i +++ b/cpp/wedpr-transport/sdk-wrapper/java/swig/wedpr_java_transport.i @@ -115,6 +115,7 @@ namespace ppc::front{ namespace std{ class vector; + class string; } namespace bcos{ @@ -151,6 +152,7 @@ namespace bcos{ %template(ubytes) std::vector; %template(ibytes) std::vector; +%template(StringVec) std::vector; /// callbacks %feature("director") ppc::front::ErrorCallback; diff --git a/cpp/wedpr-transport/sdk-wrapper/python/bindings/demo/transport_demo.py b/cpp/wedpr-transport/sdk-wrapper/python/bindings/demo/transport_demo.py index bce7efff..898f3f76 100644 --- a/cpp/wedpr-transport/sdk-wrapper/python/bindings/demo/transport_demo.py +++ b/cpp/wedpr-transport/sdk-wrapper/python/bindings/demo/transport_demo.py @@ -4,19 +4,23 @@ import os root_path = os.path.abspath(os.path.dirname(__file__)) sys.path.append(os.path.join(root_path, "../")) +# Note: here can't be refactored by autopep import time from wedpr_python_gateway_sdk.transport.impl.transport_loader import TransportLoader from wedpr_python_gateway_sdk.transport.impl.transport_config import TransportConfig from wedpr_python_gateway_sdk.transport.impl.transport import Transport +from wedpr_python_gateway_sdk.transport.impl.transport import RouteType +import traceback import argparse -import sys def parse_args(): parser = argparse.ArgumentParser(prog=sys.argv[0]) parser.add_argument("-t", '--threadpool_size', help='the threadpool size', default=4, required=True) + parser.add_argument('--dst_inst', + help='the dist inst', default=None, required=True) parser.add_argument("-n", '--node_id', help='the nodeID', required=False) parser.add_argument("-g", '--gateway_targets', @@ -39,6 +43,8 @@ def message_event_loop(args): transport = TransportLoader.load(transport_config) print(f"Create transport success, config: {transport_config.desc()}") transport.start() + component = "WEDPR_COMPONENT_TEST" + transport.register_component(component) print(f"Start transport success") test_topic = "sync_message_event_loop_test" while Transport.should_exit is False: @@ -52,7 +58,28 @@ def message_event_loop(args): continue print( f"Receive message: {msg.detail()}, buffer: {str(msg.get_payload())}") + + node_list = transport.select_node_list_by_route_policy(route_type=RouteType.ROUTE_THROUGH_COMPONENT, + dst_inst=args.dst_inst, + dst_component=component) + if node_list is None: + print( + f"####select_node_list_by_route_policy: not find component: {component}") + continue + for node in node_list: + print( + f"##### select_node_list_by_route_policy result: {node}, component: {component}") + + selected_node = transport.select_node_by_route_policy(route_type=RouteType.ROUTE_THROUGH_COMPONENT, + dst_inst=args.dst_inst, + dst_component=component) + if selected_node is None: + print( + f"####select_node_by_route_policy: not find component: {component}") + print( + f"##### select_node_by_route_policy, selected_node: {selected_node}, component: {component}") except Exception as e: + traceback.print_exc() print(f"exception: {e}") time.sleep(2) print(f"stop the transport") diff --git a/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/generated/wedpr_python_transport.py b/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/generated/wedpr_python_transport.py index 83de8c13..0b97ed83 100644 --- a/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/generated/wedpr_python_transport.py +++ b/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/generated/wedpr_python_transport.py @@ -624,6 +624,117 @@ def capacity(self): _wedpr_python_transport.ibytes_swigregister(ibytes) +class StringVec(object): + thisown = property(lambda x: x.this.own(), lambda x, + v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + + def iterator(self): + return _wedpr_python_transport.StringVec_iterator(self) + + def __iter__(self): + return self.iterator() + + def __nonzero__(self): + return _wedpr_python_transport.StringVec___nonzero__(self) + + def __bool__(self): + return _wedpr_python_transport.StringVec___bool__(self) + + def __len__(self): + return _wedpr_python_transport.StringVec___len__(self) + + def __getslice__(self, i, j): + return _wedpr_python_transport.StringVec___getslice__(self, i, j) + + def __setslice__(self, *args): + return _wedpr_python_transport.StringVec___setslice__(self, *args) + + def __delslice__(self, i, j): + return _wedpr_python_transport.StringVec___delslice__(self, i, j) + + def __delitem__(self, *args): + return _wedpr_python_transport.StringVec___delitem__(self, *args) + + def __getitem__(self, *args): + return _wedpr_python_transport.StringVec___getitem__(self, *args) + + def __setitem__(self, *args): + return _wedpr_python_transport.StringVec___setitem__(self, *args) + + def pop(self): + return _wedpr_python_transport.StringVec_pop(self) + + def append(self, x): + return _wedpr_python_transport.StringVec_append(self, x) + + def empty(self): + return _wedpr_python_transport.StringVec_empty(self) + + def size(self): + return _wedpr_python_transport.StringVec_size(self) + + def swap(self, v): + return _wedpr_python_transport.StringVec_swap(self, v) + + def begin(self): + return _wedpr_python_transport.StringVec_begin(self) + + def end(self): + return _wedpr_python_transport.StringVec_end(self) + + def rbegin(self): + return _wedpr_python_transport.StringVec_rbegin(self) + + def rend(self): + return _wedpr_python_transport.StringVec_rend(self) + + def clear(self): + return _wedpr_python_transport.StringVec_clear(self) + + def get_allocator(self): + return _wedpr_python_transport.StringVec_get_allocator(self) + + def pop_back(self): + return _wedpr_python_transport.StringVec_pop_back(self) + + def erase(self, *args): + return _wedpr_python_transport.StringVec_erase(self, *args) + + def __init__(self, *args): + _wedpr_python_transport.StringVec_swiginit( + self, _wedpr_python_transport.new_StringVec(*args)) + + def push_back(self, x): + return _wedpr_python_transport.StringVec_push_back(self, x) + + def front(self): + return _wedpr_python_transport.StringVec_front(self) + + def back(self): + return _wedpr_python_transport.StringVec_back(self) + + def assign(self, n, x): + return _wedpr_python_transport.StringVec_assign(self, n, x) + + def resize(self, *args): + return _wedpr_python_transport.StringVec_resize(self, *args) + + def insert(self, *args): + return _wedpr_python_transport.StringVec_insert(self, *args) + + def reserve(self, n): + return _wedpr_python_transport.StringVec_reserve(self, n) + + def capacity(self): + return _wedpr_python_transport.StringVec_capacity(self) + __swig_destroy__ = _wedpr_python_transport.delete_StringVec + + +# Register StringVec in _wedpr_python_transport: +_wedpr_python_transport.StringVec_swigregister(StringVec) + + class Error(object): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") @@ -1505,6 +1616,9 @@ def registerComponent(self, component): def unRegisterComponent(self, component): return _wedpr_python_transport.IFront_unRegisterComponent(self, component) + def selectNodesByRoutePolicy(self, routeType, routeInfo): + return _wedpr_python_transport.IFront_selectNodesByRoutePolicy(self, routeType, routeInfo) + # Register IFront in _wedpr_python_transport: _wedpr_python_transport.IFront_swigregister(IFront) diff --git a/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/message_impl.py b/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/message_impl.py index 51a8ef65..aec2cfc5 100644 --- a/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/message_impl.py +++ b/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/message_impl.py @@ -62,6 +62,9 @@ def get_topic(self) -> str: def detail(self) -> str: return f"version: {self.get_version()}, topic: {self.get_topic()}, src_inst: {self.get_src_inst()},src_node: {str(self.get_src_node())}, dst_inst: {self.get_dst_inst()}, dst_node: {str(self.get_dst_node())}" + def __repr__(self): + return self.detail() + class MessageImpl(MessageAPI): def __init__(self, message: Message): @@ -85,3 +88,6 @@ def get_length(self) -> int: def detail(self) -> str: return f"seq: {self.get_seq()}, header: {self.get_header().detail()}, length: {self.get_length()}" + + def __repr__(self): + return self.detail() diff --git a/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/transport.py b/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/transport.py index 4dc843e0..2de8ba0d 100644 --- a/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/transport.py +++ b/cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/transport.py @@ -2,6 +2,7 @@ from wedpr_python_gateway_sdk.transport.generated.wedpr_python_transport import TransportBuilder from wedpr_python_gateway_sdk.transport.generated.wedpr_python_transport import Transport +from wedpr_python_gateway_sdk.transport.generated.wedpr_python_transport import StringVec from wedpr_python_gateway_sdk.transport.generated.wedpr_python_transport import Error from wedpr_python_gateway_sdk.transport.api.message_api import MessageAPI from wedpr_python_gateway_sdk.transport.impl.route_info_builder import RouteInfoBuilder @@ -9,6 +10,7 @@ from wedpr_python_gateway_sdk.transport.generated.wedpr_python_transport import MessageOptionalHeader from wedpr_python_gateway_sdk.transport.api.transport_api import TransportAPI from wedpr_python_gateway_sdk.transport.impl.transport_config import TransportConfig +import random from enum import Enum import signal @@ -45,6 +47,26 @@ def _push_msg(self, route_type: int, route_info: MessageOptionalHeader, payload: except Exception as e: raise e + def select_node_list_by_route_policy(self, route_type: RouteType, dst_inst: str, dst_component: str, dst_node: str = None) -> tuple: + dst_node_bytes = None + if dst_node is not None: + dst_node_bytes = bytes(dst_node, encodings="utf-8") + route_info = self.__route_info_builder.build(topic=None, dst_inst=dst_inst, + component=dst_component, dst_node=dst_node_bytes) + try: + return self.__transport.getFront().selectNodesByRoutePolicy( + route_type.value, route_info) + except Exception as e: + raise e + + def select_node_by_route_policy(self, route_type: RouteType, dst_inst: str, dst_component: str, dst_node: str = None) -> str: + node_list = self.select_node_list_by_route_policy( + route_type, dst_inst, dst_component, dst_node) + if node_list is None or len(node_list) == 0: + return None + selected_node_idx = random.randint(0, len(node_list) - 1) + return node_list[selected_node_idx] + def push_by_nodeid(self, topic: str, dstNode: bytes, seq: int, payload: bytes, timeout: int): route_info = self.__route_info_builder.build( topic=topic, dst_node=dstNode, dst_inst=None, component=None) diff --git a/cpp/wedpr-transport/sdk-wrapper/python/src/wedpr_python_transportPYTHON_wrap.cxx b/cpp/wedpr-transport/sdk-wrapper/python/src/wedpr_python_transportPYTHON_wrap.cxx index 12d60c03..fef8030e 100644 --- a/cpp/wedpr-transport/sdk-wrapper/python/src/wedpr_python_transportPYTHON_wrap.cxx +++ b/cpp/wedpr-transport/sdk-wrapper/python/src/wedpr_python_transportPYTHON_wrap.cxx @@ -3692,48 +3692,49 @@ namespace Swig { #define SWIGTYPE_p_signed_char swig_types[44] #define SWIGTYPE_p_size_type swig_types[45] #define SWIGTYPE_p_std__allocatorT_signed_char_t swig_types[46] -#define SWIGTYPE_p_std__allocatorT_unsigned_char_t swig_types[47] -#define SWIGTYPE_p_std__exception swig_types[48] -#define SWIGTYPE_p_std__functionT_void_fF_t swig_types[49] -#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_bcos__Error_tF_t swig_types[50] -#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_bcos__Error_t_std__shared_ptrT_ppc__protocol__Message_t_std__functionT_void_fstd__shared_ptrT_bcos__bytes_t_RRF_tF_t swig_types[51] -#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_bcos__bytes_t_RRF_t swig_types[52] -#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_ppc__protocol__Message_tF_t swig_types[53] -#define SWIGTYPE_p_std__invalid_argument swig_types[54] -#define SWIGTYPE_p_std__shared_ptrT_bcos__Error_t swig_types[55] -#define SWIGTYPE_p_std__shared_ptrT_bcos__bytes_t swig_types[56] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__ErrorCallback_t swig_types[57] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__FrontConfigBuilder_t swig_types[58] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__FrontConfig_t swig_types[59] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__GetPeersInfoHandler_t swig_types[60] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__IFrontClient_t swig_types[61] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__IFront_t swig_types[62] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__IMessageHandler_t swig_types[63] -#define SWIGTYPE_p_std__shared_ptrT_ppc__front__MessageDispatcherHandler_t swig_types[64] -#define SWIGTYPE_p_std__shared_ptrT_ppc__gateway__IGateway_t swig_types[65] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__GrpcConfig_t swig_types[66] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageBuilder_t swig_types[67] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageHeaderBuilder_t swig_types[68] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageHeader_t swig_types[69] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageOptionalHeaderBuilder_t swig_types[70] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageOptionalHeader_t swig_types[71] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessagePayloadBuilder_t swig_types[72] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessagePayload_t swig_types[73] -#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__Message_t swig_types[74] -#define SWIGTYPE_p_std__shared_ptrT_ppc__sdk__Transport_t swig_types[75] -#define SWIGTYPE_p_std__string swig_types[76] -#define SWIGTYPE_p_std__string_view swig_types[77] -#define SWIGTYPE_p_std__vectorT_int8_t_t swig_types[78] -#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[79] -#define SWIGTYPE_p_std__vectorT_uint8_t_t swig_types[80] -#define SWIGTYPE_p_swig__SwigPyIterator swig_types[81] -#define SWIGTYPE_p_unsigned_char swig_types[82] -#define SWIGTYPE_p_unsigned_int swig_types[83] -#define SWIGTYPE_p_unsigned_long_long swig_types[84] -#define SWIGTYPE_p_unsigned_short swig_types[85] -#define SWIGTYPE_p_value_type swig_types[86] -static swig_type_info *swig_types[88]; -static swig_module_info swig_module = {swig_types, 87, 0, 0, 0, 0}; +#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[47] +#define SWIGTYPE_p_std__allocatorT_unsigned_char_t swig_types[48] +#define SWIGTYPE_p_std__exception swig_types[49] +#define SWIGTYPE_p_std__functionT_void_fF_t swig_types[50] +#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_bcos__Error_tF_t swig_types[51] +#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_bcos__Error_t_std__shared_ptrT_ppc__protocol__Message_t_std__functionT_void_fstd__shared_ptrT_bcos__bytes_t_RRF_tF_t swig_types[52] +#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_bcos__bytes_t_RRF_t swig_types[53] +#define SWIGTYPE_p_std__functionT_void_fstd__shared_ptrT_ppc__protocol__Message_tF_t swig_types[54] +#define SWIGTYPE_p_std__invalid_argument swig_types[55] +#define SWIGTYPE_p_std__shared_ptrT_bcos__Error_t swig_types[56] +#define SWIGTYPE_p_std__shared_ptrT_bcos__bytes_t swig_types[57] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__ErrorCallback_t swig_types[58] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__FrontConfigBuilder_t swig_types[59] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__FrontConfig_t swig_types[60] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__GetPeersInfoHandler_t swig_types[61] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__IFrontClient_t swig_types[62] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__IFront_t swig_types[63] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__IMessageHandler_t swig_types[64] +#define SWIGTYPE_p_std__shared_ptrT_ppc__front__MessageDispatcherHandler_t swig_types[65] +#define SWIGTYPE_p_std__shared_ptrT_ppc__gateway__IGateway_t swig_types[66] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__GrpcConfig_t swig_types[67] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageBuilder_t swig_types[68] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageHeaderBuilder_t swig_types[69] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageHeader_t swig_types[70] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageOptionalHeaderBuilder_t swig_types[71] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageOptionalHeader_t swig_types[72] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessagePayloadBuilder_t swig_types[73] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessagePayload_t swig_types[74] +#define SWIGTYPE_p_std__shared_ptrT_ppc__protocol__Message_t swig_types[75] +#define SWIGTYPE_p_std__shared_ptrT_ppc__sdk__Transport_t swig_types[76] +#define SWIGTYPE_p_std__string swig_types[77] +#define SWIGTYPE_p_std__string_view swig_types[78] +#define SWIGTYPE_p_std__vectorT_int8_t_t swig_types[79] +#define SWIGTYPE_p_std__vectorT_std__string_t swig_types[80] +#define SWIGTYPE_p_std__vectorT_uint8_t_t swig_types[81] +#define SWIGTYPE_p_swig__SwigPyIterator swig_types[82] +#define SWIGTYPE_p_unsigned_char swig_types[83] +#define SWIGTYPE_p_unsigned_int swig_types[84] +#define SWIGTYPE_p_unsigned_long_long swig_types[85] +#define SWIGTYPE_p_unsigned_short swig_types[86] +#define SWIGTYPE_p_value_type swig_types[87] +static swig_type_info *swig_types[89]; +static swig_module_info swig_module = {swig_types, 88, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -5869,25 +5870,6 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char **cptr, size_t *psize, int *alloc) } - - - -SWIGINTERN int -SWIG_AsVal_int (PyObject * obj, int *val) -{ - long v; - int res = SWIG_AsVal_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v < INT_MIN || v > INT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = static_cast< int >(v); - } - } - return res; -} - - SWIGINTERN int SWIG_AsPtr_std_string (PyObject * obj, std::string **val) { @@ -5919,17 +5901,22 @@ SWIG_AsPtr_std_string (PyObject * obj, std::string **val) } -struct SWIG_null_deleter { - void operator() (void const *) const { +SWIGINTERN int +SWIG_AsVal_std_string (PyObject * obj, std::string *val) +{ + std::string* v = (std::string *) 0; + int res = SWIG_AsPtr_std_string (obj, &v); + if (!SWIG_IsOK(res)) return res; + if (v) { + if (val) *val = *v; + if (SWIG_IsNewObj(res)) { + delete v; + res = SWIG_DelNewMask(res); + } + return res; } -}; -#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() -#define SWIG_NO_NULL_DELETER_1 -#define SWIG_NO_NULL_DELETER_SWIG_POINTER_NEW -#define SWIG_NO_NULL_DELETER_SWIG_POINTER_OWN - - -#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT + return SWIG_ERROR; +} SWIGINTERNINLINE PyObject * @@ -5964,6 +5951,159 @@ SWIG_From_std_string (const std::string& s) } +namespace swig { + template <> struct traits< std::string > { + typedef value_category category; + static const char* type_name() { return"std::string"; } + }; + template <> struct traits_asval< std::string > { + typedef std::string value_type; + static int asval(PyObject *obj, value_type *val) { + return SWIG_AsVal_std_string (obj, val); + } + }; + template <> struct traits_from< std::string > { + typedef std::string value_type; + static PyObject *from(const value_type& val) { + return SWIG_From_std_string (val); + } + }; +} + + + namespace swig { + template <> struct traits > > { + typedef pointer_category category; + static const char* type_name() { + return "std::vector<" "std::string" "," "std::allocator< std::string >" " >"; + } + }; + } + +SWIGINTERN swig::SwigPyIterator *std_vector_Sl_std_string_Sg__iterator(std::vector< std::string > *self,PyObject **PYTHON_SELF){ + return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } +SWIGINTERN bool std_vector_Sl_std_string_Sg____nonzero__(std::vector< std::string > const *self){ + return !(self->empty()); + } +SWIGINTERN bool std_vector_Sl_std_string_Sg____bool__(std::vector< std::string > const *self){ + return !(self->empty()); + } +SWIGINTERN std::vector< std::string >::size_type std_vector_Sl_std_string_Sg____len__(std::vector< std::string > const *self){ + return self->size(); + } +SWIGINTERN std::vector< std::string,std::allocator< std::string > > *std_vector_Sl_std_string_Sg____getslice__(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::difference_type j){ + return swig::getslice(self, i, j, 1); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____setslice____SWIG_0(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::difference_type j){ + swig::setslice(self, i, j, 1, std::vector< std::string,std::allocator< std::string > >()); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____setslice____SWIG_1(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::difference_type j,std::vector< std::string,std::allocator< std::string > > const &v){ + swig::setslice(self, i, j, 1, v); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____delslice__(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::difference_type j){ + swig::delslice(self, i, j, 1); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____delitem____SWIG_0(std::vector< std::string > *self,std::vector< std::string >::difference_type i){ + swig::erase(self, swig::getpos(self, i)); + } +SWIGINTERN std::vector< std::string,std::allocator< std::string > > *std_vector_Sl_std_string_Sg____getitem____SWIG_0(std::vector< std::string > *self,SWIGPY_SLICEOBJECT *slice){ + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return NULL; + } + PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); + std::vector< std::string,std::allocator< std::string > >::difference_type id = i; + std::vector< std::string,std::allocator< std::string > >::difference_type jd = j; + return swig::getslice(self, id, jd, step); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____setitem____SWIG_0(std::vector< std::string > *self,SWIGPY_SLICEOBJECT *slice,std::vector< std::string,std::allocator< std::string > > const &v){ + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); + std::vector< std::string,std::allocator< std::string > >::difference_type id = i; + std::vector< std::string,std::allocator< std::string > >::difference_type jd = j; + swig::setslice(self, id, jd, step, v); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____setitem____SWIG_1(std::vector< std::string > *self,SWIGPY_SLICEOBJECT *slice){ + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); + std::vector< std::string,std::allocator< std::string > >::difference_type id = i; + std::vector< std::string,std::allocator< std::string > >::difference_type jd = j; + swig::delslice(self, id, jd, step); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____delitem____SWIG_1(std::vector< std::string > *self,SWIGPY_SLICEOBJECT *slice){ + Py_ssize_t i, j, step; + if( !PySlice_Check(slice) ) { + SWIG_Error(SWIG_TypeError, "Slice object expected."); + return; + } + PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); + std::vector< std::string,std::allocator< std::string > >::difference_type id = i; + std::vector< std::string,std::allocator< std::string > >::difference_type jd = j; + swig::delslice(self, id, jd, step); + } +SWIGINTERN std::vector< std::string >::value_type const &std_vector_Sl_std_string_Sg____getitem____SWIG_1(std::vector< std::string > const *self,std::vector< std::string >::difference_type i){ + return *(swig::cgetpos(self, i)); + } +SWIGINTERN void std_vector_Sl_std_string_Sg____setitem____SWIG_2(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::value_type const &x){ + *(swig::getpos(self,i)) = x; + } +SWIGINTERN std::vector< std::string >::value_type std_vector_Sl_std_string_Sg__pop(std::vector< std::string > *self){ + if (self->size() == 0) + throw std::out_of_range("pop from empty container"); + std::vector< std::string,std::allocator< std::string > >::value_type x = self->back(); + self->pop_back(); + return x; + } +SWIGINTERN void std_vector_Sl_std_string_Sg__append(std::vector< std::string > *self,std::vector< std::string >::value_type const &x){ + self->push_back(x); + } +SWIGINTERN std::vector< std::string >::iterator std_vector_Sl_std_string_Sg__erase__SWIG_0(std::vector< std::string > *self,std::vector< std::string >::iterator pos){ return self->erase(pos); } +SWIGINTERN std::vector< std::string >::iterator std_vector_Sl_std_string_Sg__erase__SWIG_1(std::vector< std::string > *self,std::vector< std::string >::iterator first,std::vector< std::string >::iterator last){ return self->erase(first, last); } +SWIGINTERN std::vector< std::string >::iterator std_vector_Sl_std_string_Sg__insert__SWIG_0(std::vector< std::string > *self,std::vector< std::string >::iterator pos,std::vector< std::string >::value_type const &x){ return self->insert(pos, x); } +SWIGINTERN void std_vector_Sl_std_string_Sg__insert__SWIG_1(std::vector< std::string > *self,std::vector< std::string >::iterator pos,std::vector< std::string >::size_type n,std::vector< std::string >::value_type const &x){ self->insert(pos, n, x); } + + + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + + +struct SWIG_null_deleter { + void operator() (void const *) const { + } +}; +#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() +#define SWIG_NO_NULL_DELETER_1 +#define SWIG_NO_NULL_DELETER_SWIG_POINTER_NEW +#define SWIG_NO_NULL_DELETER_SWIG_POINTER_OWN + + +#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT + + SWIGINTERN int SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) { @@ -6018,6 +6158,22 @@ SWIGINTERNINLINE PyObject* } +SWIGINTERN int +SWIG_AsVal_short (PyObject * obj, short *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < SHRT_MIN || v > SHRT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< short >(v); + } + } + return res; +} + + /* --------------------------------------------------- * C++ director class methods @@ -11506,96 +11662,1990 @@ SWIGINTERN PyObject *_wrap_ibytes_back(PyObject *self, PyObject *args) { } -SWIGINTERN PyObject *_wrap_ibytes_assign(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_ibytes_assign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + std::vector< signed char >::size_type arg2 ; + std::vector< signed char >::value_type *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + std::vector< signed char >::value_type temp3 ; + signed char val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "ibytes_assign", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_assign" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + } + arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ibytes_assign" "', argument " "2"" of type '" "std::vector< signed char >::size_type""'"); + } + arg2 = static_cast< std::vector< signed char >::size_type >(val2); + ecode3 = SWIG_AsVal_signed_SS_char(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_assign" "', argument " "3"" of type '" "std::vector< signed char >::value_type""'"); + } + temp3 = static_cast< std::vector< signed char >::value_type >(val3); + arg3 = &temp3; + (arg1)->assign(arg2,(std::vector< signed char >::value_type const &)*arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ibytes_resize__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + std::vector< signed char >::size_type arg2 ; + std::vector< signed char >::value_type *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + std::vector< signed char >::value_type temp3 ; + signed char val3 ; + int ecode3 = 0 ; + + (void)self; + if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_resize" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + } + arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ibytes_resize" "', argument " "2"" of type '" "std::vector< signed char >::size_type""'"); + } + arg2 = static_cast< std::vector< signed char >::size_type >(val2); + ecode3 = SWIG_AsVal_signed_SS_char(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_resize" "', argument " "3"" of type '" "std::vector< signed char >::value_type""'"); + } + temp3 = static_cast< std::vector< signed char >::value_type >(val3); + arg3 = &temp3; + (arg1)->resize(arg2,(std::vector< signed char >::value_type const &)*arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ibytes_resize(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[4] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "ibytes_resize", 0, 3, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_ibytes_resize__SWIG_0(self, argc, argv); + } + } + } + if (argc == 3) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_signed_SS_char(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_ibytes_resize__SWIG_1(self, argc, argv); + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'ibytes_resize'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< int8_t >::resize(std::vector< signed char >::size_type)\n" + " std::vector< int8_t >::resize(std::vector< signed char >::size_type,std::vector< signed char >::value_type const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_ibytes_insert__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + SwigValueWrapper< std::vector< signed char >::iterator > arg2 ; + std::vector< signed char >::value_type *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + swig::SwigPyIterator *iter2 = 0 ; + int res2 ; + std::vector< signed char >::value_type temp3 ; + signed char val3 ; + int ecode3 = 0 ; + SwigValueWrapper< std::vector< signed char >::iterator > result; + + (void)self; + if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_insert" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + } + arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0); + if (!SWIG_IsOK(res2) || !iter2) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + } else { + swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); + if (iter_t) { + arg2 = iter_t->get_current(); + } else { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + } + } + ecode3 = SWIG_AsVal_signed_SS_char(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_insert" "', argument " "3"" of type '" "std::vector< signed char >::value_type""'"); + } + temp3 = static_cast< std::vector< signed char >::value_type >(val3); + arg3 = &temp3; + result = std_vector_Sl_int8_t_Sg__insert__SWIG_0(arg1,SWIG_STD_MOVE(arg2),(signed char const &)*arg3); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< signed char >::iterator & >(result)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ibytes_insert__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + SwigValueWrapper< std::vector< signed char >::iterator > arg2 ; + std::vector< signed char >::size_type arg3 ; + std::vector< signed char >::value_type *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + swig::SwigPyIterator *iter2 = 0 ; + int res2 ; + size_t val3 ; + int ecode3 = 0 ; + std::vector< signed char >::value_type temp4 ; + signed char val4 ; + int ecode4 = 0 ; + + (void)self; + if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_insert" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + } + arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0); + if (!SWIG_IsOK(res2) || !iter2) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + } else { + swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); + if (iter_t) { + arg2 = iter_t->get_current(); + } else { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + } + } + ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_insert" "', argument " "3"" of type '" "std::vector< signed char >::size_type""'"); + } + arg3 = static_cast< std::vector< signed char >::size_type >(val3); + ecode4 = SWIG_AsVal_signed_SS_char(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ibytes_insert" "', argument " "4"" of type '" "std::vector< signed char >::value_type""'"); + } + temp4 = static_cast< std::vector< signed char >::value_type >(val4); + arg4 = &temp4; + std_vector_Sl_int8_t_Sg__insert__SWIG_1(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3),(signed char const &)*arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ibytes_insert(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[5] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "ibytes_insert", 0, 4, argv))) SWIG_fail; + --argc; + if (argc == 3) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + swig::SwigPyIterator *iter = 0; + int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); + if (_v) { + { + int res = SWIG_AsVal_signed_SS_char(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_ibytes_insert__SWIG_0(self, argc, argv); + } + } + } + } + if (argc == 4) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + swig::SwigPyIterator *iter = 0; + int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_signed_SS_char(argv[3], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_ibytes_insert__SWIG_1(self, argc, argv); + } + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'ibytes_insert'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< int8_t >::insert(std::vector< signed char >::iterator,std::vector< signed char >::value_type const &)\n" + " std::vector< int8_t >::insert(std::vector< signed char >::iterator,std::vector< signed char >::size_type,std::vector< signed char >::value_type const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_ibytes_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + std::vector< signed char >::size_type arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "ibytes_reserve", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_reserve" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + } + arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ibytes_reserve" "', argument " "2"" of type '" "std::vector< signed char >::size_type""'"); + } + arg2 = static_cast< std::vector< signed char >::size_type >(val2); + (arg1)->reserve(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ibytes_capacity(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< signed char >::size_type result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_capacity" "', argument " "1"" of type '" "std::vector< int8_t > const *""'"); + } + arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + result = ((std::vector< int8_t > const *)arg1)->capacity(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_ibytes(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ibytes" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + } + arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + delete arg1; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ibytes_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_int8_t_t, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *ibytes_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_StringVec_iterator(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + PyObject **arg2 = (PyObject **) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + swig::SwigPyIterator *result = 0 ; + + arg2 = &swig_obj[0]; + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_iterator" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (swig::SwigPyIterator *)std_vector_Sl_std_string_Sg__iterator(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___nonzero__(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + bool result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___nonzero__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (bool)std_vector_Sl_std_string_Sg____nonzero__((std::vector< std::string > const *)arg1); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___bool__(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + bool result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___bool__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (bool)std_vector_Sl_std_string_Sg____bool__((std::vector< std::string > const *)arg1); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___len__(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::size_type result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___len__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = std_vector_Sl_std_string_Sg____len__((std::vector< std::string > const *)arg1); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___getslice__(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::difference_type arg2 ; + std::vector< std::string >::difference_type arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + ptrdiff_t val2 ; + int ecode2 = 0 ; + ptrdiff_t val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + std::vector< std::string,std::allocator< std::string > > *result = 0 ; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "StringVec___getslice__", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___getslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_ptrdiff_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec___getslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg2 = static_cast< std::vector< std::string >::difference_type >(val2); + ecode3 = SWIG_AsVal_ptrdiff_t(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVec___getslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg3 = static_cast< std::vector< std::string >::difference_type >(val3); + try { + result = (std::vector< std::string,std::allocator< std::string > > *)std_vector_Sl_std_string_Sg____getslice__(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3)); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___setslice____SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::difference_type arg2 ; + std::vector< std::string >::difference_type arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + ptrdiff_t val2 ; + int ecode2 = 0 ; + ptrdiff_t val3 ; + int ecode3 = 0 ; + + (void)self; + if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___setslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_ptrdiff_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec___setslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg2 = static_cast< std::vector< std::string >::difference_type >(val2); + ecode3 = SWIG_AsVal_ptrdiff_t(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVec___setslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg3 = static_cast< std::vector< std::string >::difference_type >(val3); + try { + std_vector_Sl_std_string_Sg____setslice____SWIG_0(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3)); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___setslice____SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::difference_type arg2 ; + std::vector< std::string >::difference_type arg3 ; + std::vector< std::string,std::allocator< std::string > > *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + ptrdiff_t val2 ; + int ecode2 = 0 ; + ptrdiff_t val3 ; + int ecode3 = 0 ; + int res4 = SWIG_OLDOBJ ; + + (void)self; + if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___setslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_ptrdiff_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec___setslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg2 = static_cast< std::vector< std::string >::difference_type >(val2); + ecode3 = SWIG_AsVal_ptrdiff_t(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVec___setslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg3 = static_cast< std::vector< std::string >::difference_type >(val3); + { + std::vector< std::string,std::allocator< std::string > > *ptr = (std::vector< std::string,std::allocator< std::string > > *)0; + res4 = swig::asptr(swig_obj[3], &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringVec___setslice__" "', argument " "4"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec___setslice__" "', argument " "4"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); + } + arg4 = ptr; + } + try { + std_vector_Sl_std_string_Sg____setslice____SWIG_1(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3),(std::vector< std::string,std::allocator< std::string > > const &)*arg4); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res4)) delete arg4; + return resultobj; +fail: + if (SWIG_IsNewObj(res4)) delete arg4; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___setslice__(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[5] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "StringVec___setslice__", 0, 4, argv))) SWIG_fail; + --argc; + if (argc == 3) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_StringVec___setslice____SWIG_0(self, argc, argv); + } + } + } + } + if (argc == 4) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + { + int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = swig::asptr(argv[3], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_StringVec___setslice____SWIG_1(self, argc, argv); + } + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'StringVec___setslice__'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< std::string >::__setslice__(std::vector< std::string >::difference_type,std::vector< std::string >::difference_type)\n" + " std::vector< std::string >::__setslice__(std::vector< std::string >::difference_type,std::vector< std::string >::difference_type,std::vector< std::string,std::allocator< std::string > > const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_StringVec___delslice__(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::difference_type arg2 ; + std::vector< std::string >::difference_type arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + ptrdiff_t val2 ; + int ecode2 = 0 ; + ptrdiff_t val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "StringVec___delslice__", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___delslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_ptrdiff_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec___delslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg2 = static_cast< std::vector< std::string >::difference_type >(val2); + ecode3 = SWIG_AsVal_ptrdiff_t(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVec___delslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg3 = static_cast< std::vector< std::string >::difference_type >(val3); + try { + std_vector_Sl_std_string_Sg____delslice__(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3)); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___delitem____SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::difference_type arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + ptrdiff_t val2 ; + int ecode2 = 0 ; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___delitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_ptrdiff_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec___delitem__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg2 = static_cast< std::vector< std::string >::difference_type >(val2); + try { + std_vector_Sl_std_string_Sg____delitem____SWIG_0(arg1,SWIG_STD_MOVE(arg2)); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___getitem____SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + SWIGPY_SLICEOBJECT *arg2 = (SWIGPY_SLICEOBJECT *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + std::vector< std::string,std::allocator< std::string > > *result = 0 ; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___getitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + { + if (!PySlice_Check(swig_obj[1])) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec___getitem__" "', argument " "2"" of type '" "SWIGPY_SLICEOBJECT *""'"); + } + arg2 = (SWIGPY_SLICEOBJECT *) swig_obj[1]; + } + try { + result = (std::vector< std::string,std::allocator< std::string > > *)std_vector_Sl_std_string_Sg____getitem____SWIG_0(arg1,arg2); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___setitem____SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + SWIGPY_SLICEOBJECT *arg2 = (SWIGPY_SLICEOBJECT *) 0 ; + std::vector< std::string,std::allocator< std::string > > *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res3 = SWIG_OLDOBJ ; + + (void)self; + if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___setitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + { + if (!PySlice_Check(swig_obj[1])) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec___setitem__" "', argument " "2"" of type '" "SWIGPY_SLICEOBJECT *""'"); + } + arg2 = (SWIGPY_SLICEOBJECT *) swig_obj[1]; + } + { + std::vector< std::string,std::allocator< std::string > > *ptr = (std::vector< std::string,std::allocator< std::string > > *)0; + res3 = swig::asptr(swig_obj[2], &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVec___setitem__" "', argument " "3"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec___setitem__" "', argument " "3"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); + } + arg3 = ptr; + } + try { + std_vector_Sl_std_string_Sg____setitem____SWIG_0(arg1,arg2,(std::vector< std::string,std::allocator< std::string > > const &)*arg3); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res3)) delete arg3; + return resultobj; +fail: + if (SWIG_IsNewObj(res3)) delete arg3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___setitem____SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + SWIGPY_SLICEOBJECT *arg2 = (SWIGPY_SLICEOBJECT *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___setitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + { + if (!PySlice_Check(swig_obj[1])) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec___setitem__" "', argument " "2"" of type '" "SWIGPY_SLICEOBJECT *""'"); + } + arg2 = (SWIGPY_SLICEOBJECT *) swig_obj[1]; + } + try { + std_vector_Sl_std_string_Sg____setitem____SWIG_1(arg1,arg2); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___delitem____SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + SWIGPY_SLICEOBJECT *arg2 = (SWIGPY_SLICEOBJECT *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___delitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + { + if (!PySlice_Check(swig_obj[1])) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec___delitem__" "', argument " "2"" of type '" "SWIGPY_SLICEOBJECT *""'"); + } + arg2 = (SWIGPY_SLICEOBJECT *) swig_obj[1]; + } + try { + std_vector_Sl_std_string_Sg____delitem____SWIG_1(arg1,arg2); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } catch(std::invalid_argument &_e) { + SWIG_exception_fail(SWIG_ValueError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___delitem__(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "StringVec___delitem__", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + _v = PySlice_Check(argv[1]); + } + if (_v) { + return _wrap_StringVec___delitem____SWIG_1(self, argc, argv); + } + } + } + if (argc == 2) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_StringVec___delitem____SWIG_0(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'StringVec___delitem__'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< std::string >::__delitem__(std::vector< std::string >::difference_type)\n" + " std::vector< std::string >::__delitem__(SWIGPY_SLICEOBJECT *)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_StringVec___getitem____SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::difference_type arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + ptrdiff_t val2 ; + int ecode2 = 0 ; + std::vector< std::string >::value_type *result = 0 ; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___getitem__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_ptrdiff_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec___getitem__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg2 = static_cast< std::vector< std::string >::difference_type >(val2); + try { + result = (std::vector< std::string >::value_type *) &std_vector_Sl_std_string_Sg____getitem____SWIG_1((std::vector< std::string > const *)arg1,SWIG_STD_MOVE(arg2)); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + (void)swig::container_owner::value_type>::category>::back_reference(resultobj, swig_obj[0]); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___getitem__(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "StringVec___getitem__", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + _v = PySlice_Check(argv[1]); + } + if (_v) { + return _wrap_StringVec___getitem____SWIG_0(self, argc, argv); + } + } + } + if (argc == 2) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_StringVec___getitem____SWIG_1(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'StringVec___getitem__'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< std::string >::__getitem__(SWIGPY_SLICEOBJECT *)\n" + " std::vector< std::string >::__getitem__(std::vector< std::string >::difference_type) const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_StringVec___setitem____SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::difference_type arg2 ; + std::vector< std::string >::value_type *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + ptrdiff_t val2 ; + int ecode2 = 0 ; + int res3 = SWIG_OLDOBJ ; + + (void)self; + if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec___setitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_ptrdiff_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec___setitem__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'"); + } + arg2 = static_cast< std::vector< std::string >::difference_type >(val2); + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(swig_obj[2], &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVec___setitem__" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec___setitem__" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg3 = ptr; + } + try { + std_vector_Sl_std_string_Sg____setitem____SWIG_2(arg1,SWIG_STD_MOVE(arg2),(std::string const &)*arg3); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res3)) delete arg3; + return resultobj; +fail: + if (SWIG_IsNewObj(res3)) delete arg3; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec___setitem__(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[4] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "StringVec___setitem__", 0, 3, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + _v = PySlice_Check(argv[1]); + } + if (_v) { + return _wrap_StringVec___setitem____SWIG_1(self, argc, argv); + } + } + } + if (argc == 3) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + _v = PySlice_Check(argv[1]); + } + if (_v) { + int res = swig::asptr(argv[2], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_StringVec___setitem____SWIG_0(self, argc, argv); + } + } + } + } + if (argc == 3) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_StringVec___setitem____SWIG_2(self, argc, argv); + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'StringVec___setitem__'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< std::string >::__setitem__(SWIGPY_SLICEOBJECT *,std::vector< std::string,std::allocator< std::string > > const &)\n" + " std::vector< std::string >::__setitem__(SWIGPY_SLICEOBJECT *)\n" + " std::vector< std::string >::__setitem__(std::vector< std::string >::difference_type,std::vector< std::string >::value_type const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_StringVec_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::value_type result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_pop" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + try { + result = std_vector_Sl_std_string_Sg__pop(arg1); + } catch(std::out_of_range &_e) { + SWIG_exception_fail(SWIG_IndexError, (&_e)->what()); + } + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_append(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::value_type *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject *swig_obj[2] ; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "StringVec_append", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_append" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(swig_obj[1], &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVec_append" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec_append" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg2 = ptr; + } + std_vector_Sl_std_string_Sg__append(arg1,(std::string const &)*arg2); + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_StringVec__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) { + PyObject *resultobj = 0; + std::vector< std::string > *result = 0 ; + + (void)self; + if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; + result = (std::vector< std::string > *)new std::vector< std::string >(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_StringVec__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = 0 ; + int res1 = SWIG_OLDOBJ ; + std::vector< std::string > *result = 0 ; + + (void)self; + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + { + std::vector< std::string,std::allocator< std::string > > *ptr = (std::vector< std::string,std::allocator< std::string > > *)0; + res1 = swig::asptr(swig_obj[0], &ptr); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringVec" "', argument " "1"" of type '" "std::vector< std::string > const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringVec" "', argument " "1"" of type '" "std::vector< std::string > const &""'"); + } + arg1 = ptr; + } + result = (std::vector< std::string > *)new std::vector< std::string >((std::vector< std::string > const &)*arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_t, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res1)) delete arg1; + return resultobj; +fail: + if (SWIG_IsNewObj(res1)) delete arg1; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_empty(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + bool result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_empty" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (bool)((std::vector< std::string > const *)arg1)->empty(); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::size_type result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_size" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = ((std::vector< std::string > const *)arg1)->size(); + resultobj = SWIG_From_size_t(static_cast< size_t >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_swap(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string > *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "StringVec_swap", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_swap" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__vectorT_std__string_t, 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVec_swap" "', argument " "2"" of type '" "std::vector< std::string > &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec_swap" "', argument " "2"" of type '" "std::vector< std::string > &""'"); + } + arg2 = reinterpret_cast< std::vector< std::string > * >(argp2); + (arg1)->swap(*arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_begin(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::iterator result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_begin" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (arg1)->begin(); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_end(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::iterator result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_end" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (arg1)->end(); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_rbegin(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::reverse_iterator result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_rbegin" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (arg1)->rbegin(); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::reverse_iterator & >(result)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_rend(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::reverse_iterator result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_rend" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (arg1)->rend(); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::reverse_iterator & >(result)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_clear(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_clear" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + (arg1)->clear(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_get_allocator(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SwigValueWrapper< std::allocator< std::string > > result; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_get_allocator" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = ((std::vector< std::string > const *)arg1)->get_allocator(); + resultobj = SWIG_NewPointerObj((new std::vector< std::string >::allocator_type(result)), SWIGTYPE_p_std__allocatorT_std__string_t, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_StringVec__SWIG_2(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string >::size_type arg1 ; + size_t val1 ; + int ecode1 = 0 ; + std::vector< std::string > *result = 0 ; + + (void)self; + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_StringVec" "', argument " "1"" of type '" "std::vector< std::string >::size_type""'"); + } + arg1 = static_cast< std::vector< std::string >::size_type >(val1); + result = (std::vector< std::string > *)new std::vector< std::string >(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_t, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_pop_back(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_pop_back" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + (arg1)->pop_back(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_resize__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::size_type arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_resize" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec_resize" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'"); + } + arg2 = static_cast< std::vector< std::string >::size_type >(val2); + (arg1)->resize(arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_erase__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::iterator arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + swig::SwigPyIterator *iter2 = 0 ; + int res2 ; + std::vector< std::string >::iterator result; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_erase" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0); + if (!SWIG_IsOK(res2) || !iter2) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); + } else { + swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); + if (iter_t) { + arg2 = iter_t->get_current(); + } else { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); + } + } + result = std_vector_Sl_std_string_Sg__erase__SWIG_0(arg1,SWIG_STD_MOVE(arg2)); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_erase__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::iterator arg2 ; + std::vector< std::string >::iterator arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + swig::SwigPyIterator *iter2 = 0 ; + int res2 ; + swig::SwigPyIterator *iter3 = 0 ; + int res3 ; + std::vector< std::string >::iterator result; + + (void)self; + if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_erase" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0); + if (!SWIG_IsOK(res2) || !iter2) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); + } else { + swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); + if (iter_t) { + arg2 = iter_t->get_current(); + } else { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); + } + } + res3 = SWIG_ConvertPtr(swig_obj[2], SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0); + if (!SWIG_IsOK(res3) || !iter3) { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_erase" "', argument " "3"" of type '" "std::vector< std::string >::iterator""'"); + } else { + swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter3); + if (iter_t) { + arg3 = iter_t->get_current(); + } else { + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_erase" "', argument " "3"" of type '" "std::vector< std::string >::iterator""'"); + } + } + result = std_vector_Sl_std_string_Sg__erase__SWIG_1(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3)); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)), + swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_erase(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[4] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "StringVec_erase", 0, 3, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + swig::SwigPyIterator *iter = 0; + int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); + if (_v) { + return _wrap_StringVec_erase__SWIG_0(self, argc, argv); + } + } + } + if (argc == 3) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + swig::SwigPyIterator *iter = 0; + int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); + if (_v) { + swig::SwigPyIterator *iter = 0; + int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); + if (_v) { + return _wrap_StringVec_erase__SWIG_1(self, argc, argv); + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'StringVec_erase'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< std::string >::erase(std::vector< std::string >::iterator)\n" + " std::vector< std::string >::erase(std::vector< std::string >::iterator,std::vector< std::string >::iterator)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_new_StringVec__SWIG_3(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + std::vector< std::string >::size_type arg1 ; + std::vector< std::string >::value_type *arg2 = 0 ; + size_t val1 ; + int ecode1 = 0 ; + int res2 = SWIG_OLDOBJ ; + std::vector< std::string > *result = 0 ; + + (void)self; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + ecode1 = SWIG_AsVal_size_t(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_StringVec" "', argument " "1"" of type '" "std::vector< std::string >::size_type""'"); + } + arg1 = static_cast< std::vector< std::string >::size_type >(val1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(swig_obj[1], &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_StringVec" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringVec" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg2 = ptr; + } + result = (std::vector< std::string > *)new std::vector< std::string >(arg1,(std::vector< std::string >::value_type const &)*arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_t, SWIG_POINTER_NEW | 0 ); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_StringVec(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "new_StringVec", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 0) { + return _wrap_new_StringVec__SWIG_0(self, argc, argv); + } + if (argc == 1) { + int _v = 0; + { + int res = SWIG_AsVal_size_t(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_new_StringVec__SWIG_2(self, argc, argv); + } + } + if (argc == 1) { + int _v = 0; + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_StringVec__SWIG_1(self, argc, argv); + } + } + if (argc == 2) { + int _v = 0; + { + int res = SWIG_AsVal_size_t(argv[0], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0)); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_StringVec__SWIG_3(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_StringVec'.\n" + " Possible C/C++ prototypes are:\n" + " std::vector< std::string >::vector()\n" + " std::vector< std::string >::vector(std::vector< std::string > const &)\n" + " std::vector< std::string >::vector(std::vector< std::string >::size_type)\n" + " std::vector< std::string >::vector(std::vector< std::string >::size_type,std::vector< std::string >::value_type const &)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_StringVec_push_back(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::value_type *arg2 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = SWIG_OLDOBJ ; + PyObject *swig_obj[2] ; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "StringVec_push_back", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_push_back" "', argument " "1"" of type '" "std::vector< std::string > *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + { + std::string *ptr = (std::string *)0; + res2 = SWIG_AsPtr_std_string(swig_obj[1], &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVec_push_back" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec_push_back" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg2 = ptr; + } + (arg1)->push_back((std::vector< std::string >::value_type const &)*arg2); + resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) delete arg2; + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_front(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::value_type *result = 0 ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_front" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (std::vector< std::string >::value_type *) &((std::vector< std::string > const *)arg1)->front(); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + (void)swig::container_owner::value_type>::category>::back_reference(resultobj, swig_obj[0]); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_back(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + std::vector< std::string >::value_type *result = 0 ; + + (void)self; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_back" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); + } + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = (std::vector< std::string >::value_type *) &((std::vector< std::string > const *)arg1)->back(); + resultobj = SWIG_From_std_string(static_cast< std::string >(*result)); + (void)swig::container_owner::value_type>::category>::back_reference(resultobj, swig_obj[0]); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_StringVec_assign(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; - std::vector< signed char >::size_type arg2 ; - std::vector< signed char >::value_type *arg3 = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::size_type arg2 ; + std::vector< std::string >::value_type *arg3 = 0 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; - std::vector< signed char >::value_type temp3 ; - signed char val3 ; - int ecode3 = 0 ; + int res3 = SWIG_OLDOBJ ; PyObject *swig_obj[3] ; (void)self; - if (!SWIG_Python_UnpackTuple(args, "ibytes_assign", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "StringVec_assign", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_assign" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_assign" "', argument " "1"" of type '" "std::vector< std::string > *""'"); } - arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ibytes_assign" "', argument " "2"" of type '" "std::vector< signed char >::size_type""'"); - } - arg2 = static_cast< std::vector< signed char >::size_type >(val2); - ecode3 = SWIG_AsVal_signed_SS_char(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_assign" "', argument " "3"" of type '" "std::vector< signed char >::value_type""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec_assign" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'"); } - temp3 = static_cast< std::vector< signed char >::value_type >(val3); - arg3 = &temp3; - (arg1)->assign(arg2,(std::vector< signed char >::value_type const &)*arg3); + arg2 = static_cast< std::vector< std::string >::size_type >(val2); + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(swig_obj[2], &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVec_assign" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec_assign" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg3 = ptr; + } + (arg1)->assign(arg2,(std::vector< std::string >::value_type const &)*arg3); resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res3)) delete arg3; return resultobj; fail: + if (SWIG_IsNewObj(res3)) delete arg3; return NULL; } -SWIGINTERN PyObject *_wrap_ibytes_resize__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_StringVec_resize__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; - std::vector< signed char >::size_type arg2 ; - std::vector< signed char >::value_type *arg3 = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::size_type arg2 ; + std::vector< std::string >::value_type *arg3 = 0 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; - std::vector< signed char >::value_type temp3 ; - signed char val3 ; - int ecode3 = 0 ; + int res3 = SWIG_OLDOBJ ; (void)self; if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_resize" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_resize" "', argument " "1"" of type '" "std::vector< std::string > *""'"); } - arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ibytes_resize" "', argument " "2"" of type '" "std::vector< signed char >::size_type""'"); - } - arg2 = static_cast< std::vector< signed char >::size_type >(val2); - ecode3 = SWIG_AsVal_signed_SS_char(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_resize" "', argument " "3"" of type '" "std::vector< signed char >::value_type""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec_resize" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'"); } - temp3 = static_cast< std::vector< signed char >::value_type >(val3); - arg3 = &temp3; - (arg1)->resize(arg2,(std::vector< signed char >::value_type const &)*arg3); + arg2 = static_cast< std::vector< std::string >::size_type >(val2); + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(swig_obj[2], &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVec_resize" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec_resize" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg3 = ptr; + } + (arg1)->resize(arg2,(std::vector< std::string >::value_type const &)*arg3); resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res3)) delete arg3; return resultobj; fail: + if (SWIG_IsNewObj(res3)) delete arg3; return NULL; } -SWIGINTERN PyObject *_wrap_ibytes_resize(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_StringVec_resize(PyObject *self, PyObject *args) { Py_ssize_t argc; PyObject *argv[4] = { 0 }; - if (!(argc = SWIG_Python_UnpackTuple(args, "ibytes_resize", 0, 3, argv))) SWIG_fail; + if (!(argc = SWIG_Python_UnpackTuple(args, "StringVec_resize", 0, 3, argv))) SWIG_fail; --argc; if (argc == 2) { int _v = 0; - int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); _v = SWIG_CheckState(res); if (_v) { { @@ -11603,13 +13653,13 @@ SWIGINTERN PyObject *_wrap_ibytes_resize(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); } if (_v) { - return _wrap_ibytes_resize__SWIG_0(self, argc, argv); + return _wrap_StringVec_resize__SWIG_0(self, argc, argv); } } } if (argc == 3) { int _v = 0; - int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); _v = SWIG_CheckState(res); if (_v) { { @@ -11617,173 +13667,177 @@ SWIGINTERN PyObject *_wrap_ibytes_resize(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); } if (_v) { - { - int res = SWIG_AsVal_signed_SS_char(argv[2], NULL); - _v = SWIG_CheckState(res); - } + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); if (_v) { - return _wrap_ibytes_resize__SWIG_1(self, argc, argv); + return _wrap_StringVec_resize__SWIG_1(self, argc, argv); } } } } fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'ibytes_resize'.\n" + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'StringVec_resize'.\n" " Possible C/C++ prototypes are:\n" - " std::vector< int8_t >::resize(std::vector< signed char >::size_type)\n" - " std::vector< int8_t >::resize(std::vector< signed char >::size_type,std::vector< signed char >::value_type const &)\n"); + " std::vector< std::string >::resize(std::vector< std::string >::size_type)\n" + " std::vector< std::string >::resize(std::vector< std::string >::size_type,std::vector< std::string >::value_type const &)\n"); return 0; } -SWIGINTERN PyObject *_wrap_ibytes_insert__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_StringVec_insert__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; - SwigValueWrapper< std::vector< signed char >::iterator > arg2 ; - std::vector< signed char >::value_type *arg3 = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::iterator arg2 ; + std::vector< std::string >::value_type *arg3 = 0 ; void *argp1 = 0 ; int res1 = 0 ; swig::SwigPyIterator *iter2 = 0 ; int res2 ; - std::vector< signed char >::value_type temp3 ; - signed char val3 ; - int ecode3 = 0 ; - SwigValueWrapper< std::vector< signed char >::iterator > result; + int res3 = SWIG_OLDOBJ ; + std::vector< std::string >::iterator result; (void)self; if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_insert" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_insert" "', argument " "1"" of type '" "std::vector< std::string > *""'"); } - arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[1], SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0); if (!SWIG_IsOK(res2) || !iter2) { - SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); } else { - swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); + swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); if (iter_t) { arg2 = iter_t->get_current(); } else { - SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); } } - ecode3 = SWIG_AsVal_signed_SS_char(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_insert" "', argument " "3"" of type '" "std::vector< signed char >::value_type""'"); - } - temp3 = static_cast< std::vector< signed char >::value_type >(val3); - arg3 = &temp3; - result = std_vector_Sl_int8_t_Sg__insert__SWIG_0(arg1,SWIG_STD_MOVE(arg2),(signed char const &)*arg3); - resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< signed char >::iterator & >(result)), + { + std::string *ptr = (std::string *)0; + res3 = SWIG_AsPtr_std_string(swig_obj[2], &ptr); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVec_insert" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec_insert" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg3 = ptr; + } + result = std_vector_Sl_std_string_Sg__insert__SWIG_0(arg1,SWIG_STD_MOVE(arg2),(std::string const &)*arg3); + resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)), swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + if (SWIG_IsNewObj(res3)) delete arg3; return resultobj; fail: + if (SWIG_IsNewObj(res3)) delete arg3; return NULL; } -SWIGINTERN PyObject *_wrap_ibytes_insert__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_StringVec_insert__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; - std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; - SwigValueWrapper< std::vector< signed char >::iterator > arg2 ; - std::vector< signed char >::size_type arg3 ; - std::vector< signed char >::value_type *arg4 = 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::iterator arg2 ; + std::vector< std::string >::size_type arg3 ; + std::vector< std::string >::value_type *arg4 = 0 ; void *argp1 = 0 ; int res1 = 0 ; swig::SwigPyIterator *iter2 = 0 ; int res2 ; size_t val3 ; int ecode3 = 0 ; - std::vector< signed char >::value_type temp4 ; - signed char val4 ; - int ecode4 = 0 ; + int res4 = SWIG_OLDOBJ ; (void)self; if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_insert" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_insert" "', argument " "1"" of type '" "std::vector< std::string > *""'"); } - arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); res2 = SWIG_ConvertPtr(swig_obj[1], SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0); if (!SWIG_IsOK(res2) || !iter2) { - SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); } else { - swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); + swig::SwigPyIterator_T::iterator > *iter_t = dynamic_cast::iterator > *>(iter2); if (iter_t) { arg2 = iter_t->get_current(); } else { - SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ibytes_insert" "', argument " "2"" of type '" "std::vector< signed char >::iterator""'"); + SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVec_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'"); } } ecode3 = SWIG_AsVal_size_t(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ibytes_insert" "', argument " "3"" of type '" "std::vector< signed char >::size_type""'"); + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVec_insert" "', argument " "3"" of type '" "std::vector< std::string >::size_type""'"); } - arg3 = static_cast< std::vector< signed char >::size_type >(val3); - ecode4 = SWIG_AsVal_signed_SS_char(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ibytes_insert" "', argument " "4"" of type '" "std::vector< signed char >::value_type""'"); - } - temp4 = static_cast< std::vector< signed char >::value_type >(val4); - arg4 = &temp4; - std_vector_Sl_int8_t_Sg__insert__SWIG_1(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3),(signed char const &)*arg4); + arg3 = static_cast< std::vector< std::string >::size_type >(val3); + { + std::string *ptr = (std::string *)0; + res4 = SWIG_AsPtr_std_string(swig_obj[3], &ptr); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringVec_insert" "', argument " "4"" of type '" "std::vector< std::string >::value_type const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVec_insert" "', argument " "4"" of type '" "std::vector< std::string >::value_type const &""'"); + } + arg4 = ptr; + } + std_vector_Sl_std_string_Sg__insert__SWIG_1(arg1,SWIG_STD_MOVE(arg2),SWIG_STD_MOVE(arg3),(std::string const &)*arg4); resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res4)) delete arg4; return resultobj; fail: + if (SWIG_IsNewObj(res4)) delete arg4; return NULL; } -SWIGINTERN PyObject *_wrap_ibytes_insert(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_StringVec_insert(PyObject *self, PyObject *args) { Py_ssize_t argc; PyObject *argv[5] = { 0 }; - if (!(argc = SWIG_Python_UnpackTuple(args, "ibytes_insert", 0, 4, argv))) SWIG_fail; + if (!(argc = SWIG_Python_UnpackTuple(args, "StringVec_insert", 0, 4, argv))) SWIG_fail; --argc; if (argc == 3) { int _v = 0; - int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); _v = SWIG_CheckState(res); if (_v) { swig::SwigPyIterator *iter = 0; int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); - _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); + _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); if (_v) { - { - int res = SWIG_AsVal_signed_SS_char(argv[2], NULL); - _v = SWIG_CheckState(res); - } + int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0)); + _v = SWIG_CheckState(res); if (_v) { - return _wrap_ibytes_insert__SWIG_0(self, argc, argv); + return _wrap_StringVec_insert__SWIG_0(self, argc, argv); } } } } if (argc == 4) { int _v = 0; - int res = swig::asptr(argv[0], (std::vector< signed char,std::allocator< signed char > >**)(0)); + int res = swig::asptr(argv[0], (std::vector< std::string,std::allocator< std::string > >**)(0)); _v = SWIG_CheckState(res); if (_v) { swig::SwigPyIterator *iter = 0; int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); - _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); + _v = (SWIG_IsOK(res) && iter && (dynamic_cast::iterator > *>(iter) != 0)); if (_v) { { int res = SWIG_AsVal_size_t(argv[2], NULL); _v = SWIG_CheckState(res); } if (_v) { - { - int res = SWIG_AsVal_signed_SS_char(argv[3], NULL); - _v = SWIG_CheckState(res); - } + int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0)); + _v = SWIG_CheckState(res); if (_v) { - return _wrap_ibytes_insert__SWIG_1(self, argc, argv); + return _wrap_StringVec_insert__SWIG_1(self, argc, argv); } } } @@ -11791,18 +13845,18 @@ SWIGINTERN PyObject *_wrap_ibytes_insert(PyObject *self, PyObject *args) { } fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'ibytes_insert'.\n" + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'StringVec_insert'.\n" " Possible C/C++ prototypes are:\n" - " std::vector< int8_t >::insert(std::vector< signed char >::iterator,std::vector< signed char >::value_type const &)\n" - " std::vector< int8_t >::insert(std::vector< signed char >::iterator,std::vector< signed char >::size_type,std::vector< signed char >::value_type const &)\n"); + " std::vector< std::string >::insert(std::vector< std::string >::iterator,std::vector< std::string >::value_type const &)\n" + " std::vector< std::string >::insert(std::vector< std::string >::iterator,std::vector< std::string >::size_type,std::vector< std::string >::value_type const &)\n"); return 0; } -SWIGINTERN PyObject *_wrap_ibytes_reserve(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_StringVec_reserve(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; - std::vector< signed char >::size_type arg2 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; + std::vector< std::string >::size_type arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; @@ -11810,17 +13864,17 @@ SWIGINTERN PyObject *_wrap_ibytes_reserve(PyObject *self, PyObject *args) { PyObject *swig_obj[2] ; (void)self; - if (!SWIG_Python_UnpackTuple(args, "ibytes_reserve", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "StringVec_reserve", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_reserve" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_reserve" "', argument " "1"" of type '" "std::vector< std::string > *""'"); } - arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ibytes_reserve" "', argument " "2"" of type '" "std::vector< signed char >::size_type""'"); + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVec_reserve" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'"); } - arg2 = static_cast< std::vector< signed char >::size_type >(val2); + arg2 = static_cast< std::vector< std::string >::size_type >(val2); (arg1)->reserve(arg2); resultobj = SWIG_Py_Void(); return resultobj; @@ -11829,23 +13883,23 @@ SWIGINTERN PyObject *_wrap_ibytes_reserve(PyObject *self, PyObject *args) { } -SWIGINTERN PyObject *_wrap_ibytes_capacity(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_StringVec_capacity(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; - std::vector< signed char >::size_type result; + std::vector< std::string >::size_type result; (void)self; if (!args) SWIG_fail; swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, 0 | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ibytes_capacity" "', argument " "1"" of type '" "std::vector< int8_t > const *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVec_capacity" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); } - arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); - result = ((std::vector< int8_t > const *)arg1)->capacity(); + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); + result = ((std::vector< std::string > const *)arg1)->capacity(); resultobj = SWIG_From_size_t(static_cast< size_t >(result)); return resultobj; fail: @@ -11853,9 +13907,9 @@ SWIGINTERN PyObject *_wrap_ibytes_capacity(PyObject *self, PyObject *args) { } -SWIGINTERN PyObject *_wrap_delete_ibytes(PyObject *self, PyObject *args) { +SWIGINTERN PyObject *_wrap_delete_StringVec(PyObject *self, PyObject *args) { PyObject *resultobj = 0; - std::vector< int8_t > *arg1 = (std::vector< int8_t > *) 0 ; + std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; @@ -11863,11 +13917,11 @@ SWIGINTERN PyObject *_wrap_delete_ibytes(PyObject *self, PyObject *args) { (void)self; if (!args) SWIG_fail; swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_int8_t_t, SWIG_POINTER_DISOWN | 0 ); + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_std__vectorT_std__string_t, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ibytes" "', argument " "1"" of type '" "std::vector< int8_t > *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_StringVec" "', argument " "1"" of type '" "std::vector< std::string > *""'"); } - arg1 = reinterpret_cast< std::vector< int8_t > * >(argp1); + arg1 = reinterpret_cast< std::vector< std::string > * >(argp1); delete arg1; resultobj = SWIG_Py_Void(); return resultobj; @@ -11876,14 +13930,14 @@ SWIGINTERN PyObject *_wrap_delete_ibytes(PyObject *self, PyObject *args) { } -SWIGINTERN PyObject *ibytes_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *StringVec_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; - SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_int8_t_t, SWIG_NewClientData(obj)); + SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_std__string_t, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } -SWIGINTERN PyObject *ibytes_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *StringVec_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { return SWIG_Python_InitShadowInstance(args); } @@ -13398,7 +15452,7 @@ SWIGINTERN PyObject *_wrap_FrontConfig_getComponents(PyObject *self, PyObject *a } } result = (std::vector< std::string,std::allocator< std::string > > *) &((ppc::front::FrontConfig const *)arg1)->getComponents(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 | 0 ); + resultobj = swig::from(static_cast< std::vector< std::string,std::allocator< std::string > > >(*result)); return resultobj; fail: return NULL; @@ -13413,8 +15467,7 @@ SWIGINTERN PyObject *_wrap_FrontConfig_setComponents(PyObject *self, PyObject *a int res1 = 0 ; std::shared_ptr< ppc::front::FrontConfig > tempshared1 ; std::shared_ptr< ppc::front::FrontConfig > *smartarg1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; + int res2 = SWIG_OLDOBJ ; PyObject *swig_obj[2] ; (void)self; @@ -13434,18 +15487,23 @@ SWIGINTERN PyObject *_wrap_FrontConfig_setComponents(PyObject *self, PyObject *a arg1 = const_cast< ppc::front::FrontConfig * >((smartarg1 ? smartarg1->get() : 0)); } } - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FrontConfig_setComponents" "', argument " "2"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FrontConfig_setComponents" "', argument " "2"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); + { + std::vector< std::string,std::allocator< std::string > > *ptr = (std::vector< std::string,std::allocator< std::string > > *)0; + res2 = swig::asptr(swig_obj[1], &ptr); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FrontConfig_setComponents" "', argument " "2"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); + } + if (!ptr) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FrontConfig_setComponents" "', argument " "2"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); + } + arg2 = ptr; } - arg2 = reinterpret_cast< std::vector< std::string,std::allocator< std::string > > * >(argp2); (arg1)->setComponents((std::vector< std::string,std::allocator< std::string > > const &)*arg2); resultobj = SWIG_Py_Void(); + if (SWIG_IsNewObj(res2)) delete arg2; return resultobj; fail: + if (SWIG_IsNewObj(res2)) delete arg2; return NULL; } @@ -13528,7 +15586,7 @@ SWIGINTERN PyObject *_wrap_FrontConfig_mutableComponents(PyObject *self, PyObjec } } result = (std::vector< std::string,std::allocator< std::string > > *) &(arg1)->mutableComponents(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 | 0 ); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_t, 0 | 0 ); return resultobj; fail: return NULL; @@ -21609,6 +23667,67 @@ SWIGINTERN PyObject *_wrap_IFront_unRegisterComponent(PyObject *self, PyObject * } +SWIGINTERN PyObject *_wrap_IFront_selectNodesByRoutePolicy(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ppc::front::IFront *arg1 = (ppc::front::IFront *) 0 ; + int16_t arg2 ; + ppc::protocol::MessageOptionalHeader::Ptr *arg3 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + std::shared_ptr< ppc::front::IFront > tempshared1 ; + std::shared_ptr< ppc::front::IFront > *smartarg1 = 0 ; + short val2 ; + int ecode2 = 0 ; + void *argp3 ; + int res3 = 0 ; + ppc::protocol::MessageOptionalHeader::Ptr tempshared3 ; + PyObject *swig_obj[3] ; + std::vector< std::string,std::allocator< std::string > > result; + + (void)self; + if (!SWIG_Python_UnpackTuple(args, "IFront_selectNodesByRoutePolicy", 3, 3, swig_obj)) SWIG_fail; + { + int newmem = 0; + res1 = SWIG_ConvertPtrAndOwn(swig_obj[0], &argp1, SWIGTYPE_p_std__shared_ptrT_ppc__front__IFront_t, 0 | 0 , &newmem); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IFront_selectNodesByRoutePolicy" "', argument " "1"" of type '" "ppc::front::IFront *""'"); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared1 = *reinterpret_cast< std::shared_ptr< ppc::front::IFront > * >(argp1); + delete reinterpret_cast< std::shared_ptr< ppc::front::IFront > * >(argp1); + arg1 = const_cast< ppc::front::IFront * >(tempshared1.get()); + } else { + smartarg1 = reinterpret_cast< std::shared_ptr< ppc::front::IFront > * >(argp1); + arg1 = const_cast< ppc::front::IFront * >((smartarg1 ? smartarg1->get() : 0)); + } + } + ecode2 = SWIG_AsVal_short(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IFront_selectNodesByRoutePolicy" "', argument " "2"" of type '" "int16_t""'"); + } + arg2 = static_cast< int16_t >(val2); + { + int newmem = 0; + res3 = SWIG_ConvertPtrAndOwn(swig_obj[2], &argp3, SWIGTYPE_p_std__shared_ptrT_ppc__protocol__MessageOptionalHeader_t, 0 , &newmem); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IFront_selectNodesByRoutePolicy" "', argument " "3"" of type '" "ppc::protocol::MessageOptionalHeader::Ptr const &""'"); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + if (argp3) tempshared3 = *reinterpret_cast< ppc::protocol::MessageOptionalHeader::Ptr * >(argp3); + delete reinterpret_cast< ppc::protocol::MessageOptionalHeader::Ptr * >(argp3); + arg3 = &tempshared3; + } else { + arg3 = (argp3) ? reinterpret_cast< ppc::protocol::MessageOptionalHeader::Ptr * >(argp3) : &tempshared3; + } + } + result = (arg1)->selectNodesByRoutePolicy(arg2,(ppc::protocol::MessageOptionalHeader::Ptr const &)*arg3); + resultobj = swig::from(static_cast< std::vector< std::string,std::allocator< std::string > > >(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *IFront_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; @@ -22438,6 +24557,41 @@ static PyMethodDef SwigMethods[] = { { "delete_ibytes", _wrap_delete_ibytes, METH_O, NULL}, { "ibytes_swigregister", ibytes_swigregister, METH_O, NULL}, { "ibytes_swiginit", ibytes_swiginit, METH_VARARGS, NULL}, + { "StringVec_iterator", _wrap_StringVec_iterator, METH_O, NULL}, + { "StringVec___nonzero__", _wrap_StringVec___nonzero__, METH_O, NULL}, + { "StringVec___bool__", _wrap_StringVec___bool__, METH_O, NULL}, + { "StringVec___len__", _wrap_StringVec___len__, METH_O, NULL}, + { "StringVec___getslice__", _wrap_StringVec___getslice__, METH_VARARGS, NULL}, + { "StringVec___setslice__", _wrap_StringVec___setslice__, METH_VARARGS, NULL}, + { "StringVec___delslice__", _wrap_StringVec___delslice__, METH_VARARGS, NULL}, + { "StringVec___delitem__", _wrap_StringVec___delitem__, METH_VARARGS, NULL}, + { "StringVec___getitem__", _wrap_StringVec___getitem__, METH_VARARGS, NULL}, + { "StringVec___setitem__", _wrap_StringVec___setitem__, METH_VARARGS, NULL}, + { "StringVec_pop", _wrap_StringVec_pop, METH_O, NULL}, + { "StringVec_append", _wrap_StringVec_append, METH_VARARGS, NULL}, + { "StringVec_empty", _wrap_StringVec_empty, METH_O, NULL}, + { "StringVec_size", _wrap_StringVec_size, METH_O, NULL}, + { "StringVec_swap", _wrap_StringVec_swap, METH_VARARGS, NULL}, + { "StringVec_begin", _wrap_StringVec_begin, METH_O, NULL}, + { "StringVec_end", _wrap_StringVec_end, METH_O, NULL}, + { "StringVec_rbegin", _wrap_StringVec_rbegin, METH_O, NULL}, + { "StringVec_rend", _wrap_StringVec_rend, METH_O, NULL}, + { "StringVec_clear", _wrap_StringVec_clear, METH_O, NULL}, + { "StringVec_get_allocator", _wrap_StringVec_get_allocator, METH_O, NULL}, + { "StringVec_pop_back", _wrap_StringVec_pop_back, METH_O, NULL}, + { "StringVec_erase", _wrap_StringVec_erase, METH_VARARGS, NULL}, + { "new_StringVec", _wrap_new_StringVec, METH_VARARGS, NULL}, + { "StringVec_push_back", _wrap_StringVec_push_back, METH_VARARGS, NULL}, + { "StringVec_front", _wrap_StringVec_front, METH_O, NULL}, + { "StringVec_back", _wrap_StringVec_back, METH_O, NULL}, + { "StringVec_assign", _wrap_StringVec_assign, METH_VARARGS, NULL}, + { "StringVec_resize", _wrap_StringVec_resize, METH_VARARGS, NULL}, + { "StringVec_insert", _wrap_StringVec_insert, METH_VARARGS, NULL}, + { "StringVec_reserve", _wrap_StringVec_reserve, METH_VARARGS, NULL}, + { "StringVec_capacity", _wrap_StringVec_capacity, METH_O, NULL}, + { "delete_StringVec", _wrap_delete_StringVec, METH_O, NULL}, + { "StringVec_swigregister", StringVec_swigregister, METH_O, NULL}, + { "StringVec_swiginit", StringVec_swiginit, METH_VARARGS, NULL}, { "Error_buildError", _wrap_Error_buildError, METH_VARARGS, NULL}, { "new_Error", _wrap_new_Error, METH_VARARGS, NULL}, { "delete_Error", _wrap_delete_Error, METH_O, NULL}, @@ -22697,6 +24851,7 @@ static PyMethodDef SwigMethods[] = { ""}, { "IFront_registerComponent", _wrap_IFront_registerComponent, METH_VARARGS, NULL}, { "IFront_unRegisterComponent", _wrap_IFront_unRegisterComponent, METH_VARARGS, NULL}, + { "IFront_selectNodesByRoutePolicy", _wrap_IFront_selectNodesByRoutePolicy, METH_VARARGS, NULL}, { "IFront_swigregister", IFront_swigregister, METH_O, NULL}, { "delete_IFrontBuilder", _wrap_delete_IFrontBuilder, METH_O, NULL}, { "IFrontBuilder_buildClient", _wrap_IFrontBuilder_buildClient, METH_VARARGS, NULL}, @@ -22781,6 +24936,7 @@ static swig_type_info _swigt__p_short = {"_p_short", "int16_t *|int_least16_t *| static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "int8_t *|int_fast8_t *|int_least8_t *|signed char *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_size_type = {"_p_size_type", "size_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__allocatorT_signed_char_t = {"_p_std__allocatorT_signed_char_t", "std::vector< signed char >::allocator_type *|std::allocator< signed char > *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__allocatorT_std__string_t = {"_p_std__allocatorT_std__string_t", "std::vector< std::string >::allocator_type *|std::allocator< std::string > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__allocatorT_unsigned_char_t = {"_p_std__allocatorT_unsigned_char_t", "std::vector< unsigned char >::allocator_type *|std::allocator< unsigned char > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__exception = {"_p_std__exception", "std::exception *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__functionT_void_fF_t = {"_p_std__functionT_void_fF_t", "std::function< void () > *", 0, 0, (void*)0, 0}; @@ -22813,7 +24969,7 @@ static swig_type_info _swigt__p_std__shared_ptrT_ppc__sdk__Transport_t = {"_p_st static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__string_view = {"_p_std__string_view", "std::string_view *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_int8_t_t = {"_p_std__vectorT_int8_t_t", "std::vector< int8_t > *|std::vector< signed char,std::allocator< signed char > > *|std::vector< signed char > *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_std__vectorT_std__string_std__allocatorT_std__string_t_t = {"_p_std__vectorT_std__string_std__allocatorT_std__string_t_t", "std::vector< std::string,std::allocator< std::string > > *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_std__vectorT_std__string_t = {"_p_std__vectorT_std__string_t", "std::vector< std::string,std::allocator< std::string > > *|std::vector< std::string > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_uint8_t_t = {"_p_std__vectorT_uint8_t_t", "bcos::bytes *|std::vector< uint8_t > *|std::vector< unsigned char,std::allocator< unsigned char > > *|std::vector< unsigned char > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_swig__SwigPyIterator = {"_p_swig__SwigPyIterator", "swig::SwigPyIterator *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "bcos::byte *|uint8_t *|uint_fast8_t *|uint_least8_t *|unsigned char *", 0, 0, (void*)0, 0}; @@ -22870,6 +25026,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_signed_char, &_swigt__p_size_type, &_swigt__p_std__allocatorT_signed_char_t, + &_swigt__p_std__allocatorT_std__string_t, &_swigt__p_std__allocatorT_unsigned_char_t, &_swigt__p_std__exception, &_swigt__p_std__functionT_void_fF_t, @@ -22902,7 +25059,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_std__string, &_swigt__p_std__string_view, &_swigt__p_std__vectorT_int8_t_t, - &_swigt__p_std__vectorT_std__string_std__allocatorT_std__string_t_t, + &_swigt__p_std__vectorT_std__string_t, &_swigt__p_std__vectorT_uint8_t_t, &_swigt__p_swig__SwigPyIterator, &_swigt__p_unsigned_char, @@ -22959,6 +25116,7 @@ static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_size_type[] = { {&_swigt__p_size_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__allocatorT_signed_char_t[] = { {&_swigt__p_std__allocatorT_signed_char_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__allocatorT_std__string_t[] = { {&_swigt__p_std__allocatorT_std__string_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__allocatorT_unsigned_char_t[] = { {&_swigt__p_std__allocatorT_unsigned_char_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__exception[] = { {&_swigt__p_std__exception, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__functionT_void_fF_t[] = { {&_swigt__p_std__functionT_void_fF_t, 0, 0, 0},{0, 0, 0, 0}}; @@ -22991,7 +25149,7 @@ static swig_cast_info _swigc__p_std__shared_ptrT_ppc__sdk__Transport_t[] = { {& static swig_cast_info _swigc__p_std__string[] = { {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__string_view[] = { {&_swigt__p_std__string_view, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_int8_t_t[] = { {&_swigt__p_std__vectorT_int8_t_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_std__vectorT_std__string_std__allocatorT_std__string_t_t[] = { {&_swigt__p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_std__vectorT_std__string_t[] = { {&_swigt__p_std__vectorT_std__string_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_uint8_t_t[] = { {&_swigt__p_std__vectorT_uint8_t_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_swig__SwigPyIterator[] = { {&_swigt__p_swig__SwigPyIterator, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; @@ -23048,6 +25206,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_signed_char, _swigc__p_size_type, _swigc__p_std__allocatorT_signed_char_t, + _swigc__p_std__allocatorT_std__string_t, _swigc__p_std__allocatorT_unsigned_char_t, _swigc__p_std__exception, _swigc__p_std__functionT_void_fF_t, @@ -23080,7 +25239,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_std__string, _swigc__p_std__string_view, _swigc__p_std__vectorT_int8_t_t, - _swigc__p_std__vectorT_std__string_std__allocatorT_std__string_t_t, + _swigc__p_std__vectorT_std__string_t, _swigc__p_std__vectorT_uint8_t_t, _swigc__p_swig__SwigPyIterator, _swigc__p_unsigned_char, diff --git a/cpp/wedpr-transport/sdk-wrapper/python/swig/wedpr_python_transport.i b/cpp/wedpr-transport/sdk-wrapper/python/swig/wedpr_python_transport.i index 7ed79823..588e2461 100644 --- a/cpp/wedpr-transport/sdk-wrapper/python/swig/wedpr_python_transport.i +++ b/cpp/wedpr-transport/sdk-wrapper/python/swig/wedpr_python_transport.i @@ -96,6 +96,7 @@ namespace ppc::front{ namespace std{ class vector; + class string; } namespace bcos{ @@ -132,6 +133,7 @@ namespace bcos{ %template(ubytes) std::vector; %template(ibytes) std::vector; +%template(StringVec) std::vector; %include %pybuffer_binary(char* data, uint64_t length) diff --git a/python/ppc_common/ppc_protos/ppc_model.proto b/python/ppc_common/ppc_protos/ppc_model.proto index ac1d72f1..228a37c2 100644 --- a/python/ppc_common/ppc_protos/ppc_model.proto +++ b/python/ppc_common/ppc_protos/ppc_model.proto @@ -1,36 +1,9 @@ syntax = "proto3"; option java_multiple_files = true; -//option java_package = "unknown"; -//option java_outer_classname = "unknown"; option objc_class_prefix = "PPC"; package ppc.model; - -service ModelService { - rpc MessageInteraction (ModelRequest) returns (ModelResponse) {} -} - -message ModelRequest { - string sender = 1; - string receiver = 2; - string task_id = 3; - string key = 4; - int64 seq = 5; - int64 slice_num = 6; - bytes data = 7; -} - -message BaseResponse { - int64 error_code = 1; - string message = 2; -} - -message ModelResponse { - BaseResponse base_response = 1; - bytes data = 2; -} - message PlainBoolList{ repeated bool plain_list = 1; } diff --git a/python/ppc_model/common/initializer.py b/python/ppc_model/common/initializer.py index 2257633e..5ebcf5b9 100644 --- a/python/ppc_model/common/initializer.py +++ b/python/ppc_model/common/initializer.py @@ -8,6 +8,7 @@ from ppc_common.deps_services import storage_loader from ppc_common.ppc_utils import common_func from wedpr_python_gateway_sdk.transport.impl.transport_loader import TransportLoader +from ppc_model.network.wedpr_model_transport import ModelTransport from ppc_model.task.task_manager import TaskManager @@ -17,10 +18,14 @@ def __init__(self, log_config_path, config_path, plot_lock=None): self.config_path = config_path self.config_data = None self.grpc_options = None - self.transport = None self.task_manager = None self.thread_event_manager = None self.storage_client = None + # default send msg timeout + self.transport = None + self.send_msg_timeout_ms = 5000 + self.pop_msg_timeout_ms = 60000 + self.MODEL_COMPONENT = "WEDPR_MODEL" # 只用于测试 self.mock_logger = None self.public_key_length = 2048 @@ -33,8 +38,8 @@ def __init__(self, log_config_path, config_path, plot_lock=None): def init_all(self): self.init_log() self.init_config() - self.init_transport() self.init_task_manager() + self.init_transport() self.init_storage_client() self.init_cache() @@ -56,19 +61,26 @@ def init_config(self): def init_transport(self): # create the transport - self.transport = TransportLoader.build(**self.config_data) + transport = TransportLoader.build(**self.config_data) self.logger( f"Create transport success, config: {self.get_config().desc()}") # start the transport - self.transport.start() - self.logger( - f"Start transport success, config: {self.get_config().desc()}") + transport.start() + self.logger().info( + f"Start transport success, config: {transport.get_config().desc()}") + transport.register_component(self.MODEL_COMPONENT) + self.logger().info( + f"Register the component {self.MODEL_COMPONENT} success") + self.transport = ModelTransport(transport=transport, + task_manager=self.task_manager, + component_type=self.MODEL_COMPONENT, + send_msg_timeout_ms=self.send_msg_timeout_ms, + pop_msg_timeout_ms=self.pop_msg_timeout_ms) def init_task_manager(self): self.task_manager = TaskManager( logger=self.logger(), thread_event_manager=self.thread_event_manager, - stub=self.stub, task_timeout_h=self.config_data['TASK_TIMEOUT_H'] ) diff --git a/python/ppc_model/common/mock/mock_model_transport.py b/python/ppc_model/common/mock/mock_model_transport.py new file mode 100644 index 00000000..e2048a56 --- /dev/null +++ b/python/ppc_model/common/mock/mock_model_transport.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +from ppc_model.network.wedpr_model_transport_api import ModelTransportApi +from ppc_model.network.wedpr_model_transport_api import ModelRouterApi + + +class MockModelTransportApi(ModelTransportApi): + def __init__(self, agency_name): + self.agency_name = agency_name + self.msg_queue = {} + + @staticmethod + def get_topic(task_id: str, task_type: str, dst_agency: str): + return f"{dst_agency}_{task_id}{task_type}" + + def push_by_nodeid(self, task_id: str, task_type: str, dst_node: str, dst_inst: str, payload: bytes, seq: int = 0): + self.msg_queue.update({MockModelTransportApi.get_topic( + task_id, task_type, dst_inst): payload}) + + def pop(self, task_id: str, task_type: str, dst_inst: str): + topic = MockModelTransportApi.get_topic(task_id, task_type, dst_inst) + if topic in self.msg_queue.keys(): + payload = self.msg_queue.get(topic) + self.msg_queue.pop(topic) + return payload + raise Exception(f"Not receive the message of topic:" + f" {self.get_topic(task_id, task_type, dst_inst)} " + f"even after the task has been killed!") + + +class MockModelRouterApi(ModelRouterApi): + def __init__(self, participant_id_list): + self.participant_id_list = participant_id_list + self.transports = {} + for participant in self.participant_id_list: + self.transports.update( + {participant, MockModelTransportApi(participant)}) + + def push(self, task_id: str, task_type: str, dst_agency: str, payload: bytes, seq: int = 0): + transport = self.transports.get(dst_agency) + dst_nodeid = f"{dst_agency}_node" + transport.push_by_nodeid(task_id, task_type, dst_nodeid, payload, seq) + + def pop(self, task_id: str, task_type: str, from_inst: str) -> bytes: + transport = self.transports.get(from_inst) + return transport.pop(task_id, task_type, from_inst) diff --git a/python/ppc_model/common/mock/rpc_client_mock.py b/python/ppc_model/common/mock/rpc_client_mock.py deleted file mode 100644 index c3094c4d..00000000 --- a/python/ppc_model/common/mock/rpc_client_mock.py +++ /dev/null @@ -1,31 +0,0 @@ -import threading - -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelRequest, ModelResponse -from ppc_model.interface.rpc_client import RpcClient - - -class RpcClientMock(RpcClient): - def __init__(self, need_failed=False): - self._need_failed = need_failed - self._bad_guy = 0 - self._lock = threading.Lock() - self._on_message_received = None - - def set_message_handler(self, on_message_received): - self._on_message_received = on_message_received - - def send(self, request: ModelRequest): - # print( - # f"send data to {request.receiver}, task_id: {request.task_id}, " - # f"key: {request.key}, seq: {request.seq}") - self._on_message_received(request) - response = ModelResponse() - if self._need_failed: - # 模拟网络断连 - with self._lock: - self._bad_guy += 1 - response.base_response.error_code = self._bad_guy % 2 - else: - response.base_response.error_code = 0 - response.base_response.message = "success" - return response diff --git a/python/ppc_model/common/model_result.py b/python/ppc_model/common/model_result.py index d42f4106..0cf9e36b 100644 --- a/python/ppc_model/common/model_result.py +++ b/python/ppc_model/common/model_result.py @@ -8,7 +8,7 @@ from ppc_common.ppc_utils.utils import AlgorithmType from ppc_model.common.context import Context from ppc_model.common.protocol import TaskRole -from ppc_model.network.stub import PushRequest, PullRequest +from ppc_model.network.wedpr_model_transport import ModelRouter class ResultFileHandling: @@ -135,20 +135,21 @@ def _remove_workspace(self): def _sync_result_files(self): for key, value in self.ctx.sync_file_list.items(): - self.sync_result_file(self.ctx, value[0], value[1], key) + self.sync_result_file( + self.ctx, self.ctx.model_router, value[0], value[1], key) @staticmethod - def sync_result_file(ctx, local_file, remote_file, key_file): + def sync_result_file(ctx, model_router: ModelRouter, local_file, remote_file, key_file): if ctx.role == TaskRole.ACTIVE_PARTY: with open(local_file, 'rb') as f: byte_data = f.read() for partner_index in range(1, len(ctx.participant_id_list)): if ctx.participant_id_list[partner_index] in ctx.result_receiver_id_list: - SendMessage._send_byte_data(ctx.components.stub, ctx, f'{CommonMessage.SYNC_FILE.value}_{key_file}', + SendMessage._send_byte_data(model_router, ctx, f'{CommonMessage.SYNC_FILE.value}_{key_file}', byte_data, partner_index) else: if ctx.components.config_data['AGENCY_ID'] in ctx.result_receiver_id_list: - byte_data = SendMessage._receive_byte_data(ctx.components.stub, ctx, + byte_data = SendMessage._receive_byte_data(model_router, ctx, f'{CommonMessage.SYNC_FILE.value}_{key_file}', 0) with open(local_file, 'wb') as f: f.write(byte_data) @@ -164,34 +165,23 @@ class CommonMessage(Enum): class SendMessage: @staticmethod - def _send_byte_data(stub, ctx, key_type, byte_data, partner_index): + def _send_byte_data(model_router: ModelRouter, ctx, key_type, byte_data, partner_index): log = ctx.components.logger() start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - - stub.push(PushRequest( - receiver=partner_id, - task_id=ctx.task_id, - key=key_type, - data=byte_data - )) - + model_router.push(task_id=ctx.task_id, task_type=key_type, + dst_agency=partner_id, payload=byte_data) log.info( f"task {ctx.task_id}: Sending {key_type} to {partner_id} finished, " f"data_size: {len(byte_data) / 1024}KB, time_costs: {time.time() - start_time}s") @staticmethod - def _receive_byte_data(stub, ctx, key_type, partner_index): + def _receive_byte_data(model_router: ModelRouter, ctx, key_type, partner_index): log = ctx.components.logger() start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - - byte_data = stub.pull(PullRequest( - sender=partner_id, - task_id=ctx.task_id, - key=key_type - )) - + byte_data = model_router.pop( + task_id=ctx.task_id, task_type=key_type, from_inst=partner_id) log.info( f"task {ctx.task_id}: Received {key_type} from {partner_id} finished, " f"data_size: {len(byte_data) / 1024}KB, time_costs: {time.time() - start_time}s") diff --git a/python/ppc_model/conf/application-sample.yml b/python/ppc_model/conf/application-sample.yml index 330f1de7..d26488f6 100644 --- a/python/ppc_model/conf/application-sample.yml +++ b/python/ppc_model/conf/application-sample.yml @@ -1,20 +1,13 @@ HOST: "0.0.0.0" HTTP_PORT: 43471 -RPC_PORT: 43472 AGENCY_ID: 'WeBank' -GATEWAY_ENDPOINT: "127.0.0.1:43454" PUBLIC_KEY_LENGTH: 2048 MAX_MESSAGE_LENGTH_MB: 100 TASK_TIMEOUT_H: 1800 -SSL_SWITCH: 0 -CA_CRT: "./ca.crt" -SSL_CRT: "./ssl.crt" -SSL_KEY: "./ssl.key" - PEM_PATH: "/data/app/wedpr-model/wedpr-model-node/ppc_model_service/server.pem" SHARE_PATH: "/data/app/wedpr-model/wedpr-model-node/ppc_model_service/dataset_share/" diff --git a/python/ppc_model/feature_engineering/test/feature_engineering_unittest.py b/python/ppc_model/feature_engineering/test/feature_engineering_unittest.py index 67251ad4..4dd89171 100644 --- a/python/ppc_model/feature_engineering/test/feature_engineering_unittest.py +++ b/python/ppc_model/feature_engineering/test/feature_engineering_unittest.py @@ -8,12 +8,11 @@ from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager from ppc_common.ppc_mock.mock_objects import MockLogger, MockStorageClient from ppc_model.common.initializer import Initializer -from ppc_model.common.mock.rpc_client_mock import RpcClientMock +from ppc_model.common.mock.mock_model_transport import MockModelRouterApi from ppc_model.common.protocol import TaskRole from ppc_model.feature_engineering.feature_engineering_context import FeatureEngineeringContext from ppc_model.feature_engineering.vertical.active_party import VerticalFeatureEngineeringActiveParty from ppc_model.feature_engineering.vertical.passive_party import VerticalFeatureEngineeringPassiveParty -from ppc_model.network.stub import ModelStub ACTIVE_PARTY = 'ACTIVE_PARTY' @@ -65,27 +64,9 @@ def mock_args(num_features, iv_thresh): class TestFeatureEngineering(unittest.TestCase): def setUp(self): - self._active_rpc_client = RpcClientMock() - self._passive_rpc_client = RpcClientMock() - self._thread_event_manager = ThreadEventManager() - self._active_stub = ModelStub( - agency_id=ACTIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._active_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._passive_stub = ModelStub( - agency_id=PASSIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._passive_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._active_rpc_client.set_message_handler( - self._passive_stub.on_message_received) - self._passive_rpc_client.set_message_handler( - self._active_stub.on_message_received) + participants = [PASSIVE_PARTY, ACTIVE_PARTY] + self._active_transport = MockModelRouterApi(participants) + self._passive_transport = MockModelRouterApi(participants) def test_fit(self): num_samples = 100000 @@ -96,7 +77,7 @@ def test_fit(self): active_components = Initializer(log_config_path='', config_path='') active_components.homo_algorithm = 0 - active_components.stub = self._active_stub + active_components.transport = self._active_transport active_components.config_data = {'JOB_TEMP_DIR': '/tmp'} active_components.mock_logger = MockLogger() active_components.storage_client = MockStorageClient() @@ -112,7 +93,7 @@ def test_fit(self): passive_components = Initializer(log_config_path='', config_path='') passive_components.homo_algorithm = 0 - passive_components.stub = self._passive_stub + passive_components.transport = self._passive_transport passive_components.config_data = {'JOB_TEMP_DIR': '/tmp'} passive_components.mock_logger = MockLogger() passive_components.storage_client = MockStorageClient() diff --git a/python/ppc_model/feature_engineering/vertical/active_party.py b/python/ppc_model/feature_engineering/vertical/active_party.py index 82523420..cb40d404 100644 --- a/python/ppc_model/feature_engineering/vertical/active_party.py +++ b/python/ppc_model/feature_engineering/vertical/active_party.py @@ -11,7 +11,6 @@ from ppc_model.feature_engineering.vertical.utils import is_continuous_feature, calculate_woe_iv, \ calculate_woe_iv_with_pos_event from ppc_model.interface.model_base import VerticalModel -from ppc_model.network.stub import PushRequest, PullRequest class VerticalFeatureEngineeringActiveParty(VerticalModel): @@ -131,12 +130,8 @@ def _process_one_feature(phe, field, count_list, enc_aggr_labels): def _get_all_enc_aggr_labels(self, partner_id): log = self.ctx.components.logger() start_time = time.time() - data = self.ctx.components.stub.pull(PullRequest( - sender=partner_id, - task_id=self.ctx.task_id, - key=FeMessage.AGGR_LABELS.value - )) - + data = self.ctx.model_router.pop(task_id=self.ctx.task_id, + task_type=FeMessage.AGGR_LABELS.value, from_inst=partner_id) enc_aggr_labels_list_pb = EncAggrLabelsList() utils.bytes_to_pb(enc_aggr_labels_list_pb, data) public_key = self.ctx.codec.decode_enc_key( @@ -163,12 +158,10 @@ def _send_enc_labels(self, enc_labels, receiver): data = PheMessage.packing_data( self.ctx.codec, self.ctx.phe.public_key, enc_labels) - self.ctx.components.stub.push(PushRequest( - receiver=receiver, - task_id=self.ctx.task_id, - key=FeMessage.ENC_LABELS.value, - data=data - )) + self.ctx.model_router.push(task_id=self.ctx.task_id, + task_type=FeMessage.ENC_LABELS.value, + dst_agency=receiver, + payload=data) log.info( f"Sending enc labels to {receiver} finished, task_id: {self.ctx.task_id}, label_num: {len(enc_labels)}, " f"size: {len(data) / 1024}KB, time_costs: {time.time() - start_time}s") @@ -183,7 +176,6 @@ def _save_and_sync_fe_results(self): self.ctx.components.storage_client.upload_file(self.ctx.woe_iv_file, self.ctx.job_id + os.sep + self.ctx.WOE_IV_FILE) log.info(f"Saving fe results finished, task_id: {task_id}") - with open(self.ctx.woe_iv_file, 'rb') as f: woe_iv = f.read() with open(self.ctx.iv_selected_file, 'rb') as f: @@ -191,16 +183,12 @@ def _save_and_sync_fe_results(self): for i in range(1, len(self.ctx.participant_id_list)): partner_id = self.ctx.participant_id_list[i] if partner_id in self.ctx.result_receiver_id_list: - self.ctx.components.stub.push(PushRequest( - receiver=partner_id, - task_id=self.ctx.task_id, - key=FeMessage.WOE_FILE.value, - data=woe_iv - )) - self.ctx.components.stub.push(PushRequest( - receiver=partner_id, - task_id=self.ctx.task_id, - key=FeMessage.IV_SELECTED_FILE.value, - data=iv_selected - )) + self.ctx.model_router.push(task_id=self.ctx.task_id, + task_type=FeMessage.WOE_FILE.value, + dst_agency=partner_id, + payload=woe_iv) + self.ctx.model_router.push(task_id=self.ctx.task_id, + task_type=FeMessage.IV_SELECTED_FILE.value, + dst_agency=partner_id, + payload=iv_selected) log.info(f"Sending fe results finished, task_id: {task_id}") diff --git a/python/ppc_model/feature_engineering/vertical/passive_party.py b/python/ppc_model/feature_engineering/vertical/passive_party.py index 4b3ffd47..9f6b36a4 100644 --- a/python/ppc_model/feature_engineering/vertical/passive_party.py +++ b/python/ppc_model/feature_engineering/vertical/passive_party.py @@ -9,7 +9,6 @@ from ppc_model.feature_engineering.feature_engineering_context import FeatureEngineeringContext, FeMessage from ppc_model.feature_engineering.vertical.utils import is_continuous_feature from ppc_model.interface.model_base import VerticalModel -from ppc_model.network.stub import PullRequest, PushRequest class VerticalFeatureEngineeringPassiveParty(VerticalModel): @@ -44,12 +43,8 @@ def _get_enc_labels(self): log = self.ctx.components.logger() start_time = time.time() active_party = self.ctx.participant_id_list[0] - data = self.ctx.components.stub.pull(PullRequest( - sender=active_party, - task_id=self.ctx.task_id, - key=FeMessage.ENC_LABELS.value - )) - + data = self.ctx.model_router.pop( + task_id=self.ctx.task_id, task_type=FeMessage.ENC_LABELS.value, from_inst=active_party) public_key, enc_labels = PheMessage.unpacking_data( self.ctx.codec, data) log.info(f"All enc labels received, task_id: {self.ctx.task_id}, label_num: {len(enc_labels)}, " @@ -145,14 +140,10 @@ def _send_all_enc_aggr_labels(self, public_key, aggr_labels_bytes_list): self.ctx.components.logger().info( f"Encoding all enc aggr labels finished, task_id: {self.ctx.task_id}, " f"size: {len(data) / 1024}KB, timecost: {time.time() - start_time}s") - - self.ctx.components.stub.push(PushRequest( - receiver=self.ctx.participant_id_list[0], - task_id=self.ctx.task_id, - key=FeMessage.AGGR_LABELS.value, - data=data - )) - + self.ctx.model_router.push(task_id=self.ctx.task_id, + task_type=FeMessage.AGGR_LABELS.value, + dst_agency=self.ctx.participant_id_list[0], + payload=data) self.ctx.components.logger().info( f"Sending all enc aggr labels finished, task_id: {self.ctx.task_id}, " f"feature_num: {len(aggr_labels_bytes_list)}, " @@ -162,11 +153,8 @@ def _get_and_save_result(self): active_party = self.ctx.participant_id_list[0] if self.ctx.components.stub.agency_id in self.ctx.result_receiver_id_list: # 保存来自标签方的woe/iv结果 - data = self.ctx.components.stub.pull(PullRequest( - sender=active_party, - task_id=self.ctx.task_id, - key=FeMessage.WOE_FILE.value - )) + data = self.ctx.model_router.pop( + task_id=self.ctx.task_id, task_type=FeMessage.WOE_FILE.value, from_inst=active_party) self.ctx.components.logger().info( f"Result of woe/iv received, task_id: {self.ctx.task_id}, size: {len(data) / 1024}KB") with open(self.ctx.woe_iv_file, 'wb') as f: @@ -175,10 +163,8 @@ def _get_and_save_result(self): self.ctx.job_id + os.sep + self.ctx.WOE_IV_FILE) # 保存来自标签方的iv筛选结果 - data = self.ctx.components.stub.pull(PullRequest( - sender=active_party, - task_id=self.ctx.task_id, - key=FeMessage.IV_SELECTED_FILE.value)) + data = self.ctx.model_router.pop( + task_id=self.ctx.task_id, task_type=FeMessage.IV_SELECTED_FILE.value, from_inst=active_party) self.ctx.components.logger().info( f"Result of iv_select received, task_id: {self.ctx.task_id}, size: {len(data) / 1024}KB") with open(self.ctx.iv_selected_file, 'wb') as f: diff --git a/python/ppc_model/interface/model_base.py b/python/ppc_model/interface/model_base.py index 0e96565f..e755b0b3 100644 --- a/python/ppc_model/interface/model_base.py +++ b/python/ppc_model/interface/model_base.py @@ -1,6 +1,7 @@ from abc import ABC from pandas import DataFrame +from ppc_model.network.wedpr_model_transport import ModelRouter class ModelBase(ABC): @@ -8,6 +9,9 @@ class ModelBase(ABC): def __init__(self, ctx): self.ctx = ctx + self.ctx.model_router = ModelRouter(logger=self.ctx.components.logger(), + transport=self.ctx.components.transport, + participant_id_list=self.ctx.participant_id_list) def fit( self, diff --git a/python/ppc_model/network/grpc/__init__.py b/python/ppc_model/network/grpc/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/python/ppc_model/network/grpc/grpc_client.py b/python/ppc_model/network/grpc/grpc_client.py deleted file mode 100644 index 8169f522..00000000 --- a/python/ppc_model/network/grpc/grpc_client.py +++ /dev/null @@ -1,82 +0,0 @@ -import os -import time -import traceback - -import grpc - -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelRequest, ModelResponse -from ppc_common.ppc_protos.generated.ppc_model_pb2_grpc import ModelServiceStub -from ppc_common.ppc_utils import utils -from ppc_model.common.protocol import RpcType -from ppc_model.interface.rpc_client import RpcClient - - -class GrpcClient(RpcClient): - rpc_type = RpcType.GRPC - - def __init__(self, logger, endpoint: str, grpc_options, ssl_switch: int = 0, - ca_path=None, ssl_key_path=None, ssl_crt_path=None): - self._logger = logger - self._endpoint = endpoint - self._ssl_switch = ssl_switch - self._grpc_options = grpc_options - self._ca_path = ca_path - self._ssl_key_path = ssl_key_path - self._ssl_crt_path = ssl_crt_path - if self._ssl_switch == 0: - insecure_channel = grpc.insecure_channel( - self._endpoint, options=grpc_options) - self._client = ModelServiceStub(insecure_channel) - else: - channel = self._create_secure_channel(self._endpoint) - self._client = ModelServiceStub(channel) - - def _create_secure_channel(self, target): - grpc_root_crt = utils.load_credential_from_file( - os.path.abspath(self._ca_path)) - grpc_ssl_key = utils.load_credential_from_file( - os.path.abspath(self._ssl_key_path)) - grpc_ssl_crt = utils.load_credential_from_file( - os.path.abspath(self._ssl_crt_path)) - credentials = grpc.ssl_channel_credentials( - root_certificates=grpc_root_crt, - private_key=grpc_ssl_key, - certificate_chain=grpc_ssl_crt - ) - return grpc.secure_channel(target, credentials, options=self._grpc_options) - - @staticmethod - def _build_error_model_response(message: str): - model_response = ModelResponse() - model_response.base_response.error_code = -1 - model_response.base_response.message = message - return model_response - - def send(self, request: ModelRequest): - start_time = time.time() - try: - self._logger.debug( - f"start sending data to {request.receiver}, task_id: {request.task_id}, " - f"key: {request.key}, seq: {request.seq}") - response = self._client.MessageInteraction(request) - end_time = time.time() - if response.base_response.error_code != 0: - self._logger.warn( - f"[OnWarn]send data to {request.receiver} failed, task_id: {request.task_id}, " - f"key: {request.key}, seq: {request.seq}, slice_num: {request.slice_num}, " - f"ret_code: {response.base_response.error_code}, message: {response.base_response.message}, " - f"time_costs: {str(end_time - start_time)}s") - else: - self._logger.info( - f"finish sending data to {request.receiver}, task_id: {request.task_id}, " - f"key: {request.key}, seq: {request.seq}, slice_num: {request.slice_num}, " - f"ret_code: {response.base_response.error_code}, message: {response.base_response.message}, " - f"time_costs: {str(end_time - start_time)}s") - except Exception: - end_time = time.time() - message = f"[OnWarn]Send data to {request.receiver} failed, task_id: {request.task_id}, " \ - f"key: {request.key}, seq: {request.seq}, slice_num: {request.slice_num}, " \ - f"exception:{str(traceback.format_exc())}, time_costs: {str(end_time - start_time)}s" - self._logger.warn(message) - response = self._build_error_model_response(message) - return response diff --git a/python/ppc_model/network/grpc/grpc_server.py b/python/ppc_model/network/grpc/grpc_server.py deleted file mode 100644 index 389ba602..00000000 --- a/python/ppc_model/network/grpc/grpc_server.py +++ /dev/null @@ -1,17 +0,0 @@ -from ppc_common.ppc_protos.generated import ppc_model_pb2_grpc -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelRequest, ModelResponse -from ppc_model.common.global_context import components - - -class ModelService(ppc_model_pb2_grpc.ModelServiceServicer): - - def MessageInteraction(self, model_request: ModelRequest, context): - components.logger().info( - f"receive a package, sender: {model_request.sender}, task_id: {model_request.task_id}, " - f"key: {model_request.key}, seq: {model_request.seq}, slice_num: {model_request.slice_num}") - - components.stub.on_message_received(model_request) - model_response = ModelResponse() - model_response.base_response.error_code = 0 - model_response.base_response.message = 'success' - return model_response diff --git a/python/ppc_model/network/stub.py b/python/ppc_model/network/stub.py deleted file mode 100644 index d472847b..00000000 --- a/python/ppc_model/network/stub.py +++ /dev/null @@ -1,219 +0,0 @@ -import os -import time -from concurrent.futures import ThreadPoolExecutor -from dataclasses import dataclass -from typing import Dict, Union - -from readerwriterlock import rwlock - -from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelRequest -from ppc_common.ppc_utils.exception import PpcException, PpcErrorCode - - -@dataclass -class PushRequest: - receiver: str # 数据接收方的机构ID - task_id: str - key: str # 数据键 - data: bytes # 二进制数据 - slice_size_MB: int = 2 # 切片大小,默认为2MB - - def slice_data(self): - """将 data 按 slice_size 进行切片""" - if not self.data: - return [b''] - slice_size = self.slice_size_MB * 1024 * 1024 - return [self.data[i:i + slice_size] for i in - range(0, len(self.data), slice_size)] - - -@dataclass -class PullRequest: - sender: str # 数据发送方的机构ID - task_id: str - key: str # 数据键 - - -class ModelStub: - def __init__( - self, - agency_id: str, - thread_event_manager: ThreadEventManager, - rpc_client, - send_retry_times: int = 3, - retry_interval_s: Union[int, float] = 5 - ) -> None: - self.agency_id = agency_id - self._thread_event_manager = thread_event_manager - self._rpc_client = rpc_client - self._executor = ThreadPoolExecutor( - max_workers=max(1, os.cpu_count() - 1)) - self._send_retry_times = send_retry_times - self._retry_interval_s = retry_interval_s - # 缓存收到的消息 [task_id:[sender:[key:[seq: data]]]] - # 缓存清理由TaskManager完成 - self._received_data: Dict[str, Dict[str, - Dict[str, Dict[int, tuple[int, bytes]]]]] = {} - self._received_uuid: Dict[str, set[str]] = {} - self._traffic_volume: Dict[str, int] = {} - self._data_rw_lock = rwlock.RWLockWrite() - - def push(self, request: PushRequest) -> bytes: - """ - 发送消息 - param request: 消息请求 - """ - slices = request.slice_data() - futures = [] - for seq, data in enumerate(slices): - model_request = ModelRequest( - sender=self.agency_id, - receiver=request.receiver, - task_id=request.task_id, - key=request.key, - seq=seq, - slice_num=len(slices), - data=data - ) - future = self._executor.submit( - self._send_with_retry, model_request) - futures.append(future) - - ret = bytearray() - for future in futures: - ret.extend(future.result()) - - self._accumulate_traffic_volume(request.task_id, len(request.data)) - - return bytes(ret) - - def pull(self, pull_request: PullRequest) -> bytes: - """ - 接收消息 - param request: 待收消息元信息 - return 消息 - """ - task_id = pull_request.task_id - sender = pull_request.sender - key = pull_request.key - while not self._thread_event_manager.event_status(task_id): - if self._is_all_data_ready(pull_request): - ret = bytearray() - with self._data_rw_lock.gen_rlock(): - slice_num = len(self._received_data[task_id][sender][key]) - for seq in range(slice_num): - ret.extend( - self._received_data[task_id][sender][key][seq][1]) - # 缓存中删除已获取到的数据 - with self._data_rw_lock.gen_wlock(): - del self._received_data[task_id][sender][key] - self._accumulate_traffic_volume(task_id, len(ret)) - return bytes(ret) - # 任务还在执行, 休眠后继续尝试获取数据 - time.sleep(0.04) - - # 接收到杀任务的信号 - raise PpcException(PpcErrorCode.TASK_IS_KILLED.get_code(), - PpcErrorCode.TASK_IS_KILLED.get_msg()) - - def traffic_volume(self, task_id) -> float: - with self._data_rw_lock.gen_rlock(): - if task_id not in self._traffic_volume: - return 0 - return self._traffic_volume[task_id] / 1024 / 1024 - - def on_message_received(self, model_request: ModelRequest): - """ - 注册给服务端的回调,服务端收到消息后调用 - param model_request: 收到的消息 - """ - # 消息幂等 - if not self._is_new_data(model_request): - return - # 缓存数据 - self._handle_received_data(model_request) - - def cleanup_cache(self, task_id): - with self._data_rw_lock.gen_wlock(): - if task_id in self._received_data: - del self._received_data[task_id] - if task_id in self._received_uuid: - del self._received_uuid[task_id] - if task_id in self._traffic_volume: - del self._traffic_volume[task_id] - - def _is_new_data(self, model_request: ModelRequest) -> bool: - # 返回是否需要继续处理消息 - task_id = model_request.task_id - uuid = f"{task_id}:{model_request.sender}:{model_request.key}:{model_request.seq}" - with self._data_rw_lock.gen_wlock(): - if task_id in self._received_uuid and uuid in self._received_uuid[task_id]: - # 收到重复的消息 - return False - elif task_id in self._received_uuid and uuid not in self._received_uuid[task_id]: - # 收到task_id的新消息 - self._received_uuid[task_id].add(uuid) - else: - # 首次收到task_id的消息 - self._received_uuid[task_id] = {uuid} - return True - - def _handle_received_data(self, model_request: ModelRequest): - task_id = model_request.task_id - sender = model_request.sender - key = model_request.key - seq = model_request.seq - slice_num = model_request.slice_num - data = model_request.data - with self._data_rw_lock.gen_wlock(): - if task_id not in self._received_data: - self._received_data[task_id] = { - model_request.sender: {key: {seq: (slice_num, data)}}} - elif sender not in self._received_data[task_id]: - self._received_data[task_id][sender] = { - key: {seq: (slice_num, data)}} - elif key not in self._received_data[task_id][sender]: - self._received_data[task_id][sender][key] = { - seq: (slice_num, data)} - else: - self._received_data[task_id][sender][key][seq] = ( - slice_num, data) - - def _is_all_data_ready(self, pull_request: PullRequest): - task_id = pull_request.task_id - sender = pull_request.sender - key = pull_request.key - with self._data_rw_lock.gen_rlock(): - if task_id not in self._received_data: - return False - if sender not in self._received_data[task_id]: - return False - if key not in self._received_data[task_id][sender]: - return False - if len(self._received_data[task_id][sender][key]) == 0: - return False - _, first_value = next( - iter(self._received_data[task_id][sender][key].items())) - if first_value[0] != len(self._received_data[task_id][sender][key]): - return False - return True - - def _send_with_retry(self, model_request: ModelRequest): - retry_times = 0 - while retry_times <= self._send_retry_times: - model_response = self._rpc_client.send(model_request) - if model_response.base_response.error_code == 0: - return model_response.data - if retry_times <= self._send_retry_times: - retry_times += 1 - time.sleep(self._retry_interval_s) - else: - raise PpcException(PpcErrorCode.NETWORK_ERROR.get_code( - ), model_response.base_response.message) - - def _accumulate_traffic_volume(self, task_id, length): - with self._data_rw_lock.gen_wlock(): - if task_id not in self._traffic_volume: - self._traffic_volume[task_id] = 0 - self._traffic_volume[task_id] += length diff --git a/python/ppc_model/network/wedpr_model_transport.py b/python/ppc_model/network/wedpr_model_transport.py new file mode 100644 index 00000000..b1cec812 --- /dev/null +++ b/python/ppc_model/network/wedpr_model_transport.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +from wedpr_python_gateway_sdk.transport.impl.transport import Transport +from wedpr_python_gateway_sdk.transport.impl.transport import RouteType +from wedpr_python_gateway_sdk.transport.api.message_api import MessageAPI +from ppc_model.network.wedpr_model_transport_api import ModelTransportApi +from ppc_model.network.wedpr_model_transport_api import ModelRouterApi +from ppc_model.task.task_manager import TaskManager +import time + + +class ModelTransport(ModelTransportApi): + def __init__(self, transport: Transport, task_manager: TaskManager, + component_type, send_msg_timeout_ms: int = 5000, pop_msg_timeout_ms: int = 60000): + self.transport = transport + # default send msg timeout + self.send_msg_timeout = send_msg_timeout_ms + self.pop_msg_timeout = pop_msg_timeout_ms + self.task_manager = task_manager + self.component_type = component_type + + @staticmethod + def get_topic(task_id: str, task_type: str, dst_agency: str): + return f"{dst_agency}_{task_id}{task_type}" + + def push_by_component(self, task_id: str, task_type: str, dst_inst: str, data): + self.transport.push_by_component(topic=self.get_topic(task_id, task_type, dst_inst), + dstInst=dst_inst, + component=self.component_type, + payload=data, timeout=self.send_msg_timeout) + + def push_by_nodeid(self, task_id: str, task_type: str, dst_node: str, dst_inst: str, payload: bytes, seq: int = 0): + self.transport.push_by_nodeid(topic=self.get_topic(task_id, task_type, dst_inst), + dstNode=bytes( + dst_node, encoding="utf-8"), + seq=seq, payload=payload, + timeout=self.send_msg_timeout) + + def pop(self, task_id: str, task_type: str, dst_inst: str) -> MessageAPI: + while self.task_manager.task_finished(task_id): + msg = self.transport.pop(topic=self.get_topic( + task_id, task_type, dst_inst), timeout_ms=self.pop_msg_timeout) + # wait for the msg if the task is running + if msg is None: + time.sleep(0.04) + else: + return msg + raise Exception(f"Not receive the message of topic:" + f" {self.get_topic(task_id, task_type, dst_inst)} " + f"even after the task has been killed!") + + def get_component_type(self): + return self.component_type + + def select_node(self, route_type: RouteType, dst_agency: str, dst_component: str) -> str: + return self.transport.select_node_by_route_policy(route_type=route_type, + dst_inst=dst_agency, dst_component=dst_component) + + +class ModelRouter(ModelRouterApi): + def __init__(self, logger, transport: ModelTransport, participant_id_list): + self.logger = logger + self.transport = transport + self.participant_id_list = participant_id_list + self.router_info = {} + + def __init_routers__(self): + for participant in self.participant_id_list: + result = self.transport.select_node(route_type=RouteType.ROUTE_THROUGH_COMPONENT, + dst_agency=participant, dst_component=self.transport.get_component_type()) + if result is None: + raise Exception( + f"No router can reach participant {participant}") + self.logger.info( + f"ModelRouter, select node {result} for participant {participant}") + self.router_info.update({participant: result}) + + def __get_dstnode_by_participant(self, participant): + if participant in self.router_info.keys(): + return self.router_info.get(participant) + return None + + def push(self, task_id: str, task_type: str, dst_agency: str, payload: bytes, seq: int = 0): + dst_node = self.__get_dstnode_by_participant(dst_agency) + if dst_node is None: + raise Exception( + f"send message to {dst_agency} failed for no router!") + self.transport.push_by_nodeid( + task_id=task_id, task_type=task_type, dst_node=dst_node, dst_inst=dst_agency, payload=payload, seq=seq) + + def pop(self, task_id: str, task_type: str, from_inst: str) -> bytes: + result = self.transport.pop( + task_id=task_id, task_type=task_type, dst_inst=from_inst) + self.logger.debug(f"Receive message from {result}") + return result.get_payload() diff --git a/python/ppc_model/network/wedpr_model_transport_api.py b/python/ppc_model/network/wedpr_model_transport_api.py new file mode 100644 index 00000000..adab0c82 --- /dev/null +++ b/python/ppc_model/network/wedpr_model_transport_api.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +from abc import ABC, abstractmethod + + +class ModelTransportApi(ABC): + @abstractmethod + def push_by_nodeid(self, task_id: str, task_type: str, dst_node: str, dst_inst: str, payload: bytes, seq: int = 0): + pass + + @abstractmethod + def pop(self, task_id: str, task_type: str, dst_inst: str): + pass + + +class ModelRouterApi: + @abstractmethod + def push(self, task_id: str, task_type: str, dst_agency: str, payload: bytes, seq: int = 0): + pass + + @abstractmethod + def pop(self, task_id: str, task_type: str, from_inst: str) -> bytes: + pass diff --git a/python/ppc_model/ppc_model_app.py b/python/ppc_model/ppc_model_app.py index c2692e53..b1c0d7bc 100644 --- a/python/ppc_model/ppc_model_app.py +++ b/python/ppc_model/ppc_model_app.py @@ -13,7 +13,6 @@ from ppc_model.network.http.restx import api from ppc_model.network.http.model_controller import ns2 as log_namespace from ppc_model.network.http.model_controller import ns as task_namespace -from ppc_model.network.grpc.grpc_server import ModelService from ppc_model.feature_engineering.feature_engineering_engine import FeatureEngineeringEngine from ppc_model.common.protocol import ModelTask from ppc_model.common.global_context import components @@ -66,15 +65,7 @@ def register_task_handler(): server = WSGIServer((app.config['HOST'], app.config['HTTP_PORT']), TransLogger(app, setup_console_handler=False), numthreads=2) - ssl_switch = app.config['SSL_SWITCH'] protocol = 'http' - if ssl_switch == 1: - protocol = 'https' - server.ssl_adapter = BuiltinSSLAdapter( - certificate=app.config['SSL_CRT'], - private_key=app.config['SSL_KEY'], - certificate_chain=app.config['CA_CRT']) - message = f"Starting ppc model server at {protocol}://{app.config['HOST']}:{app.config['HTTP_PORT']}" print(message) components.logger().info(message) diff --git a/python/ppc_model/secure_lgbm/test/test_secure_lgbm_performance_training.py b/python/ppc_model/secure_lgbm/test/test_secure_lgbm_performance_training.py index 0c1925ca..4ba739a7 100644 --- a/python/ppc_model/secure_lgbm/test/test_secure_lgbm_performance_training.py +++ b/python/ppc_model/secure_lgbm/test/test_secure_lgbm_performance_training.py @@ -5,12 +5,11 @@ from ppc_model.common.initializer import Initializer from ppc_common.ppc_mock.mock_objects import MockLogger from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager -from ppc_model.network.stub import ModelStub from ppc_model.datasets.dataset import SecureDataset from ppc_model.metrics.evaluation import Evaluation from ppc_model.metrics.model_plot import ModelPlot from ppc_model.common.model_result import ResultFileHandling -from ppc_model.common.mock.rpc_client_mock import RpcClientMock +from ppc_model.common.mock.mock_model_transport import MockModelRouterApi from ppc_model.secure_lgbm.secure_lgbm_context import SecureLGBMContext from ppc_model.secure_lgbm.vertical import VerticalLGBMActiveParty, VerticalLGBMPassiveParty @@ -67,33 +66,15 @@ def mock_args(): class TestXgboostTraining(unittest.TestCase): def setUp(self): - self._active_rpc_client = RpcClientMock() - self._passive_rpc_client = RpcClientMock() - self._thread_event_manager = ThreadEventManager() - self._active_stub = ModelStub( - agency_id=ACTIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._active_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._passive_stub = ModelStub( - agency_id=PASSIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._passive_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._active_rpc_client.set_message_handler( - self._passive_stub.on_message_received) - self._passive_rpc_client.set_message_handler( - self._active_stub.on_message_received) + participants = [PASSIVE_PARTY, ACTIVE_PARTY] + self._active_transport = MockModelRouterApi(participants) + self._passive_transport = MockModelRouterApi(participants) def test_fit(self): args_a, args_b = mock_args() active_components = Initializer(log_config_path='', config_path='') - active_components.stub = self._active_stub + active_components.transport = self._active_transport active_components.config_data = { 'JOB_TEMP_DIR': '/tmp/active', 'AGENCY_ID': ACTIVE_PARTY} active_components.mock_logger = MockLogger() @@ -111,7 +92,7 @@ def test_fit(self): print(secure_dataset_a.test_y.shape) passive_components = Initializer(log_config_path='', config_path='') - passive_components.stub = self._passive_stub + passive_components.transport = self._passive_transport passive_components.config_data = { 'JOB_TEMP_DIR': '/tmp/passive', 'AGENCY_ID': PASSIVE_PARTY} passive_components.mock_logger = MockLogger() diff --git a/python/ppc_model/secure_lgbm/test/test_secure_lgbm_training.py b/python/ppc_model/secure_lgbm/test/test_secure_lgbm_training.py index d8e20c90..826b89dd 100644 --- a/python/ppc_model/secure_lgbm/test/test_secure_lgbm_training.py +++ b/python/ppc_model/secure_lgbm/test/test_secure_lgbm_training.py @@ -6,12 +6,11 @@ from ppc_model.common.initializer import Initializer from ppc_common.ppc_mock.mock_objects import MockLogger from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager -from ppc_model.network.stub import ModelStub from ppc_model.datasets.dataset import SecureDataset from ppc_model.metrics.evaluation import Evaluation from ppc_model.metrics.model_plot import ModelPlot from ppc_model.common.model_result import ResultFileHandling -from ppc_model.common.mock.rpc_client_mock import RpcClientMock +from ppc_model.common.mock.mock_model_transport import MockModelRouterApi from ppc_model.secure_lgbm.secure_lgbm_context import SecureLGBMContext from ppc_model.secure_lgbm.vertical import VerticalLGBMActiveParty, VerticalLGBMPassiveParty @@ -73,34 +72,18 @@ class TestXgboostTraining(unittest.TestCase): df_with_y, df_without_y = SecureDataset.hetero_split_dataset(df) def setUp(self): - self._active_rpc_client = RpcClientMock() - self._passive_rpc_client = RpcClientMock() self._thread_event_manager = ThreadEventManager() - self._active_stub = ModelStub( - agency_id=ACTIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._active_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._passive_stub = ModelStub( - agency_id=PASSIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._passive_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._active_rpc_client.set_message_handler( - self._passive_stub.on_message_received) - self._passive_rpc_client.set_message_handler( - self._active_stub.on_message_received) + participants = [PASSIVE_PARTY, ACTIVE_PARTY] + self._active_transport = MockModelRouterApi(participants) + self._passive_transport = MockModelRouterApi(participants) def test_fit(self): args_a, args_b = mock_args() plot_lock = threading.Lock() - active_components = Initializer(log_config_path='', config_path='', plot_lock=plot_lock) - active_components.stub = self._active_stub + active_components = Initializer( + log_config_path='', config_path='', plot_lock=plot_lock) + active_components.transport = self._active_transport active_components.config_data = { 'JOB_TEMP_DIR': '/tmp/active', 'AGENCY_ID': ACTIVE_PARTY} active_components.mock_logger = MockLogger() @@ -115,9 +98,9 @@ def test_fit(self): print(secure_dataset_a.test_X.shape) print(secure_dataset_a.test_y.shape) - passive_components = Initializer(log_config_path='', config_path='', plot_lock=plot_lock) - passive_components.stub = self._passive_stub - passive_components.stub = self._passive_stub + passive_components = Initializer( + log_config_path='', config_path='', plot_lock=plot_lock) + passive_components.transport = self._passive_transport passive_components.config_data = { 'JOB_TEMP_DIR': '/tmp/passive', 'AGENCY_ID': PASSIVE_PARTY} passive_components.mock_logger = MockLogger() diff --git a/python/ppc_model/secure_lgbm/vertical/booster.py b/python/ppc_model/secure_lgbm/vertical/booster.py index 888c9618..803d6c3d 100644 --- a/python/ppc_model/secure_lgbm/vertical/booster.py +++ b/python/ppc_model/secure_lgbm/vertical/booster.py @@ -10,20 +10,18 @@ from ppc_model.interface.model_base import VerticalModel from ppc_model.datasets.dataset import SecureDataset from ppc_model.common.protocol import PheMessage -from ppc_model.network.stub import PushRequest, PullRequest from ppc_model.common.model_result import ResultFileHandling from ppc_model.datasets.feature_binning.feature_binning import FeatureBinning from ppc_model.secure_model_base.secure_model_booster import SecureModelBooster from ppc_model.secure_lgbm.secure_lgbm_context import SecureLGBMContext, LGBMMessage - # 抽离sgb的公共部分 + + class VerticalBooster(SecureModelBooster): def __init__(self, ctx: SecureLGBMContext, dataset: SecureDataset) -> None: super().__init__(ctx) self.dataset = dataset - self._stub = ctx.components.stub - self._tree_id = None self._leaf_id = None self._X_bin = None @@ -134,21 +132,13 @@ def _send_enc_data(self, ctx, key_type, enc_data, partner_index, matrix_data=Fal partner_id = ctx.participant_id_list[partner_index] if matrix_data: - self._stub.push(PushRequest( - receiver=partner_id, - task_id=ctx.task_id, - key=key_type, - data=PheMessage.packing_2dim_data( - ctx.codec, ctx.phe.public_key, enc_data) - )) + payload = PheMessage.packing_2dim_data( + ctx.codec, ctx.phe.public_key, enc_data) else: - self._stub.push(PushRequest( - receiver=partner_id, - task_id=ctx.task_id, - key=key_type, - data=PheMessage.packing_data( - ctx.codec, ctx.phe.public_key, enc_data) - )) + payload = PheMessage.packing_data( + ctx.codec, ctx.phe.public_key, enc_data) + self.ctx.model_router.push( + task_id=ctx.task_id, task_type=key_type, dst_agency=partner_id, payload=payload) self.logger.info( f"task {ctx.task_id}: Sending {key_type} to {partner_id} finished, " @@ -157,13 +147,9 @@ def _send_enc_data(self, ctx, key_type, enc_data, partner_index, matrix_data=Fal def _receive_enc_data(self, ctx, key_type, partner_index, matrix_data=False): start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - - byte_data = self._stub.pull(PullRequest( - sender=partner_id, - task_id=ctx.task_id, - key=key_type - )) - + # send without payload + byte_data = self.ctx.model_router.pop( + task_id=ctx.task_id, task_type=key_type, from_inst=partner_id) if matrix_data: public_key, enc_data = PheMessage.unpacking_2dim_data( ctx.codec, byte_data) @@ -180,13 +166,8 @@ def _send_byte_data(self, ctx, key_type, byte_data, partner_index): start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - self._stub.push(PushRequest( - receiver=partner_id, - task_id=ctx.task_id, - key=key_type, - data=byte_data - )) - + self.ctx.model_router.push( + task_id=ctx.task_id, task_type=key_type, dst_agency=partner_id, data=byte_data) self.logger.info( f"task {ctx.task_id}: Sending {key_type} to {partner_id} finished, " f"data_size: {len(byte_data) / 1024}KB, time_costs: {time.time() - start_time}s") @@ -195,12 +176,8 @@ def _receive_byte_data(self, ctx, key_type, partner_index): start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - byte_data = self._stub.pull(PullRequest( - sender=partner_id, - task_id=ctx.task_id, - key=key_type - )) - + byte_data = self.ctx.model_router.pop( + task_id=ctx.task_id, task_type=key_type, from_inst=partner_id) self.logger.info( f"task {ctx.task_id}: Received {key_type} from {partner_id} finished, " f"data_size: {len(byte_data) / 1024}KB, time_costs: {time.time() - start_time}s") diff --git a/python/ppc_model/secure_lr/test/test_lr.py b/python/ppc_model/secure_lr/test/test_lr.py index 7ed377ba..f6121fb6 100644 --- a/python/ppc_model/secure_lr/test/test_lr.py +++ b/python/ppc_model/secure_lr/test/test_lr.py @@ -1,3 +1,5 @@ +from sklearn.preprocessing import StandardScaler +from sklearn.preprocessing import MinMaxScaler import unittest import threading import traceback @@ -6,16 +8,10 @@ from ppc_model.common.initializer import Initializer from ppc_common.ppc_mock.mock_objects import MockLogger -from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager -from ppc_model.network.stub import ModelStub from ppc_model.datasets.dataset import SecureDataset from ppc_model.metrics.evaluation import Evaluation -from ppc_model.metrics.model_plot import ModelPlot from ppc_model.metrics.loss import BinaryLoss -from ppc_model.common.model_result import ResultFileHandling -from ppc_model.common.mock.rpc_client_mock import RpcClientMock from ppc_model.secure_lr.secure_lr_context import SecureLRContext -from ppc_model.secure_lr.vertical import VerticalLRActiveParty, VerticalLRPassiveParty from ppc_model.secure_lr.vertical.booster import VerticalBooster @@ -90,7 +86,8 @@ def mock_args(): # for _ in range(max_iter): for i in range(1): - idx = VerticalBooster._get_sample_idx(i, secure_dataset.train_X.shape[0], size = 8) + idx = VerticalBooster._get_sample_idx( + i, secure_dataset.train_X.shape[0], size=8) x_, y_ = secure_dataset.train_X[idx], secure_dataset.train_y[idx] g = BinaryLoss.dot_product(x_, train_weights) + bias @@ -119,7 +116,8 @@ def mock_args(): # for _ in range(max_iter): for i in range(2): - idx = VerticalBooster._get_sample_idx(i, secure_dataset.train_X.shape[0], size = 8) + idx = VerticalBooster._get_sample_idx( + i, secure_dataset.train_X.shape[0], size=8) x_, y_ = secure_dataset.train_X[idx], secure_dataset.train_y[idx] g = BinaryLoss.dot_product(x_, train_weights) @@ -141,7 +139,6 @@ def mock_args(): # df --------------------------------------------- # MinMaxScaler -from sklearn.preprocessing import MinMaxScaler # 创建MinMaxScaler对象 scaler = MinMaxScaler() @@ -153,7 +150,7 @@ def mock_args(): train_weights = VerticalBooster._init_weight(secure_dataset.train_X.shape[1]) for i in range(2): - idx = VerticalBooster._get_sample_idx(i, train_X.shape[0], size = 8) + idx = VerticalBooster._get_sample_idx(i, train_X.shape[0], size=8) x_, y_ = train_X[idx], secure_dataset.train_y[idx] g = BinaryLoss.dot_product(x_, train_weights) @@ -174,7 +171,6 @@ def mock_args(): # StandardScaler -from sklearn.preprocessing import StandardScaler # 创建MinMaxScaler对象 scaler = StandardScaler() @@ -186,7 +182,7 @@ def mock_args(): train_weights = VerticalBooster._init_weight(secure_dataset.train_X.shape[1]) for i in range(2): - idx = VerticalBooster._get_sample_idx(i, train_X.shape[0], size = 8) + idx = VerticalBooster._get_sample_idx(i, train_X.shape[0], size=8) x_, y_ = train_X[idx], secure_dataset.train_y[idx] g = BinaryLoss.dot_product(x_, train_weights) @@ -204,4 +200,3 @@ def mock_args(): train_praba = BinaryLoss.sigmoid(g) auc = Evaluation.fevaluation(secure_dataset.train_y, train_praba)['auc'] print(auc) - diff --git a/python/ppc_model/secure_lr/test/test_secure_lr_performance_training.py b/python/ppc_model/secure_lr/test/test_secure_lr_performance_training.py index 3c99d12b..9aa985e9 100644 --- a/python/ppc_model/secure_lr/test/test_secure_lr_performance_training.py +++ b/python/ppc_model/secure_lr/test/test_secure_lr_performance_training.py @@ -4,13 +4,10 @@ from ppc_model.common.initializer import Initializer from ppc_common.ppc_mock.mock_objects import MockLogger -from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager -from ppc_model.network.stub import ModelStub from ppc_model.datasets.dataset import SecureDataset from ppc_model.metrics.evaluation import Evaluation -from ppc_model.metrics.model_plot import ModelPlot from ppc_model.common.model_result import ResultFileHandling -from ppc_model.common.mock.rpc_client_mock import RpcClientMock +from ppc_model.common.mock.mock_model_transport import MockModelRouterApi from ppc_model.secure_lgbm.secure_lgbm_context import SecureLGBMContext from ppc_model.secure_lgbm.vertical import VerticalLGBMActiveParty, VerticalLGBMPassiveParty @@ -66,33 +63,15 @@ def mock_args(): class TestXgboostTraining(unittest.TestCase): def setUp(self): - self._active_rpc_client = RpcClientMock() - self._passive_rpc_client = RpcClientMock() - self._thread_event_manager = ThreadEventManager() - self._active_stub = ModelStub( - agency_id=ACTIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._active_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._passive_stub = ModelStub( - agency_id=PASSIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._passive_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._active_rpc_client.set_message_handler( - self._passive_stub.on_message_received) - self._passive_rpc_client.set_message_handler( - self._active_stub.on_message_received) + participants = [PASSIVE_PARTY, ACTIVE_PARTY] + self._active_transport = MockModelRouterApi(participants) + self._passive_transport = MockModelRouterApi(participants) def test_fit(self): args_a, args_b = mock_args() active_components = Initializer(log_config_path='', config_path='') - active_components.stub = self._active_stub + active_components.transport = self._active_transport active_components.config_data = { 'JOB_TEMP_DIR': '/tmp/active', 'AGENCY_ID': ACTIVE_PARTY} active_components.mock_logger = MockLogger() @@ -110,7 +89,7 @@ def test_fit(self): print(secure_dataset_a.test_y.shape) passive_components = Initializer(log_config_path='', config_path='') - passive_components.stub = self._passive_stub + passive_components.transport = self._passive_transport passive_components.config_data = { 'JOB_TEMP_DIR': '/tmp/passive', 'AGENCY_ID': PASSIVE_PARTY} passive_components.mock_logger = MockLogger() diff --git a/python/ppc_model/secure_lr/test/test_secure_lr_training.py b/python/ppc_model/secure_lr/test/test_secure_lr_training.py index d90e66a7..736f38f0 100644 --- a/python/ppc_model/secure_lr/test/test_secure_lr_training.py +++ b/python/ppc_model/secure_lr/test/test_secure_lr_training.py @@ -5,13 +5,10 @@ from ppc_model.common.initializer import Initializer from ppc_common.ppc_mock.mock_objects import MockLogger -from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager -from ppc_model.network.stub import ModelStub from ppc_model.datasets.dataset import SecureDataset from ppc_model.metrics.evaluation import Evaluation -from ppc_model.metrics.model_plot import ModelPlot +from ppc_model.common.mock.mock_model_transport import MockModelRouterApi from ppc_model.common.model_result import ResultFileHandling -from ppc_model.common.mock.rpc_client_mock import RpcClientMock from ppc_model.secure_lr.secure_lr_context import SecureLRContext from ppc_model.secure_lr.vertical import VerticalLRActiveParty, VerticalLRPassiveParty @@ -68,7 +65,7 @@ class TestXgboostTraining(unittest.TestCase): y = cancer.target # MinMaxScaler - from sklearn.preprocessing import MinMaxScaler + from sklearn.preprocessing import MinMaxScaler # 创建MinMaxScaler对象 scaler = MinMaxScaler() # 拟合并转换数据 @@ -78,38 +75,22 @@ class TestXgboostTraining(unittest.TestCase): df_with_y, df_without_y = SecureDataset.hetero_split_dataset(df) def setUp(self): - self._active_rpc_client = RpcClientMock() - self._passive_rpc_client = RpcClientMock() - self._thread_event_manager = ThreadEventManager() - self._active_stub = ModelStub( - agency_id=ACTIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._active_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._passive_stub = ModelStub( - agency_id=PASSIVE_PARTY, - thread_event_manager=self._thread_event_manager, - rpc_client=self._passive_rpc_client, - send_retry_times=3, - retry_interval_s=0.1 - ) - self._active_rpc_client.set_message_handler( - self._passive_stub.on_message_received) - self._passive_rpc_client.set_message_handler( - self._active_stub.on_message_received) + participants = [PASSIVE_PARTY, ACTIVE_PARTY] + self._active_transport = MockModelRouterApi(participants) + self._passive_transport = MockModelRouterApi(participants) def test_fit(self): args_a, args_b = mock_args() plot_lock = threading.Lock() - active_components = Initializer(log_config_path='', config_path='', plot_lock=plot_lock) - active_components.stub = self._active_stub + active_components = Initializer( + log_config_path='', config_path='', plot_lock=plot_lock) + active_components.transport = self._active_transport active_components.config_data = { 'JOB_TEMP_DIR': '/tmp/active', 'AGENCY_ID': ACTIVE_PARTY} active_components.mock_logger = MockLogger() task_info_a = SecureLRContext(args_a, active_components) + secure_dataset_a = SecureDataset(task_info_a, self.df_with_y) booster_a = VerticalLRActiveParty(task_info_a, secure_dataset_a) print(secure_dataset_a.feature_name) @@ -120,8 +101,9 @@ def test_fit(self): print(secure_dataset_a.test_X.shape) print(secure_dataset_a.test_y.shape) - passive_components = Initializer(log_config_path='', config_path='', plot_lock=plot_lock) - passive_components.stub = self._passive_stub + passive_components = Initializer( + log_config_path='', config_path='', plot_lock=plot_lock) + passive_components.transport = self._passive_transport passive_components.config_data = { 'JOB_TEMP_DIR': '/tmp/passive', 'AGENCY_ID': PASSIVE_PARTY} passive_components.mock_logger = MockLogger() diff --git a/python/ppc_model/secure_lr/vertical/booster.py b/python/ppc_model/secure_lr/vertical/booster.py index 537e3425..e7cc5f1f 100644 --- a/python/ppc_model/secure_lr/vertical/booster.py +++ b/python/ppc_model/secure_lr/vertical/booster.py @@ -12,7 +12,6 @@ from ppc_model.datasets.data_reduction.feature_selection import FeatureSelection from ppc_model.datasets.dataset import SecureDataset from ppc_model.common.protocol import PheMessage -from ppc_model.network.stub import PushRequest, PullRequest from ppc_model.common.model_result import ResultFileHandling from ppc_model.datasets.feature_binning.feature_binning import FeatureBinning from ppc_model.secure_lr.secure_lr_context import SecureLRContext, LRMessage @@ -178,22 +177,13 @@ def _send_enc_data(self, ctx, key_type, enc_data, partner_index, matrix_data=Fal partner_id = ctx.participant_id_list[partner_index] if matrix_data: - self._stub.push(PushRequest( - receiver=partner_id, - task_id=ctx.task_id, - key=key_type, - data=PheMessage.packing_2dim_data( - ctx.codec, ctx.phe.public_key, enc_data) - )) + payload = PheMessage.packing_2dim_data( + ctx.codec, ctx.phe.public_key, enc_data) else: - self._stub.push(PushRequest( - receiver=partner_id, - task_id=ctx.task_id, - key=key_type, - data=PheMessage.packing_data( - ctx.codec, ctx.phe.public_key, enc_data) - )) - + payload = PheMessage.packing_data( + ctx.codec, ctx.phe.public_key, enc_data) + self.ctx.model_router.push( + task_id=ctx.task_id, task_type=key_type, dst_agency=partner_id, payload=payload) self.logger.info( f"task {ctx.task_id}: Sending {key_type} to {partner_id} finished, " f"data_length: {len(enc_data)}, time_costs: {time.time() - start_time}s") @@ -201,13 +191,8 @@ def _send_enc_data(self, ctx, key_type, enc_data, partner_index, matrix_data=Fal def _receive_enc_data(self, ctx, key_type, partner_index, matrix_data=False): start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - - byte_data = self._stub.pull(PullRequest( - sender=partner_id, - task_id=ctx.task_id, - key=key_type - )) - + byte_data = self.ctx.model_router.pop( + task_id=ctx.task_id, task_type=key_type, from_inst=partner_id) if matrix_data: public_key, enc_data = PheMessage.unpacking_2dim_data( ctx.codec, byte_data) @@ -223,14 +208,8 @@ def _receive_enc_data(self, ctx, key_type, partner_index, matrix_data=False): def _send_byte_data(self, ctx, key_type, byte_data, partner_index): start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - - self._stub.push(PushRequest( - receiver=partner_id, - task_id=ctx.task_id, - key=key_type, - data=byte_data - )) - + self.ctx.model_router.push( + task_id=ctx.task_id, task_type=key_type, dst_agency=partner_id, data=byte_data) self.logger.info( f"task {ctx.task_id}: Sending {key_type} to {partner_id} finished, " f"data_size: {len(byte_data) / 1024}KB, time_costs: {time.time() - start_time}s") @@ -239,11 +218,8 @@ def _receive_byte_data(self, ctx, key_type, partner_index): start_time = time.time() partner_id = ctx.participant_id_list[partner_index] - byte_data = self._stub.pull(PullRequest( - sender=partner_id, - task_id=ctx.task_id, - key=key_type - )) + byte_data = self.ctx.model_router.pop( + task_id=ctx.task_id, task_type=key_type, from_inst=partner_id) self.logger.info( f"task {ctx.task_id}: Received {key_type} from {partner_id} finished, " diff --git a/python/ppc_model/task/task_manager.py b/python/ppc_model/task/task_manager.py index 49654e82..48159c8f 100644 --- a/python/ppc_model/task/task_manager.py +++ b/python/ppc_model/task/task_manager.py @@ -11,17 +11,14 @@ from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager from ppc_common.ppc_utils.exception import PpcException, PpcErrorCode from ppc_model.common.protocol import ModelTask, TaskStatus, LOG_START_FLAG_FORMATTER, LOG_END_FLAG_FORMATTER -from ppc_model.network.stub import ModelStub class TaskManager: def __init__(self, logger, thread_event_manager: ThreadEventManager, - stub: ModelStub, task_timeout_h: Union[int, float]): self.logger = logger self._thread_event_manager = thread_event_manager - self._stub = stub self._task_timeout_s = task_timeout_h * 3600 self._rw_lock = rwlock.RWLockWrite() self._tasks: dict[str, list] = {} @@ -90,6 +87,12 @@ def kill_one_task(self, task_id: str): with self._rw_lock.gen_wlock(): self._tasks[task_id][0] = TaskStatus.FAILED.value + def task_finished(self, task_id: str) -> bool: + (status, _, _) = self.status(task_id) + if status == TaskStatus.RUNNING: + return False + return True + def status(self, task_id: str) -> [str, float, float]: """ 返回: 任务状态, 通讯量(MB), 执行耗时(s) @@ -100,9 +103,9 @@ def status(self, task_id: str) -> [str, float, float]: PpcErrorCode.TASK_NOT_FOUND.get_code(), PpcErrorCode.TASK_NOT_FOUND.get_msg()) status = self._tasks[task_id][0] - traffic_volume = self._stub.traffic_volume(task_id) time_costs = self._tasks[task_id][2] - return status, traffic_volume, time_costs + # TODO: the traffic_volume + return status, 0, time_costs def _on_task_finish(self, task_id: str, is_succeeded: bool, e: Exception = None): with self._rw_lock.gen_wlock(): @@ -154,7 +157,6 @@ def _cleanup_finished_tasks(self): if job_id in self._jobs: del self._jobs[job_id] self._thread_event_manager.remove_event(task_id) - self._stub.cleanup_cache(task_id) self.logger.info( f"Cleanup task cache, task_id: {task_id}, job_id: {job_id}") diff --git a/python/ppc_model/task/test/task_manager_unittest.py b/python/ppc_model/task/test/task_manager_unittest.py index 060d0d6c..33d38e1d 100644 --- a/python/ppc_model/task/test/task_manager_unittest.py +++ b/python/ppc_model/task/test/task_manager_unittest.py @@ -4,20 +4,11 @@ from ppc_common.ppc_async_executor.thread_event_manager import ThreadEventManager from ppc_common.ppc_mock.mock_objects import MockLogger from ppc_model.common.protocol import ModelTask -from ppc_model.common.mock.rpc_client_mock import RpcClientMock from ppc_model.task.task_manager import TaskManager -from ppc_model.network.stub import ModelStub, PushRequest, PullRequest -rpc_client = RpcClientMock() thread_event_manager = ThreadEventManager() -stub = ModelStub( - agency_id='TEST_AGENCY', - thread_event_manager=thread_event_manager, - rpc_client=rpc_client, - send_retry_times=3, - retry_interval_s=0.1 -) -rpc_client.set_message_handler(stub.on_message_received) + +# TODO: complement here def my_send_task(args): @@ -25,49 +16,25 @@ def my_send_task(args): time.sleep(1) byte_array = bytearray(31 * 1024 * 1024) bytes_data = bytes(byte_array) - stub.push(PushRequest( - receiver=args['receiver'], - task_id=args['task_id'], - key=args['key'], - data=bytes_data - )) time.sleep(1) def my_receive_task(args): - print("start my_receive_task") - stub.pull(PullRequest( - sender=args['sender'], - task_id=args['task_id'], - key=args['key'], - )) - time.sleep(1) print("finish my_receive_task") def my_failed_task(args): print("start my_failed_task") - time.sleep(1) raise Exception('For Test') def my_long_task(args): print("start my_long_task") - stub.pull(PullRequest( - sender=args['sender'], - task_id=args['task_id'], - key='not_ready', - )) print("finish my_receive_task") def my_timeout_task(args): print("start my_timeout_task") - stub.pull(PullRequest( - sender=args['sender'], - task_id=args['task_id'], - key='not_ready', - )) print("finish my_timeout_task") @@ -77,7 +44,6 @@ def setUp(self): self._task_manager = TaskManager( logger=MockLogger(), thread_event_manager=thread_event_manager, - stub=stub, task_timeout_h=0.0005 ) self._task_manager.register_task_handler( diff --git a/python/ppc_model_gateway/__init__.py b/python/ppc_model_gateway/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/python/ppc_model_gateway/clients/__init__.py b/python/ppc_model_gateway/clients/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/python/ppc_model_gateway/clients/client_manager.py b/python/ppc_model_gateway/clients/client_manager.py deleted file mode 100644 index e05f89fb..00000000 --- a/python/ppc_model_gateway/clients/client_manager.py +++ /dev/null @@ -1,57 +0,0 @@ -import os - -import grpc - -from ppc_common.ppc_protos.generated.ppc_model_pb2_grpc import ModelServiceStub -from ppc_common.ppc_utils import utils -from ppc_model_gateway import config - - -class ClientManager: - def __init__(self, config_data, grpc_options): - self._config_data = config_data - self._grpc_options = grpc_options - channel = grpc.insecure_channel( - self._config_data['NODE_ENDPOINT'], options=self._grpc_options) - self.node_stub = ModelServiceStub(channel) - self.agency_stub_dict = {} - self._create_partner_stubs() - - def _create_partner_stubs(self): - for agency_id, endpoint in self._get_agency_dict().items(): - if self._config_data['SSL_SWITCH'] == 0: - channel = grpc.insecure_channel( - endpoint, options=self._grpc_options) - self.agency_stub_dict[agency_id] = ModelServiceStub(channel) - else: - channel = self._create_secure_channel(endpoint) - self.agency_stub_dict[agency_id] = ModelServiceStub(channel) - - def _get_agency_dict(self) -> dict: - agency_dict = {} - for entry in self._config_data.get('AGENCY_LIST', []): - if ':' in entry: - key, value = entry.split(":", 1) - key = key.strip() - value = value.strip() - agency_dict[key] = value - return agency_dict - - def _create_secure_channel(self, target): - grpc_root_crt = utils.load_credential_from_file( - os.path.abspath(self._config_data['SSL_CA'])) - grpc_ssl_key = utils.load_credential_from_file( - os.path.abspath(self._config_data['SSL_KEY'])) - grpc_ssl_crt = utils.load_credential_from_file( - os.path.abspath(self._config_data['SSL_CRT'])) - - credentials = grpc.ssl_channel_credentials( - root_certificates=grpc_root_crt, - private_key=grpc_ssl_key, - certificate_chain=grpc_ssl_crt - ) - - return grpc.secure_channel(target, credentials, options=self._grpc_options) - - -client_manager = ClientManager(config.CONFIG_DATA, config.grpc_options) diff --git a/python/ppc_model_gateway/conf/application-sample.yml b/python/ppc_model_gateway/conf/application-sample.yml deleted file mode 100644 index 3c7abf8c..00000000 --- a/python/ppc_model_gateway/conf/application-sample.yml +++ /dev/null @@ -1,19 +0,0 @@ -HOST: "0.0.0.0" - -# 0: off, 1: on -SSL_SWITCH: 1 -SSL_CA: "cert/ca.crt" -SSL_KEY: "cert/node.key" -SSL_CRT: "cert/node.crt" - -# 0801配置 -NODE_TO_PARTNER_RPC_PORT: 43454 -PARTNER_TO_NODE_RPC_PORT: 43451 - -NODE_ENDPOINT: "127.0.0.1:43472" - -AGENCY_LIST: - #- "SG: [@IDC_PPCS_SG_MODEL_GATEWAY_ENDPOINT]" - - "WeBank: 127.0.0.1:43451" - -MAX_MESSAGE_LENGTH_MB: 100 diff --git a/python/ppc_model_gateway/conf/logging.conf b/python/ppc_model_gateway/conf/logging.conf deleted file mode 100644 index 4a7b0aa9..00000000 --- a/python/ppc_model_gateway/conf/logging.conf +++ /dev/null @@ -1,40 +0,0 @@ -[loggers] -keys=root,grpc - -[logger_root] -level=INFO -handlers=consoleHandler,fileHandler - -[logger_grpc] -level = DEBUG -handlers = accessHandler -qualname = grpc -propagate = 0 - -[handlers] -keys=fileHandler,consoleHandler,accessHandler - -[handler_accessHandler] -class=handlers.TimedRotatingFileHandler -args=('logs/appmonitor.log', 'D', 1, 30, 'utf-8') -level=INFO -formatter=simpleFormatter - -[handler_fileHandler] -class=handlers.TimedRotatingFileHandler -args=('logs/ppcs-modelgateway-gateway.log', 'D', 1, 30, 'utf-8') -level=INFO -formatter=simpleFormatter - -[handler_consoleHandler] -class=StreamHandler -args=(sys.stdout,) -level=ERROR -formatter=simpleFormatter - -[formatters] -keys=simpleFormatter - -[formatter_simpleFormatter] -format=[%(levelname)s][%(asctime)s %(msecs)03d][%(process)d][%(filename)s:%(lineno)d] %(message)s -datefmt=%Y-%m-%d %H:%M:%S diff --git a/python/ppc_model_gateway/config.py b/python/ppc_model_gateway/config.py deleted file mode 100644 index 0e36903d..00000000 --- a/python/ppc_model_gateway/config.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -import logging -import logging.config -import os - -import yaml - -path = os.getcwd() -log_dir = os.sep.join([path, 'logs']) -chain_log_dir = os.sep.join([path, 'bin', 'logs']) -print(f"log_dir: {log_dir}") -print(f"chain_log_dir: {chain_log_dir}") -if not os.path.exists(log_dir): - os.makedirs(log_dir) -if not os.path.exists(chain_log_dir): - os.makedirs(chain_log_dir) -logging_conf_path = os.path.normpath('logging.conf') -logging.config.fileConfig(logging_conf_path) - - -def get_logger(name=None): - log = logging.getLogger(name) - return log - - -config_path = "application.yml" - -CONFIG_DATA = {} -agency_dict = {} - - -def read_config(): - with open(config_path, 'rb') as f: - global CONFIG_DATA - CONFIG_DATA = yaml.safe_load(f.read()) - - -read_config() - -grpc_options = [ - ('grpc.ssl_target_name_override', 'PPCS MODEL GATEWAY'), - ('grpc.max_send_message_length', - CONFIG_DATA['MAX_MESSAGE_LENGTH_MB'] * 1024 * 1024), - ('grpc.max_receive_message_length', - CONFIG_DATA['MAX_MESSAGE_LENGTH_MB'] * 1024 * 1024), - ('grpc.keepalive_time_ms', 15000), # 每 15 秒发送一次心跳 - ('grpc.keepalive_timeout_ms', 5000), # 等待心跳回应的超时时间为 5 秒 - ('grpc.keepalive_permit_without_calls', True), # 即使没有调用也允许发送心跳 - ('grpc.http2.min_time_between_pings_ms', 15000), # 心跳之间最小时间间隔为 15 秒 - ('grpc.http2.max_pings_without_data', 0), # 在发送数据前不限制心跳次数 - # 在没有数据传输的情况下,确保心跳包之间至少有 20 秒的间隔 - ('grpc.http2.min_ping_interval_without_data_ms', 20000), - ("grpc.so_reuseport", 1), - ("grpc.use_local_subchannel_pool", 1), - ('grpc.enable_retries', 1), - ('grpc.service_config', - '{ "retryPolicy":{ "maxAttempts": 4, "initialBackoff": "0.1s", "maxBackoff": "1s", "backoffMutiplier": 2, "retryableStatusCodes": [ "UNAVAILABLE" ] } }') -] diff --git a/python/ppc_model_gateway/endpoints/__init__.py b/python/ppc_model_gateway/endpoints/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/python/ppc_model_gateway/endpoints/node_to_partner.py b/python/ppc_model_gateway/endpoints/node_to_partner.py deleted file mode 100644 index 71f6aa07..00000000 --- a/python/ppc_model_gateway/endpoints/node_to_partner.py +++ /dev/null @@ -1,36 +0,0 @@ -import time -import traceback - -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelRequest -from ppc_common.ppc_protos.generated.ppc_model_pb2_grpc import ModelServiceServicer -from ppc_model_gateway import config -from ppc_model_gateway.clients.client_manager import client_manager -from ppc_model_gateway.endpoints.response_builder import build_error_model_response - -log = config.get_logger() - - -class NodeToPartnerService(ModelServiceServicer): - - def MessageInteraction(self, request: ModelRequest, context): - start_time = time.time() - try: - log.debug( - f"start sending data to {request.receiver}, task_id: {request.task_id}, " - f"key: {request.key}, seq: {request.seq}") - # 根据接收方的机构ID路由消息 - client = client_manager.agency_stub_dict[request.receiver] - response = client.MessageInteraction(request) - end_time = time.time() - log.info( - f"finish sending data to {request.receiver}, task_id: {request.task_id}, " - f"key: {request.key}, seq: {request.seq}, slice_num: {request.slice_num}, " - f"ret_code: {response.base_response.error_code}, time_costs: {str(end_time - start_time)}s") - except Exception: - end_time = time.time() - message = f"[OnWarn]Send data to {request.receiver} failed, task_id: {request.task_id}, " \ - f"key: {request.key}, seq: {request.seq}, slice_num: {request.slice_num}, " \ - f"exception:{str(traceback.format_exc())}, time_costs: {str(end_time - start_time)}s" - log.warn(message) - response = build_error_model_response(message) - return response diff --git a/python/ppc_model_gateway/endpoints/partner_to_node.py b/python/ppc_model_gateway/endpoints/partner_to_node.py deleted file mode 100644 index e4aebfce..00000000 --- a/python/ppc_model_gateway/endpoints/partner_to_node.py +++ /dev/null @@ -1,34 +0,0 @@ -import time -import traceback - -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelRequest -from ppc_common.ppc_protos.generated.ppc_model_pb2_grpc import ModelServiceServicer -from ppc_model_gateway import config -from ppc_model_gateway.clients.client_manager import client_manager -from ppc_model_gateway.endpoints.response_builder import build_error_model_response - -log = config.get_logger() - - -class PartnerToNodeService(ModelServiceServicer): - - def MessageInteraction(self, request: ModelRequest, context): - start_time = time.time() - try: - log.debug( - f"start sending data to {request.receiver}, task_id: {request.task_id}, " - f"key: {request.key}, seq: {request.seq}") - response = client_manager.node_stub.MessageInteraction(request) - end_time = time.time() - log.info( - f"finish sending data to {request.receiver}, task_id: {request.task_id}, " - f"key: {request.key}, seq: {request.seq}, slice_num: {request.slice_num}, " - f"ret_code: {response.base_response.error_code}, time_costs: {str(end_time - start_time)}s") - except Exception: - end_time = time.time() - message = f"[OnWarn]Send data to {request.receiver} failed, task_id: {request.task_id}, " \ - f"key: {request.key}, seq: {request.seq}, slice_num: {request.slice_num}, " \ - f"exception:{str(traceback.format_exc())}, time_costs: {str(end_time - start_time)}s" - log.warn(message) - response = build_error_model_response(message) - return response diff --git a/python/ppc_model_gateway/endpoints/response_builder.py b/python/ppc_model_gateway/endpoints/response_builder.py deleted file mode 100644 index f97fa21a..00000000 --- a/python/ppc_model_gateway/endpoints/response_builder.py +++ /dev/null @@ -1,8 +0,0 @@ -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelResponse - - -def build_error_model_response(message: str): - model_response = ModelResponse() - model_response.base_response.error_code = -1 - model_response.base_response.message = message - return model_response diff --git a/python/ppc_model_gateway/ppc_model_gateway_app.py b/python/ppc_model_gateway/ppc_model_gateway_app.py deleted file mode 100644 index 6d53286e..00000000 --- a/python/ppc_model_gateway/ppc_model_gateway_app.py +++ /dev/null @@ -1,93 +0,0 @@ -# Note: here can't be refactored by autopep -import sys -sys.path.append("../") - -import os -from concurrent import futures -from threading import Thread -import grpc -from ppc_common.ppc_protos.generated import ppc_model_pb2_grpc -from ppc_common.ppc_utils import utils -from ppc_model_gateway import config -from ppc_model_gateway.endpoints.node_to_partner import NodeToPartnerService -from ppc_model_gateway.endpoints.partner_to_node import PartnerToNodeService - - - -log = config.get_logger() - - -def node_to_partner_serve(): - rpc_port = config.CONFIG_DATA['NODE_TO_PARTNER_RPC_PORT'] - - ppc_serve = grpc.server(futures.ThreadPoolExecutor(max_workers=max(1, os.cpu_count() - 1)), - options=config.grpc_options) - ppc_model_pb2_grpc.add_ModelServiceServicer_to_server( - NodeToPartnerService(), ppc_serve) - address = "[::]:{}".format(rpc_port) - ppc_serve.add_insecure_port(address) - - ppc_serve.start() - - start_message = f'Start ppc model gateway internal rpc server at {rpc_port}' - print(start_message) - log.info(start_message) - ppc_serve.wait_for_termination() - - -def partner_to_node_serve(): - rpc_port = config.CONFIG_DATA['PARTNER_TO_NODE_RPC_PORT'] - - if config.CONFIG_DATA['SSL_SWITCH'] == 0: - ppc_serve = grpc.server(futures.ThreadPoolExecutor(max_workers=max(1, os.cpu_count() - 1)), - options=config.grpc_options) - ppc_model_pb2_grpc.add_ModelServiceServicer_to_server( - PartnerToNodeService(), ppc_serve) - address = "[::]:{}".format(rpc_port) - ppc_serve.add_insecure_port(address) - else: - grpc_root_crt = utils.load_credential_from_file( - os.path.abspath(config.CONFIG_DATA['SSL_CA'])) - grpc_ssl_key = utils.load_credential_from_file( - os.path.abspath(config.CONFIG_DATA['SSL_KEY'])) - grpc_ssl_crt = utils.load_credential_from_file( - os.path.abspath(config.CONFIG_DATA['SSL_CRT'])) - server_credentials = grpc.ssl_server_credentials((( - grpc_ssl_key, - grpc_ssl_crt, - ),), grpc_root_crt, True) - - ppc_serve = grpc.server(futures.ThreadPoolExecutor(max_workers=max(1, os.cpu_count() - 1)), - options=config.grpc_options) - ppc_model_pb2_grpc.add_ModelServiceServicer_to_server( - PartnerToNodeService(), ppc_serve) - address = "[::]:{}".format(rpc_port) - ppc_serve.add_secure_port(address, server_credentials) - - ppc_serve.start() - - start_message = f'Start ppc model gateway external rpc server at {rpc_port}' - print(start_message) - log.info(start_message) - ppc_serve.wait_for_termination() - - -if __name__ == '__main__': - log = config.get_logger() - - # 设置守护线程 - node_to_partner_serve_thread = Thread(target=node_to_partner_serve) - partner_to_node_serve_thread = Thread(target=partner_to_node_serve) - - node_to_partner_serve_thread.daemon = True - partner_to_node_serve_thread.daemon = True - - node_to_partner_serve_thread.start() - partner_to_node_serve_thread.start() - - node_to_partner_serve_thread.join() - partner_to_node_serve_thread.join() - - message = f'Start ppc model gateway successfully.' - print(message) - log.info(message) diff --git a/python/ppc_model_gateway/test/__init__.py b/python/ppc_model_gateway/test/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/python/ppc_model_gateway/test/client.py b/python/ppc_model_gateway/test/client.py deleted file mode 100644 index a941eb1b..00000000 --- a/python/ppc_model_gateway/test/client.py +++ /dev/null @@ -1,41 +0,0 @@ - -import grpc -import sys -import os - -from ppc_model_gateway import config -from ppc_common.ppc_protos.generated import ppc_model_pb2_grpc -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelRequest - - -def generate_bytes(size_in_mb): - size_in_bytes = size_in_mb * 1024 * 1023 - return os.urandom(size_in_bytes) - - -def send_data(): - channel = grpc.insecure_channel( - f'localhost:{port}', options=config.grpc_options) - stub = ppc_model_pb2_grpc.ModelServiceStub(channel) - - request = ModelRequest() - - request.task_id = "task_id" - request.receiver = receiver - request.key = 'key' - request.seq = 0 - request.slice_num = 1 - request.data = bytes(generate_bytes( - config.CONFIG_DATA['MAX_MESSAGE_LENGTH_MB'])) - - response = stub.MessageInteraction(request) - print("Received response:", response.base_response.message) - - -if __name__ == '__main__': - if len(sys.argv) != 3: - print("Usage: python client.py ") - sys.exit(1) - port = int(sys.argv[1]) - receiver = sys.argv[2] - send_data() diff --git a/python/ppc_model_gateway/test/server.py b/python/ppc_model_gateway/test/server.py deleted file mode 100644 index 03d2a93a..00000000 --- a/python/ppc_model_gateway/test/server.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -from concurrent import futures -import grpc -import sys - -from ppc_model_gateway import config -from ppc_common.ppc_protos.generated import ppc_model_pb2_grpc -from ppc_common.ppc_protos.generated.ppc_model_pb2 import ModelResponse - - -class ModelService(ppc_model_pb2_grpc.ModelServiceServicer): - def MessageInteraction(self, request, context): - response = ModelResponse() - response.base_response.error_code = 0 - response.base_response.message = "Data received successfully." - response.data = request.data - return response - - -def serve(): - server = grpc.server(futures.ThreadPoolExecutor( - max_workers=max(1, os.cpu_count() - 1)), - options=config.grpc_options) - ppc_model_pb2_grpc.add_ModelServiceServicer_to_server( - ModelService(), server) - server.add_insecure_port(f'[::]:{port}') - server.start() - print(f'Start serve successfully at {port}.') - server.wait_for_termination() - - -if __name__ == '__main__': - if len(sys.argv) != 2: - print("Usage: python server.py ") - sys.exit(1) - port = sys.argv[1] - serve() diff --git a/python/ppc_model_gateway/tools/gen_cert.sh b/python/ppc_model_gateway/tools/gen_cert.sh deleted file mode 100644 index 199b7844..00000000 --- a/python/ppc_model_gateway/tools/gen_cert.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -print_usage() { - echo "Usage: $0 [--ca] [--node ] [-h|--help]" - echo " --ca Generate CA key and certificate" - echo " --node Generate sets of certificates and place them in nodeX directories" - echo " -h, --help Display this help message" -} - -generate_ca() { - echo "Generating CA key and certificate..." - # 生成CA私钥 - openssl genrsa -out ca.key 2048 - # 生成自签名的CA证书 - openssl req -x509 -new -nodes -key ca.key -sha256 -days 36500 -out ca.crt -subj "/CN=PPCS CA" -} - -generate_node_certificates() { - local number=$1 - echo "Generating $number sets of node certificates..." - for ((i=1; i<=$number; i++)); do - # 生成节点私钥 - openssl genrsa -out node.key 2048 - # 生成证书签署请求(CSR) - openssl req -new -key node.key -out node.csr -subj "/CN=PPCS MODEL GATEWAY" - # 使用CA证书签署CSR以生成节点证书 - openssl x509 -req -in node.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out node.crt -days 36500 -sha256 - # 清理CSR文件 - rm node.csr - # 创建节点目录并将证书移入 - mkdir -p "node$i" - mv node.key node.crt "node$i/" - echo "Generated certificate set $i and placed in node$i directory" - done -} - -# 检查参数 -if [[ $# -eq 0 ]]; then - echo "Error: No arguments provided." - print_usage - exit 1 -fi - -while [[ "$1" != "" ]]; do - case $1 in - --ca) - generate_ca - ;; - --node) - shift - if [[ $1 =~ ^[0-9]+$ ]]; then - generate_node_certificates $1 - else - echo "Error: --node argument expects a number." - print_usage - exit 1 - fi - ;; - -h | --help) - print_usage - exit 0 - ;; - *) - echo "Error: Invalid argument: $1" - print_usage - exit 1 - ;; - esac - shift -done diff --git a/python/ppc_model_gateway/tools/start.sh b/python/ppc_model_gateway/tools/start.sh deleted file mode 100644 index a25aa05e..00000000 --- a/python/ppc_model_gateway/tools/start.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -dirpath="$(cd "$(dirname "$0")" && pwd)" -cd $dirpath - -export PYTHONPATH=$dirpath/../ -source /data/app/ppcs-modelgateway/gateway_env/bin/deactivate -source /data/app/ppcs-modelgateway/gateway_env/bin/activate -sleep 1 - -rm -rf $dirpath/../success -nohup python $dirpath/ppc_model_gateway_app.py > start.out 2>&1 & - -check_service() { - try_times=5 - i=0 - while [ -z `ps -ef | grep ${1} | grep python | grep -v grep | awk '{print $2}'` ]; do - sleep 1 - ((i = i + 1)) - if [ $i -lt ${try_times} ]; then - echo -e "\033[32m.\033[0m\c" - else - echo -e "\033[31m\nServer ${1} isn't running. \033[0m" - return - fi - done - echo -e "\033[32mServer ${1} started \033[0m" - echo "success" > $dirpath/../success -} - -sleep 5 -check_service ppc_model_gateway_app.py diff --git a/python/ppc_model_gateway/tools/stop.sh b/python/ppc_model_gateway/tools/stop.sh deleted file mode 100644 index fd17dcea..00000000 --- a/python/ppc_model_gateway/tools/stop.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -dirpath="$(cd "$(dirname "$0")" && pwd)" -cd $dirpath - -sleep 1 - -ppc_model_gateway_app_pid=`ps aux |grep ppc_model_gateway_app.py |grep -v grep |awk '{print $2}'` -kill -9 $ppc_model_gateway_app_pid - -echo -e "\033[32mServer ppc_model_gateway_app.py killed. \033[0m"