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

package com.nanotec.nanolib;

public class ObjectSubEntry {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

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

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

  protected static long swigRelease(ObjectSubEntry 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")
  protected void finalize() {
    delete();
  }

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

  public ObjectSubEntry() {
    this(NanolibJNI.new_ObjectSubEntry(), true);
  }

  public String getName() {
    return NanolibJNI.ObjectSubEntry_getName(swigCPtr, this);
  }

  public short getSubIndex() {
    return NanolibJNI.ObjectSubEntry_getSubIndex(swigCPtr, this);
  }

  public ObjectEntryDataType getDataType() {
    return ObjectEntryDataType.swigToEnum(NanolibJNI.ObjectSubEntry_getDataType(swigCPtr, this));
  }

  public ObjectSdoAccessAttribute getSdoAccess() {
    return ObjectSdoAccessAttribute.swigToEnum(NanolibJNI.ObjectSubEntry_getSdoAccess(swigCPtr, this));
  }

  public ObjectPdoAccessAttribute getPdoAccess() {
    return ObjectPdoAccessAttribute.swigToEnum(NanolibJNI.ObjectSubEntry_getPdoAccess(swigCPtr, this));
  }

  public long getBitLength() {
    return NanolibJNI.ObjectSubEntry_getBitLength(swigCPtr, this);
  }

  public ResultInt getDefaultValueAsNumeric(String key) {
    return new ResultInt(NanolibJNI.ObjectSubEntry_getDefaultValueAsNumeric(swigCPtr, this, key), true);
  }

  public ResultString getDefaultValueAsString(String key) {
    return new ResultString(NanolibJNI.ObjectSubEntry_getDefaultValueAsString(swigCPtr, this, key), true);
  }

  public StringStringMap getDefaultValues() {
    return new StringStringMap(NanolibJNI.ObjectSubEntry_getDefaultValues(swigCPtr, this), true);
  }

  public ResultInt readNumber() {
    return new ResultInt(NanolibJNI.ObjectSubEntry_readNumber(swigCPtr, this), true);
  }

  public ResultString readString() {
    return new ResultString(NanolibJNI.ObjectSubEntry_readString(swigCPtr, this), true);
  }

  public ResultArrayByte readBytes() {
    return new ResultArrayByte(NanolibJNI.ObjectSubEntry_readBytes(swigCPtr, this), true);
  }

  public ResultVoid writeNumber(long value) {
    return new ResultVoid(NanolibJNI.ObjectSubEntry_writeNumber(swigCPtr, this, value), true);
  }

  public ResultVoid writeBytes(ByteVector data) {
    return new ResultVoid(NanolibJNI.ObjectSubEntry_writeBytes(swigCPtr, this, ByteVector.getCPtr(data), data), true);
  }

}
