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

package be.portugal.eid;

/******************************************************************************//**
  * A singleton class that is the starting point to get all other objects.
  * An instance can be obtained from the static method instance().
  * From the readerset, a reader context can be requested, either by name or index.
  * From this reader context, a card object can be received, depending on the card
  * type in the reader.
  *********************************************************************************/
public class PTEID_ReaderSet extends PTEID_Object {
  private long swigCPtr;

  protected PTEID_ReaderSet(long cPtr, boolean cMemoryOwn) {
    super(pteidlibJava_WrapperJNI.SWIGPTEID_ReaderSetUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

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

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      pteidlibJava_WrapperJNI.delete_PTEID_ReaderSet(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }
	/** Return the singleton object (created at first use) */
  public static PTEID_ReaderSet instance() {
    return new PTEID_ReaderSet(pteidlibJava_WrapperJNI.PTEID_ReaderSet_instance(), false);
  }

	/**
	  * Init the SDK (Optional)
	  * @param bManageTestCard If true, the applayer must ask if test cards are allowed (used for compatibility with old C API).
	  */
  public static void initSDK(boolean bManageTestCard) throws java.lang.Exception {
    pteidlibJava_WrapperJNI.PTEID_ReaderSet_initSDK__SWIG_0(bManageTestCard);
  }

	/**
	  * Init the SDK (Optional)
	  */
  public static void initSDK() throws java.lang.Exception {
    pteidlibJava_WrapperJNI.PTEID_ReaderSet_initSDK__SWIG_1();
  }
	/** Release the SDK */
  public static void releaseSDK() throws java.lang.Exception {
    pteidlibJava_WrapperJNI.PTEID_ReaderSet_releaseSDK();
  }

	/**
	  * Release the readers (Useful if readers had changed)
	  *
	  * @param bAllReference If true all the invalid reference/pointer are destroyed.
	  * THIS PARAMETER IS THREAD UNSAFE.
	  * make sure not to use any old reference/pointer after this release
	  */
  public void releaseReaders(boolean bAllReference) throws java.lang.Exception {
    pteidlibJava_WrapperJNI.PTEID_ReaderSet_releaseReaders__SWIG_0(swigCPtr, this, bAllReference);
  }

	/**
	  * Release the readers (Useful if readers had changed)
	  */
  public void releaseReaders() throws java.lang.Exception {
    pteidlibJava_WrapperJNI.PTEID_ReaderSet_releaseReaders__SWIG_1(swigCPtr, this);
  }

	/**
	  * Return true if readers have been added or removed
	  */
  public boolean isReadersChanged() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_ReaderSet_isReadersChanged(swigCPtr, this);
  }

	/**
	  * Get the list of the reader
	  *
	  * @param bForceRefresh true=force a refresh of the list of readers
	  * @return String[] names of the connected readers
	  */
  public String[] readerList(boolean bForceRefresh) throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_ReaderSet_readerList__SWIG_0(swigCPtr, this, bForceRefresh);
  }

	/**
	  * Get the list of the reader
	  * @return String[] names of the connected readers
	  */
  public String[] readerList() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_ReaderSet_readerList__SWIG_1(swigCPtr, this);
  }

	/**
	  * Return the first readercontext with a card.
	  *		If no card is present, return the first reader.
	  *		If no reader exist, throw an exception PTEID_ExNoReader
	  */
  public PTEID_ReaderContext getReader() throws java.lang.Exception {
    return new PTEID_ReaderContext(pteidlibJava_WrapperJNI.PTEID_ReaderSet_getReader(swigCPtr, this), false);
  }

	/**
	  * Get the reader by its name
 	  */
  public PTEID_ReaderContext getReaderByName(String readerName) throws java.lang.Exception {
    return new PTEID_ReaderContext(pteidlibJava_WrapperJNI.PTEID_ReaderSet_getReaderByName(swigCPtr, this, readerName), false);
  }

 	/**
	  * Return the number of card readers connected to the computer
	  *
	  * @param bForceRefresh force the reconnection to the lower layer to see if reader list have changed
	  */
  public long readerCount(boolean bForceRefresh) throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_ReaderSet_readerCount__SWIG_0(swigCPtr, this, bForceRefresh);
  }

 	/**
	  * Return the number of card readers connected to the computer
	  */
  public long readerCount() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_ReaderSet_readerCount__SWIG_1(swigCPtr, this);
  }

	/**
	  * Get the name of the reader by its index in the reader list
	  * Throw PTEID_ExParamRange exception if the index is out of range
 	  */
  public String getReaderName(long ulIndex) throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_ReaderSet_getReaderName(swigCPtr, this, ulIndex);
  }

	/**
	  * Get the reader by its index
	  * Throw PTEID_ExParamRange exception if the index is out of range
 	  */
  public PTEID_ReaderContext getReaderByNum(long ulIndex) throws java.lang.Exception {
    return new PTEID_ReaderContext(pteidlibJava_WrapperJNI.PTEID_ReaderSet_getReaderByNum(swigCPtr, this, ulIndex), false);
  }

	/**
	  * Return the reader containing the card with this serial number
	  *		If no card with this serial number is found, throw an exception PTEID_ExParamRange
	  */
  public PTEID_ReaderContext getReaderByCardSerialNumber(String cardSerialNumber) throws java.lang.Exception {
    return new PTEID_ReaderContext(pteidlibJava_WrapperJNI.PTEID_ReaderSet_getReaderByCardSerialNumber(swigCPtr, this, cardSerialNumber), false);
  }

	/**
	* Flush the cache files.
	* Return if any files were flushed (T/F)
	*/
  public boolean flushCache() throws java.lang.Exception {
    return pteidlibJava_WrapperJNI.PTEID_ReaderSet_flushCache(swigCPtr, this);
  }

}
