OpenTracker

An Open Architecture for Reconfigurable Tracking based on XML | Contact

SpeechSet.h

Go to the documentation of this file.
00001 /* ========================================================================
00002  * Copyright (c) 2006,
00003  * Institute for Computer Graphics and Vision
00004  * Graz University of Technology
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are
00009  * met:
00010  *
00011  * Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the following disclaimer.
00013  *
00014  * Redistributions in binary form must reproduce the above copyright
00015  * notice, this list of conditions and the following disclaimer in the
00016  * documentation and/or other materials provided with the distribution.
00017  *
00018  * Neither the name of the Graz University of Technology nor the names of
00019  * its contributors may be used to endorse or promote products derived from
00020  * this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00023  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00024  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00025  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00026  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  * ========================================================================
00034  * PROJECT: OpenTracker
00035  * ======================================================================== */
00042 /* ======================================================================= */
00043 
00044 
00045 #if !defined(__SPEECHSET_H)
00046 #define __SPEECHSET_H
00047 
00048 #include "../OpenTracker.h"
00049 
00050 #include "SpeechDef.h"
00051 
00065 #ifndef OT_NO_SPEECH_SUPPORT
00066 
00067 
00068 namespace ot {
00069 
00070     class SpeechSetBase
00071     {
00072         // protected data members
00073     protected:
00074         bool m_Active;                    
00075 
00076         std::string m_Name;               
00077         DWORD m_Id;                       
00078         SpeechCoreBase *m_SpeechCore;        
00079 
00080         std::vector<SSpeechCommand> m_RegisteredCommands; 
00081   
00082         StringQueue m_RecogizedCommands;  
00083 
00084 
00085         // protected init & destroy methods
00086     protected:
00088     virtual void Initialize()
00089     {
00090             m_SpeechCore = 0;
00091             m_Active = true;
00092     };
00093 
00095     virtual void Destroy()
00096     {   
00097             m_SpeechCore = 0;
00098             m_Active = false;
00099     };      
00100 
00101 
00102         // constructor & destructor
00103     protected:
00104         SpeechSetBase(const char *p_Name, DWORD p_Id, SpeechCoreBase *p_SpeechCore)
00105         {
00106             Initialize();
00107             m_Name = p_Name;
00108             m_Id = p_Id;
00109             m_SpeechCore = p_SpeechCore;
00110         }
00111 
00112         virtual ~SpeechSetBase()
00113         {
00114             Destroy();
00115         }
00116 
00117   
00118         // public methods
00119     public:
00121         DWORD GetId();
00122 
00124         virtual const char* GetName();
00125 
00126 
00128         virtual bool IsCommandRegistered(const char *p_Command);
00129 
00131         virtual bool IsCommandIdRegistered(DWORD p_CommandId);
00132 
00133 
00135         virtual long GetCommandId(const char *p_Command);
00136 
00138         virtual bool GetCommand(DWORD p_CommandId, std::string &p_Command);
00139 
00140 
00142         virtual void AddCommand(const char *p_Command, DWORD p_CommandId = -1, float p_Weight = 1.0f);
00143 
00145         virtual void RemoveCommand(const char *p_Command);
00146 
00148         virtual void RemoveCommand(DWORD p_CommandId);
00149 
00151         virtual bool GetReco(std::string &p_Result)
00152         {
00153             return false;
00154         };
00155 
00156 
00158         void Activate();
00160         void Deactivate();
00162         bool IsActive();
00163   
00164         friend class SpeechCoreBase;
00165     };
00166 
00167 } // namespace ot
00168 
00169 
00170 #ifdef USE_SAPISPEECH
00171 
00172 
00173 // #include "SpeechInc.h"
00174 
00183 namespace ot {
00184 
00185     class CSpeechSet : public SpeechSetBase
00186     {
00187         // protected data members
00188     protected:
00189         bool m_Active;                    
00190 
00191         std::string m_Name;               
00192         DWORD m_Id;                       
00193         CSpeechCore *m_SpeechCore;        
00194 
00195         std::vector<SSpeechCommand> m_RegisteredCommands; 
00196   
00197         StringQueue m_RecogizedCommands;  
00198 
00199 
00200         // protected init & destroy methods
00201     protected:
00202         void Initialize();    
00203         void Destroy();       
00204 
00205 
00206         // constructor & destructor
00207     protected:
00208         CSpeechSet(const char *p_Name, DWORD p_Id, CSpeechCore *p_SpeechCore);
00209 
00210 
00211         virtual ~CSpeechSet()
00212         {
00213             Destroy();
00214         }
00215 
00216 
00217         // protected methods
00218     protected:
00220         void Recognize(const char *p_String);
00221 
00223         void RebuildRule();
00224 
00225   
00226         // public methods
00227     public:
00229         DWORD GetId();
00230 
00232         const char* GetName();
00233 
00234 
00236         bool IsCommandRegistered(const char *p_Command);
00237 
00239         bool IsCommandIdRegistered(DWORD p_CommandId);
00240 
00241 
00243         long GetCommandId(const char *p_Command);
00244 
00246         bool GetCommand(DWORD p_CommandId, std::string &p_Command);
00247 
00248 
00250         void AddCommand(const char *p_Command, DWORD p_CommandId = -1, float p_Weight = 1.0f);
00251 
00253         void RemoveCommand(const char *p_Command);
00254 
00256         void RemoveCommand(DWORD p_CommandId);
00257 
00258 
00260         bool IsReco();
00261 
00263         bool GetReco(std::string &p_Result);
00264 
00265 
00267         void Activate();
00269         void Deactivate();
00271         bool IsActive();
00272 
00273   
00274         friend class CSpeechCore;
00275     };
00276 
00277 } // namespace ot
00278 
00279 #endif //ifdef USE_SAPISPEECH
00280 
00281 
00282 #endif // OT_NO_SPEECH_SUPPORT
00283 
00284 
00285 #endif //#if !defined(__SPEECHSET_H)
00286 
00287 /* 
00288  * ------------------------------------------------------------
00289  *   End of SpeechSet.h
00290  * ------------------------------------------------------------
00291  *   Automatic Emacs configuration follows.
00292  *   Local Variables:
00293  *   mode:c++
00294  *   c-basic-offset: 4
00295  *   eval: (c-set-offset 'substatement-open 0)
00296  *   eval: (c-set-offset 'case-label '+)
00297  *   eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00298  *   eval: (setq indent-tabs-mode nil)
00299  *   End:
00300  * ------------------------------------------------------------ 
00301  */

copyright (c) 2006 Graz University of Technology