/*==========================================================================*/
/* Copyright (c) 1999 - Sykes Enterprises Inc. - All rights reserved        */
/*--------------------------------------------------------------------------*/
/* Sykes grants you ("Licensee") a non-exclusive, royalty free, license to  */
/* use, modify and redistribute this software in source and binary code     */
/* form, provided that i) this copyright notice and license appear on all   */
/* copies of the software; and ii) Licensee does not utilize the software   */
/* in a manner which is disparaging to Sykes.                               */
/*                                                                          */
/* This software is provided "AS IS", without a warranty of any kind. ALL   */
/* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING */
/* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR        */
/* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SYKES AND ITS          */
/* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A  */
/* RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS           */
/* DERIVATIVES. IN NO EVENT WILL SYKES OR ITS LICENSORS BE LIABLE FOR ANY   */
/* LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,          */
/* CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND        */
/* REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR      */
/* INABILITY TO USE SOFTWARE, EVEN IF SYKES HAS BEEN ADVISED OF THE         */
/* POSSIBILITY OF SUCH DAMAGES.                                             */
/*==========================================================================*/

#ifndef __OKLITETMQUERY_H
#define __OKLITETMQUERY_H

#include "okLiteTM.h"


/*--------------------------------------------------------------------------*/

class okLiteTMQuery
{
public:

	/// Constructor
	okLiteTMQuery ();

	/// Destructor
	~okLiteTMQuery ();

	/// Closes the query engine
	void Close ();

	/// Is a TM opened
	bool IsOpen ()
		{ return(m_Tm.IsOpen()); };

	/// Opens a TM
	bool Open (const char* p_pszPath)
		{ return(m_Tm.Open(p_pszPath)); };

	/// Queries the TM, returns the number of matches
	long Query (const char* p_pszQuery);

	/// Gets the first match, returns its score
	int GetFirstMatch (okLiteTMRecord& p_rData,
		long* p_plPos = NULL);

	/// Gets the next match, returns its score
	int GetNextMatch (okLiteTMRecord& p_rData,
		long* p_plPos = NULL);

	/// Returns the number of matches (exact and fuzzy)
	long GetMatchCount ()
		{ return(m_lstResults.size()); };

	/// Returns the number of exact matches found
	long GetExactMatchCount ();

	/// Sets the threshold
	void SetThreshold (const int p_nThreshold)
		{ m_nThreshold = p_nThreshold; };

	/// Returns the current threshold
	int GetThreshold ()
		{ return(m_nThreshold); };

	/// Sets the concordance mode on/off
	void SetConcordance (const bool p_bConcordance)
		{ m_bConcordance = p_bConcordance; };

	/// Returns the current concordance mode
	bool GetConcordance ()
		{ return(m_bConcordance); };

	/// Returns a pointer to the underlying TM object
	okLiteTM* GetTM ()
		{ return(&m_Tm); };

private:

	okLiteTM             m_Tm;
	okLiteTMResultList   m_lstResults;
	okLiteTMResultIter   m_IterRes;
	int                  m_nThreshold;
	bool                 m_bConcordance;
};


#endif // __OKLITETMQUERY_H


