1 /* |
|
2 * Copyright (c) 2002-2007 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: This class handles the storage and access of speaker independent |
|
15 * lexicons. It is also responsible for allocating memory when |
|
16 * loading lexicons into the recognizer. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef SILEXICONDB_H |
|
23 #define SILEXICONDB_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <nsssispeechrecognitiondatadevasr.h> |
|
27 #include "sicommondb.h" |
|
28 |
|
29 // CLASS DECLARATION |
|
30 /** |
|
31 * This class implements Speaker Inependent Lexicon Database. |
|
32 * |
|
33 * @lib SIControllerPlugin.lib |
|
34 * @since 2.0 |
|
35 */ |
|
36 class CSILexiconDB : public CSICommonDB |
|
37 { |
|
38 public: // Constructors and destructor |
|
39 |
|
40 /** |
|
41 * Two-phased constructor. |
|
42 */ |
|
43 static CSILexiconDB* NewL( RDbNamedDatabase& aDatabase, |
|
44 RDbs& aDbSession, |
|
45 TInt aDrive ); |
|
46 |
|
47 /** |
|
48 * Destructor. |
|
49 */ |
|
50 virtual ~CSILexiconDB(); |
|
51 |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Adds a new pronunciation into the specified lexicon. |
|
56 * @since 2.0 |
|
57 * @param aClientUid client's Uid for data ownership |
|
58 * @param aLexiconID lexicon Id |
|
59 * @param aModelBankID model bank Id |
|
60 * @param aPhonemeID phoneme Id |
|
61 * @return new pronunciation Id |
|
62 */ |
|
63 TSIPronunciationID AddPronunciationL( TUid aClientUid, TSILexiconID aLexiconID, |
|
64 TDesC8& aPronunciation, TSIModelBankID aModelBankID ); |
|
65 |
|
66 /** |
|
67 * Inserts the externalized SI Lexicon into the specified grammar table. |
|
68 * @since 2.0 |
|
69 * @param aClientUid client's Uid for data ownership |
|
70 * @param aSILexicon lexicon to be updated |
|
71 */ |
|
72 void UpdateLexiconL( TUid aClientUid, CSILexicon* aSILexicon ); |
|
73 |
|
74 /** |
|
75 * Creates a new lexicon ID table in the database. |
|
76 * @since 2.0 |
|
77 */ |
|
78 void CreateIDTableL(); |
|
79 |
|
80 /** |
|
81 * Creates a new lexicon in the database. |
|
82 * @since 2.0 |
|
83 * @param aClientUid client's Uid for data ownership |
|
84 * @return new lexicon Id |
|
85 */ |
|
86 TSILexiconID CreateLexiconL( TUid aClientUid ); |
|
87 |
|
88 |
|
89 /** |
|
90 * Returns all lexicon Ids that belong to the specified client. |
|
91 * @since 2.0 |
|
92 * @param aClientUid client's Uid for data ownership |
|
93 * @param aLexiconIDs reference where lexicon Ids are stored |
|
94 */ |
|
95 void GetAllClientLexiconIDsL( TUid aClientUid, RArray<TSILexiconID>& aLexiconIDs ); |
|
96 |
|
97 /** |
|
98 * Returns all lexicon Ids in the database. |
|
99 * @since 2.0 |
|
100 * @param aLexiconIDs reference where lexicon Ids are stored |
|
101 */ |
|
102 void GetAllLexiconIDsL( RArray<TSILexiconID>& aLexiconIDs ); |
|
103 |
|
104 /** |
|
105 * Returns all pronunciation Ids that exist in the specified lexicon. |
|
106 * @since 2.0 |
|
107 * @param aLexiconID lexicon Id |
|
108 * @param aPronunciationIDs reference where pronunciation Ids are stored |
|
109 */ |
|
110 void GetAllPronunciationIDsL( TSILexiconID aLexiconID, RArray<TSIPronunciationID>& aPronunciationIDs ); |
|
111 |
|
112 /** |
|
113 * Returns the number of pronunciations in the specified lexicon. |
|
114 * @since 2.0 |
|
115 * @param aLexiconID lexicon Id |
|
116 * @return Number of pronunciations |
|
117 */ |
|
118 TInt PronunciationCountL( TSILexiconID aLexiconID ); |
|
119 |
|
120 /** |
|
121 * Checks if the pronunciation is valid or not. |
|
122 * @since 2.0 |
|
123 * @param aLexiconID lexicon Id |
|
124 * @param aPronunciationID pronunciation Id |
|
125 * @return ETrue if the pronunciation is valid |
|
126 */ |
|
127 TBool IsPronunciationValidL( TSILexiconID aLexiconID, TSIPronunciationID aPronunciationID ); |
|
128 |
|
129 /** |
|
130 * Removes the specified lexicon from the database. |
|
131 * Removing a lexicon will remove all pronunciations within the lexicon. |
|
132 * @since 2.0 |
|
133 * @param aClientUid client's Uid for data ownership |
|
134 * @param aLexiconID lexicon Id |
|
135 */ |
|
136 void RemoveLexiconL( TUid aClientUid, TSILexiconID aLexiconID ); |
|
137 |
|
138 /** |
|
139 * Removes the specified pronunciation from the database. |
|
140 * @since 2.0 |
|
141 * @param aClientUid client's Uid for data ownership |
|
142 * @param aLexiconID lexicon Id |
|
143 * @param aPronunciationID pronunciation Id |
|
144 */ |
|
145 void RemovePronunciationL( TUid aClientUid, TSILexiconID aLexiconID, TSIPronunciationID aPronunciationID ); |
|
146 |
|
147 /** |
|
148 * Deallocates the temporary memory containing the lexicon object created with AllPronunciationsL. |
|
149 * @since 2.0 |
|
150 */ |
|
151 void ResetAndDestroy(); |
|
152 |
|
153 /** |
|
154 * Get a new uniq ID |
|
155 * @since 2.0 |
|
156 * @param Rule ID array |
|
157 * @param |
|
158 * @return Error code |
|
159 */ |
|
160 TInt GetNewID( RArray<TSIRuleID>& aMyIds ) ; |
|
161 |
|
162 /** |
|
163 * This function returns lexicon based on given id |
|
164 * @since 2.0 |
|
165 * @param aLexiconID lexicon Id |
|
166 * @return Lexicon containing all pronunciations |
|
167 */ |
|
168 CSILexicon* LexiconL( TSILexiconID aLexiconID ); |
|
169 |
|
170 private: |
|
171 |
|
172 /** |
|
173 * C++ default constructor. |
|
174 */ |
|
175 CSILexiconDB( RDbNamedDatabase& aDatabase, RDbs& aDbSession, TInt aDrive ); |
|
176 |
|
177 /** |
|
178 * By default Symbian 2nd phase constructor is private. |
|
179 */ |
|
180 void ConstructL(); |
|
181 |
|
182 private: // Data |
|
183 |
|
184 // Temporary memory where loaded lexicons are held during recognition session |
|
185 RPointerArray<CSILexicon> iLexiconArray; |
|
186 CSILexicon* iLexicon; |
|
187 }; |
|
188 |
|
189 #endif // SILEXICONDB_H |
|
190 |
|
191 // End of File |
|