using System;
using System.Collections;
namespace com.epam.indigo
{
///
/// Bingo search object
///
public unsafe class BingoObject : IDisposable
{
private int _id;
private Indigo _indigo;
private BingoLib _bingoLib;
private IndigoDllLoader _dllLoader;
private IDisposable _reference;
internal BingoObject(int id, Indigo indigo, BingoLib bingo_lib)
{
this._id = id;
this._indigo = indigo;
this._bingoLib = bingo_lib;
this._dllLoader = IndigoDllLoader.Instance;
}
///
/// Destructor
///
~BingoObject()
{
Dispose();
}
///
///
public void Dispose()
{
if (_id >= 0 && _dllLoader != null && _dllLoader.isValid() && _bingoLib != null && _indigo != null)
{
_indigo.setSessionID();
Bingo.checkResult(_indigo, _bingoLib.bingoEndSearch(_id));
_id = -1;
}
}
///
/// Close method
///
public void close()
{
Dispose();
}
internal int id
{
get { return _id; }
set { _id = value; }
}
///
/// Method to move to the next record
///
/// True if there are any more records
public bool next()
{
_indigo.setSessionID();
return (Bingo.checkResult(_indigo, _bingoLib.bingoNext(_id)) == 1) ? true : false;
}
///
/// Method to return current record id. Should be called after next() method.
///
/// Record id
public int getCurrentId()
{
_indigo.setSessionID();
return Bingo.checkResult(_indigo, _bingoLib.bingoGetCurrentId(_id));
}
///
/// Method to return current similarity value. Should be called after next() method.
///
/// Similarity value
public float getCurrentSimilarityValue()
{
_indigo.setSessionID();
return Bingo.checkResult(_indigo, _bingoLib.bingoGetCurrentSimilarityValue(_id));
}
///
/// Returns a shared IndigoObject for the matched target
///
/// Shared Indigo object for the current search operation
public IndigoObject getIndigoObject()
{
_indigo.setSessionID();
IndigoObject res = new IndigoObject(_indigo, Bingo.checkResult(_indigo, _bingoLib.bingoGetObject(_id)));
_reference = res;
return res;
}
///
/// Method to estimate remaining hits count
///
/// Estimated hits count
public int estimateRemainingResultsCount ()
{
_indigo.setSessionID();
return Bingo.checkResult(_indigo, _bingoLib.bingoEstimateRemainingResultsCount(_id));
}
///
/// Method to estimate remaining hits count error
///
/// Estimated hits count error
public int estimateRemainingResultsCountError ()
{
_indigo.setSessionID();
return Bingo.checkResult(_indigo, _bingoLib.bingoEstimateRemainingResultsCountError(_id));
}
///
/// Method to estimate remaining search time
///
/// Estimated remainin search time
public float estimateRemainingTime ()
{
float esimated_time;
_indigo.setSessionID();
Bingo.checkResult(_indigo, _bingoLib.bingoEstimateRemainingTime(_id, &esimated_time));
return esimated_time;
}
}
}