/* ----------------------------------------------------------------------------
 * 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.
 * ----------------------------------------------------------------------------- */

namespace be.portugal.eid {

using System;
using System.Runtime.InteropServices;

/// <summary>
/// This is a singleton class that is the starting point to get all other objects.
/// You get an instance from the static instance() method (or using the define ReaderSet).
/// Then you get a READER							(PTEID_ReaderContext)
///		-> from this reader, you a CARD				(PTEID_Card or derived class)
///			-> from this card, you get DOCUMENT		(PTEID_XMLDoc or derived class)
///				-> ...
///</summary>
    public class PTEID_ReaderSet : PTEID_Object
    {
  private HandleRef swigCPtr;

  internal PTEID_ReaderSet(IntPtr cPtr, bool cMemoryOwn) : base(pteidlib_dotNetPINVOKE.PTEID_ReaderSetUpcast(cPtr), cMemoryOwn) {
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(PTEID_ReaderSet obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~PTEID_ReaderSet() {
    Dispose();
  }

  public override void Dispose() {
    lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
        swigCMemOwn = false;
        pteidlib_dotNetPINVOKE.delete_PTEID_ReaderSet(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
      base.Dispose();
    }
  }

  public static PTEID_ReaderSet instance() {
    PTEID_ReaderSet ret = new PTEID_ReaderSet(pteidlib_dotNetPINVOKE.PTEID_ReaderSet_instance(), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Init the SDK (Optional).</summary>
  /// <param name="bManageTestCard">
  /// If true the applayer must ask if test cards are allowed (used for compatibility with old C API). 
  /// If false other applications (ex. gui) take that into their scope.
  /// </param>
  public static void initSDK(bool bManageTestCard)
  {
    pteidlib_dotNetPINVOKE.PTEID_ReaderSet_initSDK__SWIG_0(bManageTestCard);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Init the SDK (Optional) without test card managment.</summary>
  public static void initSDK()
  {
    pteidlib_dotNetPINVOKE.PTEID_ReaderSet_initSDK__SWIG_1();
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Release the SDK.</summary>
  public static void releaseSDK()
  {
    pteidlib_dotNetPINVOKE.PTEID_ReaderSet_releaseSDK();
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Release the readers (Useful if readers had changed).</summary>
  /// <param name="bAllReference">
  /// If true all the invalid reference/pointer are destroyed.
  /// PUT THIS PARAMETER TO TRUE IS THREAD UNSAFE. 
  /// You have to be sure that you will not use any old reference/pointer after this release.
  /// </param>
  public void releaseReaders(bool bAllReference)
  {
    pteidlib_dotNetPINVOKE.PTEID_ReaderSet_releaseReaders__SWIG_0(swigCPtr, bAllReference);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Release the readers (Useful if readers had changed).</summary>
  public void releaseReaders()
  {
    pteidlib_dotNetPINVOKE.PTEID_ReaderSet_releaseReaders__SWIG_1(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>Return true if readers has been added or removed.</summary>
  public bool isReadersChanged()
  {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_ReaderSet_isReadersChanged(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Get the list of the reader.
  /// Return an array of string.
  /// </summary>
  /// <param name="bForceRefresh">
  /// force the reconnection to the lower layer to see if reader list have changed
  /// </param>
  public string[] readerList(bool bForceRefresh)
  { 
	IntPtr p = pteidlib_dotNetPINVOKE.PTEID_ReaderSet_readerList__SWIG_0(swigCPtr, bForceRefresh);
	if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
	string[] rslt = pteidlib_dotNetPINVOKE.custom_StringArrayResult;
	return rslt; 
  }

  /// <summary>
  /// Get the list of the reader.
  /// Return an array string.
  /// </summary>
  public string[] readerList() { 
	IntPtr p = pteidlib_dotNetPINVOKE.PTEID_ReaderSet_readerList__SWIG_1(swigCPtr);
	if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
	string[] rslt = pteidlib_dotNetPINVOKE.custom_StringArrayResult;
	return rslt; 
  }

	/// <summary>
	/// Return the first readercontext with a card.
	/// </summary>
    /// <remarks>
	///		If no card is present, return the firs reader.
	///		If no reader exist, throw an exception PTEID_ExNoReader.
    /// </remarks>
  public PTEID_ReaderContext getReader() {
    PTEID_ReaderContext ret = new PTEID_ReaderContext(pteidlib_dotNetPINVOKE.PTEID_ReaderSet_getReader(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the reader by its name.</summary>
  public PTEID_ReaderContext getReaderByName(string readerName)
  {
    PTEID_ReaderContext ret = new PTEID_ReaderContext(pteidlib_dotNetPINVOKE.PTEID_ReaderSet_getReaderByName(swigCPtr, readerName), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return the number of card readers connected to the computer.
  /// </summary>
  /// <param name="bForceRefresh">
  /// force the reconnection to the lower layer to see if reader list have changed.
  /// </param>
  public uint readerCount(bool bForceRefresh)
  {
    uint ret = pteidlib_dotNetPINVOKE.PTEID_ReaderSet_readerCount__SWIG_0(swigCPtr, bForceRefresh);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return the number of card readers connected to the computer.
  /// </summary>
  public uint readerCount()
  {
    uint ret = pteidlib_dotNetPINVOKE.PTEID_ReaderSet_readerCount__SWIG_1(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Get the name of the reader by its Index.
  /// </summary>
  /// <remarks>
  /// Throw PTEID_ExParamRange exception if the index is out of range.
  /// </remarks>
  public string getReaderName(uint ulIndex) {
    string ret = pteidlib_dotNetPINVOKE.PTEID_ReaderSet_getReaderName(swigCPtr, ulIndex);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Get the reader by its Index.
  /// </summary>
  /// <remarks>
  /// Throw PTEID_ExParamRange exception if the index is out of range.
  /// </remarks>
  public PTEID_ReaderContext getReaderByNum(uint ulIndex)
  {
    PTEID_ReaderContext ret = new PTEID_ReaderContext(pteidlib_dotNetPINVOKE.PTEID_ReaderSet_getReaderByNum(swigCPtr, ulIndex), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return the reader containing the card with this SN.
  /// </summary>
  /// <remarks>
  /// If no card with this SN is found, throw an exception PTEID_ExParamRange.
  /// </remarks>
  public PTEID_ReaderContext getReaderByCardSerialNumber(string cardSerialNumber)
  {
    PTEID_ReaderContext ret = new PTEID_ReaderContext(pteidlib_dotNetPINVOKE.PTEID_ReaderSet_getReaderByCardSerialNumber(swigCPtr, cardSerialNumber), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Flush the cached files.
  /// Return if any files were flushed (T/F).
  /// </summary>
  public bool flushCache() {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_ReaderSet_flushCache(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
