/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com

Copyright (c) 2010 I-maginer

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt

You may alternatively use this source under the terms of a specific version of
the OpenSpace3D Unrestricted License provided you have obtained such a license from
I-maginer.
-----------------------------------------------------------------------------
*/


/**
* plugin.h : main include for Speech plugin
*
*/


#ifndef __PLUGIN_H__
#define __PLUGIN_H__

//! utils libraries for Speech
#include <scol.h>
#include <sapi.h>
#include <sphelper.h>
#include <spuihelp.h>
#include <list>
#include <mlang.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>

//! global scol declaration
extern cbmachine ww;
extern HWND HScol ;		

//! global object declaration
extern int OBJSPEECHSCOL;
extern int OBJRECOSCOL;

//! global Callback declaration for text to speech
extern int SCOL_SPEECH_START_CB;
extern int SPEECH_START_CB;

extern int SCOL_SPEECH_END_CB;
extern int SPEECH_END_CB;

extern int SCOL_SPEECH_WORD_CB;
extern int SPEECH_WORD_CB;

extern int SCOL_SPEECH_TEXT_CB;
extern int SPEECH_TEXT_CB;

extern int SCOL_SPEECH_PHONEME_CB;
extern int SPEECH_PHONEME_CB;

extern int SCOL_SPEECH_VISEME_CB;
extern int SPEECH_VISEME_CB;

//! global Callback declaration for recognition
extern int SCOL_RECO_END_CB;
extern int RECOGNITION_END_CB;

extern int SCOL_RECO_START_CB;
extern int RECOGNITION_START_CB;

extern int SCOL_RECO_TEXT_CB;
extern int RECOGNITION_TEXT_CB;

extern int SCOL_RECO_TEXTS_ALT_CB;
extern int RECOGNITION_TEXTS_ALT_CB;

extern int SCOL_RECO_WORDS_CB;
extern int RECOGNITION_WORDS_CB;

//! Utils Conversions
wchar_t* convertCharToLPCWSTR(char * s_text);
char* convertWcharToChar(wchar_t * w_text);


/*!
Structure to define alternates result for speech API
*/
struct pTextRec
{
  CSpDynamicString altText ;
  float altConfidence ;
};

/*!
Class to record recognition result
*/
class cbData
{
public:
protected:
private:
  std::string          paramStr;
  std::list <pTextRec> lParamText;

public :
  /*!
  */
	cbData()
  {
  }
  
  /*!
  */
  cbData(std::string param1)
  {
    paramStr = param1;
  }
  
  /*!
  */
  cbData(std::list <pTextRec> lParamText1)
  {
    lParamText = lParamText1;
  }

  /*!
  */
  void setParamChar(std::string param1)
  {
    paramStr = param1;
  }
  
  /*!
  */
  std::string getParamChar()
  {
    return paramStr;
  }

  /*!
  */
  std::list <pTextRec> getlParamText()
  {
    return lParamText;
  }
    
	/*!
  */
  ~cbData()
  {
    std::list<pTextRec>::iterator iText = lParamText.begin();
    while (iText != lParamText.end())
    {
      iText->altText.Clear() ;
      delete iText->altText ;
      iText++ ;
    }
    lParamText.clear() ;
  }
protected:
private:
};

#endif