First public contribution.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __SDDATABASE_H__
17 #define __SDDATABASE_H__
21 class CSecurityDecryptBase;
22 class CSecurityEncryptBase;
26 #include <mmf/common/speechrecognitiondatacommon.h>
29 class CSDDatabase : public CBase
32 class TPronunciationData
35 TPronunciationID iPronunciationID;
36 TModelBankID iModelBankID;
44 TLexiconID iLexiconID;
45 TPronunciationID iPronunciationID;
52 TUint32 iUtteranceDurationMicroSeconds;
60 RSDGrammarTable(CSDDatabase& aDatabase);
62 void OpenL(TBool aOwnedByClient = EFalse);
64 void CreateGrammarL(TGrammarID& aGrammarID);
65 void AddGrammarL(TGrammarID aGrammarID);
66 void RemoveGrammarL(TGrammarID aGrammarID);
68 TBool FindGrammarL(TGrammarID aGrammarID);
69 void GetAllGrammarIDsL(RArray<TGrammarID>& aGrammarIDs);
73 CSDDatabase& iDatabase;
80 RSDLexiconTable(CSDDatabase& aDatabase);
82 void OpenL(TBool aOwnedByClient = EFalse);
84 void CreateLexiconL(TLexiconID& aLexiconID);
85 void AddLexiconL(TLexiconID aLexiconID);
86 void RemoveLexiconL(TLexiconID aLexiconID);
88 TBool FindLexiconL(TLexiconID aLexiconID);
89 void GetAllLexiconIDsL(RArray<TLexiconID>& aLexiconIDs);
93 CSDDatabase& iDatabase;
97 class RSDModelBankTable
100 RSDModelBankTable(CSDDatabase& aDatabase);
102 void OpenL(TBool aOwnedByClient = EFalse);
104 TModelBankID CreateModelBankL();
105 void AddModelBankL(TModelBankID aModelBankID);
106 void RemoveModelBankL(TModelBankID aModelBankID);
108 TBool FindModelBankL(TModelBankID aModelBankID);
109 void GetAllModelBankIDsL(RArray<TModelBankID>& aModelBankIDs);
113 CSDDatabase& iDatabase;
120 RSDRuleTable(CSDDatabase& aDatabase);
122 void OpenL(TGrammarID aGrammarID);
124 TRuleID CreateRuleL(TRuleData aRuleData);
125 void AddRuleL(TRuleData aRuleData);
126 void RemoveRuleL(TRuleID aRuleID);
128 void GetRuleDataL(TRuleID aRuleID, TRuleData& aRuleData);
130 TBool FindRuleL(TRuleID aRuleID);
131 TBool IsRuleValidL(TRuleID aRuleID);
132 void GetAllRuleIDsL(RArray<TRuleID>& aRuleIDs);
136 CSDDatabase& iDatabase;
138 TGrammarID iGrammarID;
141 class RSDPronunciationTable
144 RSDPronunciationTable(CSDDatabase& aDatabase);
146 void OpenL(TLexiconID aLexiconID);
148 TPronunciationID CreatePronunciationL(TPronunciationData aPronunciationData);
149 void AddPronunciationL(TPronunciationData aPronunciationData);
150 void RemovePronunciationL(TPronunciationID aPronunciationID);
151 void GetPronunciationDataL(TPronunciationID aPronunciationID, TPronunciationData& aPronunciationData);
153 TBool FindPronunciationL(TPronunciationID aPronunciationID);
154 void GetAllPronunciationIDsL(RArray<TPronunciationID>& aPronunciationIDs);
158 CSDDatabase& iDatabase;
160 TLexiconID iLexiconID;
169 RSDModelTable(CSDDatabase& aDatabase);
171 void OpenL(TModelBankID aModelBankID);
173 TModelID CreateModelL(TModelData aModelData);
174 void AddModelL(TModelData aModelData);
175 void RemoveModelL(TModelID aModelID);
177 void GetModelDataL(TModelID aModelID, TModelData& aModelData);
179 TBool FindModelL(TModelID aModelID);
180 void GetAllModelIDsL(RArray<TModelID>& aModelIDs);
184 CSDDatabase& iDatabase;
186 TModelBankID iModelBankID;
189 class RSDSettingsTable
192 RSDSettingsTable(CSDDatabase& aDatabase);
196 TUint32 GetValueL(TUint32 aIndex);
197 void SetValueL(TUint32 aIndex, TUint32 aValue);
202 CSDDatabase& iDatabase;
212 static CSDDatabase* NewL(const TDesC& aFileName, TBool aUseExisting=ETrue);
214 TGrammarID CreateGrammarL();
215 void AddGrammarL(TGrammarID aGrammarID);
216 void RemoveGrammarL(TGrammarID aGrammarID);
217 void GetAllGrammarIDsL(RArray<TGrammarID>& aGrammarIDs, TBool aOwnedByClient=EFalse);
218 TBool GrammarExistsL(TGrammarID aGrammarID);
220 TLexiconID CreateLexiconL();
221 void AddLexiconL(TLexiconID aLexiconID);
222 void RemoveLexiconL(TLexiconID aLexiconID);
223 void GetAllLexiconIDsL(RArray<TLexiconID>& aLexiconIDs, TBool aOwnedByClient=EFalse);
224 TBool LexiconExistsL(TLexiconID aLexiconID);
226 TModelBankID CreateModelBankL();
227 void AddModelBankL(TModelBankID aModelBankID);
228 void RemoveModelBankL(TModelBankID aModelBankID);
229 void GetAllModelBankIDsL(RArray<TModelBankID>& aModelBankIDs, TBool aOwnedByClient=EFalse);
230 TBool ModelBankExistsL(TModelBankID aModelBankID);
233 TRuleID CreateRuleL(TGrammarID aGrammarID, TRuleData aRuleData);
234 void AddRuleL(TGrammarID aGrammarID, TRuleData aRuleData);
235 void RemoveRuleL(TGrammarID aGrammarID, TRuleID aRuleID);
236 void GetAllRuleIDsL(TGrammarID aGrammarID, RArray<TRuleID>& aRuleIDs);
237 TBool RuleExistsL(TGrammarID aGrammarID, TRuleID aRuleID);
239 TPronunciationID CreatePronunciationL(TLexiconID aLexiconID, TPronunciationData aPronunciationData);
240 void AddPronunciationL(TLexiconID aLexiconID, TPronunciationData aPronunciationData);
241 void RemovePronunciationL(TLexiconID aLexiconID, TPronunciationID aPronunciationID);
242 void GetPronunciationDataL(TLexiconID aLexiconID, TPronunciationID aPronunciationID, TPronunciationData& aPronunciation);
243 void GetAllPronunciationIDsL(TLexiconID aLexiconID, RArray<TPronunciationID>& aPronunciationID);
244 TBool PronunciationExistsL(TLexiconID aLexiconID, TPronunciationID aPronunciationID);
246 TModelID CreateModelL(TModelBankID aModelBankID, TModelData aModelData);
247 void AddModelL(TModelBankID aModelBankID, TModelData aModelData);
248 void RemoveModelL(TModelBankID aModelBankID, TModelID aModelID);
249 void GetModelDataL(TModelBankID aModelBankID, TModelID aModelID, TModelData& aModelData);
250 void GetAllModelIDsL(TModelBankID aModelBankID, RArray<TModelID>& aModelIDs);
251 TBool ModelExistsL(TModelBankID aModelBankID, TModelID aModelID);
255 RDbDatabase& Database();
257 void StartTransactionL();
258 void CommitChangesL();
260 TUint32 AllocNewIDL();
261 void UpdateLastIDL(TUint32 aLastID);
263 void SetClientUid(TUid aClientUid);
266 void CreateTestDatabaseL();
269 void OpenDatabaseL(const TDesC& aFileName);
270 void CreateDatabaseL(const TDesC& aFileName);
272 void DoCreateTablesL();
273 void DoCreateIndexesL();
277 void ConstructL(const TDesC& aFileName, TBool aUseExisting);
281 CFileStore* iDbStore;
282 RDbStoreDatabase iDatabase;
283 TBool iDatabaseOpened;
289 #endif //__SDDATABASE_H__