/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.2
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package com.robotraconteur;

public class WrappedPipeEndpoint {
  private transient long swigCPtr;
  private transient boolean swigCMemOwn;

  protected WrappedPipeEndpoint(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(WrappedPipeEndpoint obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void swigSetCMemOwn(boolean own) {
    swigCMemOwn = own;
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        RobotRaconteurJavaJNI.delete_WrappedPipeEndpoint(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public long sendPacket(MessageElement packet) {
    return RobotRaconteurJavaJNI.WrappedPipeEndpoint_sendPacket(swigCPtr, this, MessageElement.getCPtr(packet), packet);
  }

  public MessageElement receivePacket() {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_receivePacket(swigCPtr, this);
    return (cPtr == 0) ? null : new MessageElement(cPtr, true);
  }

  public MessageElement peekNextPacket() {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_peekNextPacket(swigCPtr, this);
    return (cPtr == 0) ? null : new MessageElement(cPtr, true);
  }

  public MessageElement receivePacketWait(int timeout) {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_receivePacketWait__SWIG_0(swigCPtr, this, timeout);
    return (cPtr == 0) ? null : new MessageElement(cPtr, true);
  }

  public MessageElement receivePacketWait() {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_receivePacketWait__SWIG_1(swigCPtr, this);
    return (cPtr == 0) ? null : new MessageElement(cPtr, true);
  }

  public MessageElement peekNextPacketWait(int timeout) {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_peekNextPacketWait__SWIG_0(swigCPtr, this, timeout);
    return (cPtr == 0) ? null : new MessageElement(cPtr, true);
  }

  public MessageElement peekNextPacketWait() {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_peekNextPacketWait__SWIG_1(swigCPtr, this);
    return (cPtr == 0) ? null : new MessageElement(cPtr, true);
  }

  public WrappedTryReceivePacketWaitResult tryReceivePacketWait(int timeout, boolean peek) {
    return new WrappedTryReceivePacketWaitResult(RobotRaconteurJavaJNI.WrappedPipeEndpoint_tryReceivePacketWait__SWIG_0(swigCPtr, this, timeout, peek), true);
  }

  public WrappedTryReceivePacketWaitResult tryReceivePacketWait(int timeout) {
    return new WrappedTryReceivePacketWaitResult(RobotRaconteurJavaJNI.WrappedPipeEndpoint_tryReceivePacketWait__SWIG_1(swigCPtr, this, timeout), true);
  }

  public WrappedTryReceivePacketWaitResult tryReceivePacketWait() {
    return new WrappedTryReceivePacketWaitResult(RobotRaconteurJavaJNI.WrappedPipeEndpoint_tryReceivePacketWait__SWIG_2(swigCPtr, this), true);
  }

  public void close() {
    RobotRaconteurJavaJNI.WrappedPipeEndpoint_close(swigCPtr, this);
  }

  public int getIndex() {
    return RobotRaconteurJavaJNI.WrappedPipeEndpoint_getIndex(swigCPtr, this);
  }

  public long getEndpoint() {
    return RobotRaconteurJavaJNI.WrappedPipeEndpoint_getEndpoint(swigCPtr, this);
  }

  public long available() {
    return RobotRaconteurJavaJNI.WrappedPipeEndpoint_available(swigCPtr, this);
  }

  public boolean getRequestPacketAck() {
    return RobotRaconteurJavaJNI.WrappedPipeEndpoint_getRequestPacketAck(swigCPtr, this);
  }

  public void setRequestPacketAck(boolean v) {
    RobotRaconteurJavaJNI.WrappedPipeEndpoint_setRequestPacketAck(swigCPtr, this, v);
  }

  public void setType(TypeDefinition value) {
    RobotRaconteurJavaJNI.WrappedPipeEndpoint_Type_set(swigCPtr, this, TypeDefinition.getCPtr(value), value);
  }

  public TypeDefinition getType() {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_Type_get(swigCPtr, this);
    return (cPtr == 0) ? null : new TypeDefinition(cPtr, true);
  }

  public void setRRDirector(WrappedPipeEndpointDirector director, int id) {
    RobotRaconteurJavaJNI.WrappedPipeEndpoint_setRRDirector(swigCPtr, this, WrappedPipeEndpointDirector.getCPtr(director), director, id);
  }

  public boolean isUnreliable() {
    return RobotRaconteurJavaJNI.WrappedPipeEndpoint_isUnreliable(swigCPtr, this);
  }

  public MemberDefinition_Direction direction() {
    return MemberDefinition_Direction.swigToEnum(RobotRaconteurJavaJNI.WrappedPipeEndpoint_direction(swigCPtr, this));
  }

  public void asyncSendPacket(MessageElement packet, AsyncUInt32ReturnDirector handler, int id) {
    RobotRaconteurJavaJNI.WrappedPipeEndpoint_asyncSendPacket(swigCPtr, this, MessageElement.getCPtr(packet), packet, AsyncUInt32ReturnDirector.getCPtr(handler), handler, id);
  }

  public void asyncClose(int timeout, AsyncVoidReturnDirector handler, int id) {
    RobotRaconteurJavaJNI.WrappedPipeEndpoint_asyncClose(swigCPtr, this, timeout, AsyncVoidReturnDirector.getCPtr(handler), handler, id);
  }

  public RobotRaconteurNode getNode() {
    long cPtr = RobotRaconteurJavaJNI.WrappedPipeEndpoint_getNode(swigCPtr, this);
    return (cPtr == 0) ? null : new RobotRaconteurNode(cPtr, true);
  }

  public boolean getIgnoreReceived() {
    return RobotRaconteurJavaJNI.WrappedPipeEndpoint_getIgnoreReceived(swigCPtr, this);
  }

  public void setIgnoreReceived(boolean ignore) {
    RobotRaconteurJavaJNI.WrappedPipeEndpoint_setIgnoreReceived(swigCPtr, this, ignore);
  }

}
