srsfenginestub/ttphwdevice/src/asrsttphwdevice.h
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:     Exported interface towards TTP HW Device.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef ASRSTTPHWDEVICE_H
       
    23 #define ASRSTTPHWDEVICE_H
       
    24 
       
    25 // INCLUDES
       
    26 // Base class for all HW Devices
       
    27 #include <asrshwdevice.h>
       
    28 // SI Data
       
    29 #include <nsssispeechrecognitiondatadevasr.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CTTPAlgorithm;
       
    33 class CTtpCallback;
       
    34 
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 * Class which defines callback functions. Client must implement this in order
       
    40 * to receive callbacks.
       
    41 *
       
    42 * @lib asrsttphwdevice.lib
       
    43 */
       
    44 class MASRSTtpHwDeviceObserver 
       
    45     {
       
    46     public: // New functions
       
    47         
       
    48         /**
       
    49         * Callback function to load configuration data.
       
    50         * Client provides an implementation.
       
    51         *
       
    52         * @param aPackageType Type identifier.
       
    53         * @param aPackageID Package identifier.
       
    54         * @param aStartPosition First byte.
       
    55         * @param aEndPosition Last byte. If greater than the size of 
       
    56         *                     the data, rest of the data is given.
       
    57         * @return Pointer to the data buffer, TTP HW Device takes ownership.
       
    58         */	
       
    59         virtual HBufC8* MathdoConfigurationData( TUint32 aPackageType, TUint32 aPackageID,
       
    60                                                  TUint32 aStartPosition = 0,
       
    61                                                  TUint32 aEndPosition = KMaxTUint32 ) = 0;
       
    62 
       
    63 		/**
       
    64         * Callback function to notify that word list is converted.
       
    65         * Client provides an implementation.
       
    66         *
       
    67         * @param aError Error code, KErrNone if successful.
       
    68         */	
       
    69 		virtual void MathdoWordListReady( const TInt aError ) = 0;
       
    70 	};
       
    71 
       
    72 /**
       
    73 * TTP HW Device interface.
       
    74 *
       
    75 * @lib asrsttphwdevice.lib
       
    76 */
       
    77 class CASRSTtpHwDevice : public CASRSHwDevice
       
    78     {
       
    79     public: // Constructors and destructor
       
    80         
       
    81         /**
       
    82         * Two-phased constructor.
       
    83         *
       
    84         * @param aObserver Reference to callback observer.
       
    85         */
       
    86         IMPORT_C static CASRSTtpHwDevice* NewL( MASRSTtpHwDeviceObserver& aObserver );
       
    87         
       
    88         /**
       
    89         * Destructor.
       
    90         */
       
    91         IMPORT_C virtual ~CASRSTtpHwDevice();
       
    92 
       
    93     public: // New functions
       
    94         
       
    95         /**
       
    96         * Use to convert text to phonemes.
       
    97         *
       
    98         * @param aText Text to be converted
       
    99 		* @param aLanguage Used language
       
   100         * @return Phoneme sequence, client gains ownership
       
   101         */
       
   102 		IMPORT_C HBufC8* ConvertTextL( const TDesC& aText, 
       
   103 							           TLanguage& aLanguage );
       
   104 
       
   105 		/**
       
   106         * Use to convert list of words to pronunciation sequences.
       
   107         * 
       
   108         * @param aWordList Initialized word list to where 
       
   109         *        pronunciations will be added. Client will keep the ownership
       
   110         *        of CSITtpWordList also after this call.
       
   111 		* @param aDefaultLanguage Language which overrides the first identified language. 
       
   112         *        Iflanguage is ELangOther, language identification will be used.
       
   113     	* @param aMaxNPronunsForWord Maximum number of pronunciations (languages) for each word.
       
   114         */
       
   115 		IMPORT_C void ConvertWordListL( CSITtpWordList& aWordList,
       
   116 								        const RArray<TLanguage> aDefaultLanguage,
       
   117 								        const RArray<TUint32> aMaxNPronunsForWord );
       
   118 		
       
   119         /**
       
   120         * Use to cancel running word list conversion.
       
   121         */
       
   122 		IMPORT_C void CancelWordListConversion();
       
   123 
       
   124         /**
       
   125         * Sets the phoneme notation used in output.
       
   126         *
       
   127         * @param aNotation Phoneme notation identifier.
       
   128         */
       
   129         IMPORT_C void SetPhonemeNotationL( const TDesC& aNotation );
       
   130 
       
   131         /**
       
   132         * Gets the current phoneme notation indentifier.
       
   133         *
       
   134         * @return Phoneme notation identifier.
       
   135         */
       
   136         IMPORT_C const TDesC& PhonemeNotation();
       
   137 
       
   138     public: // From CASRSHwDevice
       
   139 
       
   140         /**
       
   141         * From CASRSHwDevice
       
   142         * Custom interface
       
   143         *
       
   144         * @param aInterfaceId ID of wanted custom interface
       
   145         * @return A pointer to the interface implementation, NULL if not found.
       
   146         */
       
   147         IMPORT_C TAny* CustomInterface( TUid aInterfaceId );
       
   148 
       
   149         /**
       
   150         * From CASRSHwDevice
       
   151         * Initializes Hw Device.
       
   152         */
       
   153         IMPORT_C void InitializeL();
       
   154 
       
   155         /**
       
   156         * From CASRSHwDevice
       
   157         * Clears Hw Device, counter part for InitializeL()
       
   158         */
       
   159         IMPORT_C void Clear();
       
   160 
       
   161     public: // New methods for SIND increment 3
       
   162 
       
   163         /**
       
   164         * Tries to identify the language of given text
       
   165         *
       
   166         * @param "const TDesC& aText" Text
       
   167         * @param "TInt aNumberOfGuesses" Maximum number of guesses that will be provided
       
   168         * @param "RArray<TLanguage>& aLanguages" Output parameter, will contain list of guessed languages
       
   169         * @param "RArray<TInt>& aScores" Output parameter, scores
       
   170         */
       
   171         IMPORT_C void LanguageIdentificationL( const TDesC& aText,
       
   172                                                TInt aNumberOfGuesses,
       
   173                                                RArray<TLanguage>& aLanguages,
       
   174                                                RArray<TInt>& aScores );
       
   175  
       
   176     private:
       
   177 
       
   178         /**
       
   179         * C++ default constructor.
       
   180         * @param aObserver Reference to observer.
       
   181         */
       
   182         CASRSTtpHwDevice( MASRSTtpHwDeviceObserver& aObserver );
       
   183 
       
   184         /**
       
   185         * By default Symbian 2nd phase constructor is private.
       
   186         */
       
   187         void ConstructL();
       
   188 
       
   189         // Prohibit copy constructor if not deriving from CBase.
       
   190         CASRSTtpHwDevice( const CASRSTtpHwDevice& );
       
   191         // Prohibit assigment operator if not deriving from CBase.
       
   192         CASRSTtpHwDevice& operator=( const CASRSTtpHwDevice& );
       
   193 
       
   194 		/**
       
   195         * Function to notify that word list is converted
       
   196         * Called by CTtpCallback.
       
   197         *
       
   198         * @param aError Error code
       
   199         */	
       
   200 		void WordListReady( const TInt aError );
       
   201 
       
   202         /**
       
   203         * Function to notify that configuration data is needed.
       
   204         * Called by CTtpCallback.
       
   205         *
       
   206         * @param aPackageType Type identifier.
       
   207         * @param aPackageID Package identifier.
       
   208         * @param aStartPosition First byte.
       
   209         * @param aEndPosition Last byte. If greater than the size of 
       
   210         *                     the data, rest of the data is given.
       
   211         * @return Pointer to the data buffer.
       
   212         */	
       
   213         virtual HBufC8* ConfigurationData( TUint32 aPackageType, TUint32 aPackageID,
       
   214                                            TUint32 aStartPosition = 0,
       
   215                                            TUint32 aEndPosition = KMaxTUint32 );
       
   216 
       
   217     private: // Data
       
   218 		// Observer
       
   219 		MASRSTtpHwDeviceObserver& iObserver;
       
   220 
       
   221         // algorithm implementation
       
   222         CTTPAlgorithm* iTTPAlgorithm;
       
   223          
       
   224 		// Implements call backs from CTTPAlgorithm
       
   225 		CTtpCallback* iTTPAlgObserver;
       
   226 
       
   227         // Reserved pointer for future extension
       
   228         TAny* iReserved;
       
   229 
       
   230     private: // Friend classes
       
   231         friend class CTtpCallback;
       
   232 
       
   233     };
       
   234 
       
   235 #endif // ASRSTTPHWDEVICE_H  
       
   236             
       
   237 // End of File