srsf/nssvasapi/nssvascore/inc/nssvasccontext.h
branchRCL_3
changeset 23 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
22:cad71a31b7fc 23:e36f3802f733
       
     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:  CContext class provides context processing. It implements 
       
    15 *               MNssContext interface.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef NSSVASCCONTEXT_H
       
    21 #define NSSVASCCONTEXT_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <nsssispeechrecognitiondatacommon.h>
       
    25 #include "nssvascoreconstant.h"
       
    26 #include "nssvasmcontext.h"
       
    27 #include "nssvasccontextsrsportal.h"
       
    28 #include "nssvasmcoresrsdbeventhandler.h"
       
    29 #include "nssvascoreconstant.h"
       
    30 
       
    31 
       
    32 class CNssContextSrsPortal;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 *  CContext is the implementation class for MNssContext. 
       
    38 *  It encapsulates context data. A context cannot be directly created by a 
       
    39 *  client. A client has to own an instance of Context Manager which has methods 
       
    40 *  for creating context objects. The CContext class also provides additional 
       
    41 *  members for internal use by NssVAS.
       
    42 *  @lib NssVASApi.lib
       
    43 *  @since 2.0
       
    44 */
       
    45 
       
    46 class CNssContext: public CBase, public MNssContext
       
    47 {
       
    48 public:
       
    49     /**
       
    50     * C++ constructor.
       
    51     */
       
    52 	CNssContext(CNssContextSrsPortal* aContextSrsPortal);
       
    53 
       
    54     /**
       
    55     * Destructor.
       
    56     */
       
    57 	~CNssContext();
       
    58 
       
    59 public: // functions for internal VAS use
       
    60 
       
    61     /**
       
    62     * Get the context id
       
    63 	* for internal use
       
    64 	* @since 2.0
       
    65     * @param 
       
    66     * @return context id
       
    67     */
       
    68 	TInt ContextId() const;
       
    69 
       
    70     /**
       
    71     * Get the grammar id
       
    72 	* for internal use
       
    73 	* @since 2.0
       
    74     * @param 
       
    75     * @return grammar id
       
    76     */
       
    77 	TUint32 GrammarId() const;
       
    78 
       
    79 	/**
       
    80     * Get the lexicon id
       
    81 	* for internal use
       
    82 	* @since 2.0
       
    83     * @param 
       
    84     * @return lexicon id
       
    85     */
       
    86 	TUint32 LexiconId() const;
       
    87 
       
    88 	/**
       
    89     * Get the model bank id
       
    90 	* for internal use
       
    91 	* @since 2.0
       
    92     * @param 
       
    93     * @return model bank id
       
    94     */
       
    95 	TUint32 ModelBankId() const;
       
    96 
       
    97 	/**
       
    98     * Get the recognition mode
       
    99 	* for internal use
       
   100 	* @since 2.8
       
   101     * @param none
       
   102     * @return recognition technology (SI / SD)
       
   103     */
       
   104 	TNSSRecognitionMode RecognitionMode() const;
       
   105 
       
   106     /**
       
   107     * Set the context id 
       
   108 	* for internal use
       
   109 	* @since 2.0
       
   110     * @param aContextId - the context id 
       
   111     * @return 
       
   112     */
       
   113 	void SetContextId(TInt aContextId);
       
   114 
       
   115 	/**
       
   116     * Set the grammar id 
       
   117 	* for internal use
       
   118 	* @since 2.0
       
   119     * @param aGrammarId - the grammar id
       
   120     * @return 
       
   121     */
       
   122 	void SetGrammarId(TUint32 aGrammarId);
       
   123 
       
   124 	/**
       
   125     * Set the lexicon id
       
   126 	* for internal use
       
   127 	* @since 2.0
       
   128     * @param aLexiconId - the lexicon id
       
   129     * @return id
       
   130     */
       
   131 	void SetLexiconId(TUint32 aLexiconId);
       
   132 
       
   133 	/**
       
   134     * Set the model bank id
       
   135 	* for internal use
       
   136 	* @since 2.0
       
   137     * @param aModelBankId - the model bank id
       
   138     * @return id
       
   139     */
       
   140 	void SetModelBankId(TUint32 aModelBankId);
       
   141 
       
   142     /**
       
   143     * Set the speech technology (Speaker independent or dependent)
       
   144     * for internal use
       
   145     * @since 2.0
       
   146     * @param aRecognitionMode - the recognition mode
       
   147     * @return none
       
   148     */
       
   149     void SetRecognitionMode(TNSSRecognitionMode aRecognitionMode);
       
   150 
       
   151 	/**
       
   152     * Save the context to the SRS. 
       
   153 	* for internal use
       
   154 	* This method is used to save the context to the SRS.
       
   155 	* This creates the model bank, 
       
   156 	* lexicon, and grammar for a context. Model bank, and lexicon 
       
   157 	* are created only for the first time, and are thus, fixed.
       
   158 	* For every context, there is one grammar id. After, model bank,
       
   159 	* lexicon, and grammar are created, the corresponding Ids are 
       
   160 	* set in the context object.
       
   161 	* @since 2.0
       
   162     * @param
       
   163     * @return none
       
   164     */
       
   165 	void BeginSaveToSrsL(MNssCoreSrsDBEventHandler* aSrsDBEventHandler);
       
   166 
       
   167 	/**
       
   168     * Delete the context from the SRS. 
       
   169 	* for internal use
       
   170 	* deletes grammar from SRS
       
   171 	* @since 2.0
       
   172     * @param 
       
   173     * @return none
       
   174     */
       
   175 	void BeginDeleteFromSrsL(MNssCoreSrsDBEventHandler* aSrsDBEventHandler);
       
   176 
       
   177 	/**
       
   178     * Commit the context from the SRS. 
       
   179 	* for internal use
       
   180 	* Commit the changes from SRS
       
   181 	* @since 2.0
       
   182     * @param 
       
   183     * @return 
       
   184     */
       
   185 	TInt CommitSrsChanges();
       
   186 
       
   187 	/**
       
   188     * Don't commit the context from the SRS. 
       
   189 	* for internal use
       
   190 	* Doesn't commit the changes from SRS
       
   191 	* @since 2.8
       
   192     * @param 
       
   193     * @return 
       
   194     */
       
   195 	TInt RollbackSrsChanges();
       
   196 
       
   197     /**
       
   198     * Set/Reset the iModelBankAndLexiconExist flag.
       
   199 	* for internal use
       
   200 	* @since 2.0
       
   201     * @param aVal, ETrue to set, EFalse to reset
       
   202     * @return 
       
   203     */
       
   204 	void SetModelBankAndLexiconExist(TBool aVal);
       
   205 
       
   206 	/**
       
   207     * Get the iModelBankAndLexiconExist flag
       
   208 	* for internal use
       
   209 	* @since 2.0
       
   210     * @param 
       
   211     * @return ETrue if set, else EFalse
       
   212     */
       
   213 	TBool ModelBankAndLexiconExist();
       
   214 
       
   215 	/**
       
   216     * overloaded assignment operator
       
   217 	* for internal use
       
   218 	* @since 2.0
       
   219     * @param reference to context
       
   220     * @return reference to the context
       
   221     */
       
   222 	CNssContext& operator=(const CNssContext& aContext);
       
   223 
       
   224 	/**
       
   225     * Create a copy of the context. 
       
   226 	* for internal use
       
   227 	* This function creates a new context by allocating memory for
       
   228 	* a new context, and deep copying the members of the context on which
       
   229 	* this fucntion is called. Old context and new context exist. Client need
       
   230 	* to deallocate memory.
       
   231 	* @since 2.0
       
   232     * @param 
       
   233     * @return pointer the newly created context.
       
   234     */
       
   235 	CNssContext* CopyL();
       
   236 
       
   237     /**
       
   238     * Sets/Resets the client data. The data must be saved with
       
   239     * MNssContextMgr::SaveClientData after this call.
       
   240     * @since 2.8
       
   241     * @param aData At most 100 bytes of serialized client data.
       
   242     */
       
   243     void SetClientData(const TDesC8& aData);
       
   244 
       
   245     /**
       
   246     * Gets the client data.
       
   247     * @since 2.8
       
   248     * @return At most 100 bytes of data.
       
   249     */
       
   250     const TDesC8& ClientData();
       
   251 
       
   252 public: // functions derived from MNssContext
       
   253 
       
   254    /**
       
   255    * Get the name of the context
       
   256    * @since 2.0
       
   257    * @param 
       
   258    * @return reference to name of context
       
   259    */  
       
   260    TDesC& ContextName();
       
   261 
       
   262 	/**
       
   263    * Is the context global
       
   264    * @since 2.0
       
   265    * @param 
       
   266    * @return ETrue if context is global, EFalse otherwise
       
   267    */  
       
   268    TBool IsGlobal();
       
   269 
       
   270 	/**
       
   271     * Sets the name of the context
       
   272 	* @since 2.0
       
   273     * @param aName name of the context as a descriptor
       
   274     * @return 
       
   275     */  
       
   276     void SetNameL(const TDesC& aName);
       
   277 
       
   278    /**
       
   279    * Sets/Resets the global flag for the context
       
   280    * @since 2.0
       
   281    * @param aGlobal ETrue to set the context as global, EFalse as not global 
       
   282    * @return 
       
   283    */  
       
   284    void SetGlobal(TBool aGlobal);
       
   285 
       
   286 private: // data
       
   287 
       
   288 	// name of the context
       
   289 	HBufC*				iName;
       
   290 
       
   291 	// context id, used by the VAS DB
       
   292 	TInt				iContextId;
       
   293 
       
   294 	// global flag
       
   295 	TBool				iGlobal;
       
   296 
       
   297 	// grammar id
       
   298 	TUint32		        iGrammarId;
       
   299 
       
   300 	// lexicon id
       
   301 	TUint32             iLexiconId;
       
   302 
       
   303 	// model bank id
       
   304 	TUint32             iModelBankId;
       
   305 
       
   306 	// association to context srs portal 
       
   307 	CNssContextSrsPortal*	iContextSrsPortal;
       
   308 	
       
   309 	// flag to denote if Model Bank and Lexicon already created
       
   310 	TBool				iModelBankAndLexiconExist;
       
   311 
       
   312     // differentiates between SI and SD contexts
       
   313     TNSSRecognitionMode iRecognitionMode;
       
   314 
       
   315     // client payload data
       
   316     TBuf8<100>          iClientData;
       
   317 };
       
   318 
       
   319 
       
   320 #endif // NSSVASCCONTEXT  
       
   321             
       
   322 // End of File