os/mm/mmdevicefw/speechrecogsupport/ASR/inc/mmf/common/SpeechRecognitionDataClient.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmdevicefw/speechrecogsupport/ASR/inc/mmf/common/SpeechRecognitionDataClient.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,304 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __SPEECHRECOGNITIONDATACLIENT_H__
1.20 +#define __SPEECHRECOGNITIONDATACLIENT_H__
1.21 +
1.22 +#include <e32base.h>
1.23 +#include <s32strm.h>
1.24 +
1.25 +// INCLUDES
1.26 +#include <mmf/common/mmfcontrollerframework.h>
1.27 +#include <mmf/common/speechrecognitiondatacommon.h>
1.28 +
1.29 +
1.30 +// FORWARD DECLARATION
1.31 +class TDiagnostic;
1.32 +
1.33 +
1.34 +// CLASS DECLARATION
1.35 +
1.36 +/**
1.37 +@publishedAll
1.38 +@released
1.39 +
1.40 +Class to encapsulate a client recognition result.
1.41 +The result is formulated for client consumption.
1.42 +
1.43 +@since 8.0
1.44 +*/
1.45 +class CSDClientResult : public CBase
1.46 + {
1.47 +public: // Constructors and destructor
1.48 + /**
1.49 + Destructor.
1.50 + */
1.51 + IMPORT_C ~CSDClientResult();
1.52 +
1.53 + /**
1.54 + Two-phased constructor. Creates an uninitialised recognition result.
1.55 +
1.56 + Can leave with one of the system-wide error codes
1.57 +
1.58 + @return CSDClientResult object
1.59 + */
1.60 + IMPORT_C static CSDClientResult* NewL();
1.61 +
1.62 + /**
1.63 + Two-phased constructor. Creates an uninitialised recognition result. A copy of the newly created class
1.64 + is pushed onto the cleanup stack.
1.65 +
1.66 + Can leave with one of the system-wide error codes.
1.67 +
1.68 + @return CSDClientResult object
1.69 + */
1.70 + IMPORT_C static CSDClientResult* NewLC();
1.71 +
1.72 + /**
1.73 + Two-phased constructor. Creates a result with a grammar and rule ID.
1.74 +
1.75 + Can leave with one of the system-wide error codes.
1.76 +
1.77 + @param aGrammarID
1.78 + The grammar ID of the result.
1.79 + @param aRuleID
1.80 + The rule ID of the result.
1.81 +
1.82 + @return CSDClientResult object.
1.83 + */
1.84 + IMPORT_C static CSDClientResult* NewL(TGrammarID aGrammarID, TRuleID aRuleID);
1.85 +
1.86 + /**
1.87 + Two-phased constructor. Creates a result with a grammar and rule ID. A copy of the newly created class
1.88 + is pushed onto the cleanup stack.
1.89 +
1.90 + Can leave with one of the system-wide error codes.
1.91 +
1.92 + @param aGrammarID
1.93 + The grammar ID of the result
1.94 + @param aRuleID
1.95 + The rule ID of the result
1.96 +
1.97 + @return CSDClientResult object.
1.98 + */
1.99 + IMPORT_C static CSDClientResult* NewLC(TGrammarID aGrammarID, TRuleID aRuleID);
1.100 +
1.101 + /**
1.102 + Sets the grammar ID on the result.
1.103 +
1.104 + @param aGrammarID
1.105 + The grammar identifier.
1.106 +
1.107 + @since 8.0
1.108 + */
1.109 + IMPORT_C void SetGrammarID(TGrammarID aGrammarID);
1.110 +
1.111 + /**
1.112 + Retrieves the grammar ID of the result.
1.113 +
1.114 + @return Grammar identifier.
1.115 + @since 8.0
1.116 + */
1.117 + IMPORT_C TGrammarID GrammarID() const;
1.118 +
1.119 + /**
1.120 + Sets the rule ID of the result.
1.121 +
1.122 + @param aRuleID
1.123 + The rule identifier.
1.124 +
1.125 + @since 8.0
1.126 + */
1.127 + IMPORT_C void SetRuleID(TRuleID aRuleID);
1.128 +
1.129 + /**
1.130 + Returns the rule ID of the result.
1.131 +
1.132 + @return The rule identifier.
1.133 + @since 8.0
1.134 + */
1.135 + IMPORT_C TRuleID RuleID() const;
1.136 +
1.137 + /**
1.138 + @internalTechnology
1.139 +
1.140 + Writes the class to a stream.
1.141 +
1.142 + @param aStream
1.143 + A RWriteStream to write the class to.
1.144 +
1.145 + @since 8.0
1.146 + */
1.147 + void ExternalizeL(RWriteStream& aStream) const;
1.148 + /**
1.149 + @internalTechnology
1.150 +
1.151 + Reads the class from a stream.
1.152 +
1.153 + @param aStream
1.154 + A RReadStream to read from.
1.155 +
1.156 + @since 8.0
1.157 + */
1.158 + void InternalizeL(RReadStream& aStream);
1.159 +
1.160 +private:
1.161 + void ConstructL();
1.162 + CSDClientResult();
1.163 + CSDClientResult(TGrammarID aGrammarID, TRuleID aRuleID);
1.164 +
1.165 +
1.166 +private:
1.167 + TGrammarID iGrammarID;
1.168 + TRuleID iRuleID;
1.169 + };
1.170 +
1.171 +
1.172 +/**
1.173 +@publishedAll
1.174 +@released
1.175 +
1.176 +Class to encapsulate a client recogntion result set
1.177 +This is a lightweight result set formulated for client consumption
1.178 +
1.179 +@since 8.0
1.180 +*/
1.181 +class CSDClientResultSet : public CBase
1.182 + {
1.183 +public: // Constructors and destructor
1.184 + /**
1.185 + Destructor.
1.186 + */
1.187 + IMPORT_C ~CSDClientResultSet();
1.188 +
1.189 + /**
1.190 + Two-phased constructor.
1.191 +
1.192 + @return CSDClientResultSet object.
1.193 + */
1.194 + IMPORT_C static CSDClientResultSet* NewL();
1.195 +
1.196 + /**
1.197 + Two-phased constructor. Pushes the newly created object onto the cleanup stack
1.198 +
1.199 + @return CSDClientResultSet object.
1.200 + */
1.201 + IMPORT_C static CSDClientResultSet* NewLC();
1.202 +
1.203 +
1.204 + /**
1.205 + Sets the maximum number of best matches (N-best) expected in the recognition result after
1.206 + recognition.
1.207 +
1.208 + @param aMaxResults
1.209 + The maximum number of matches expected in the recognition result.
1.210 +
1.211 + @since 8.0
1.212 + */
1.213 + IMPORT_C void SetMaxResultsL(TInt aMaxResults);
1.214 +
1.215 + /**
1.216 + Returns the current value of the max number of expected after recognition.
1.217 +
1.218 + @return The maximum number of best matches (N-best) expected in the recognition result.
1.219 +
1.220 + @since 8.0
1.221 + */
1.222 + IMPORT_C TInt MaxResults() const;
1.223 +
1.224 + /**
1.225 + Returns a result at a given index within the result set.
1.226 +
1.227 + @param aIndex
1.228 + The index of result to return.
1.229 +
1.230 + @return A pointer to CSDClientResult object.
1.231 +
1.232 + @since 8.0
1.233 + */
1.234 + IMPORT_C const CSDClientResult& At(TInt aIndex) const;
1.235 +
1.236 + /**
1.237 + Sets the number of results actually returned after recogntion.
1.238 +
1.239 + @param aResultCount
1.240 + The number of results returned by the recognizer.
1.241 +
1.242 + @since 8.0
1.243 + */
1.244 + IMPORT_C void SetResultCount(TInt aResultCount);
1.245 +
1.246 + /**
1.247 + Returns the number of results actually returned after recogntion.
1.248 +
1.249 + @return The number of results actually returned after recogntion.
1.250 +
1.251 + @since 8.0
1.252 + */
1.253 + IMPORT_C TInt ResultCount() const;
1.254 +
1.255 + /**
1.256 + Sets the diagnostic of this result set.
1.257 +
1.258 + @param aDiagnostic
1.259 + The reference to the diagostic object.
1.260 +
1.261 + @since 8.0
1.262 + */
1.263 + IMPORT_C void SetDiagnostic(TDiagnostic& aDiagnostic);
1.264 +
1.265 + /**
1.266 + Gets the diagnostic of this result set.
1.267 +
1.268 + @return A reference to TDiagnostic object.
1.269 +
1.270 + @since 8.0
1.271 + */
1.272 + IMPORT_C const TDiagnostic& Diagnostic() const;
1.273 +
1.274 +
1.275 + /**
1.276 + Writes the state of the class to a stream.
1.277 +
1.278 + @param aStream
1.279 + The stream to write to.
1.280 +
1.281 + @since 8.0
1.282 + */
1.283 + IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
1.284 +
1.285 + /**
1.286 + Restores the state of the object from a stream.
1.287 +
1.288 + @param aStream
1.289 + The stream to read from.
1.290 +
1.291 + @since 8.0
1.292 + */
1.293 + IMPORT_C void InternalizeL(RReadStream& aStream);
1.294 +
1.295 +private:
1.296 + void ConstructL();
1.297 + CSDClientResultSet();
1.298 +
1.299 +private:
1.300 + TInt iMaxResults; // maximum number of results
1.301 + TInt iResultCount; // number of recognition results
1.302 + RPointerArray<CSDClientResult> iResultArray; // array of recognition results
1.303 + TDiagnostic* iDiagnostic; // diagnostic information
1.304 + };
1.305 +
1.306 +#endif // __SPEECHRECOGNITIONDATACLIENT_H__
1.307 +