1 /* |
|
2 * Copyright (c) 2002-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: The CNssSpeechItemBuilder provides methods to create SpeechItem object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "nssvascspeechitembuilder.h" |
|
20 #include "rubydebug.h" |
|
21 |
|
22 // --------------------------------------------------------- |
|
23 // CNssSpeechItemBuilder::CNssSpeechItemBuilder |
|
24 // C++ default constructor can NOT contain any code, that |
|
25 // might leave. |
|
26 // --------------------------------------------------------- |
|
27 // |
|
28 CNssSpeechItemBuilder::CNssSpeechItemBuilder() |
|
29 { |
|
30 // Nothing |
|
31 } |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CNssSpeechItemBuilder::ConstructL |
|
35 // Symbian 2nd phase constructor can leave. |
|
36 // This is overloaded function for SpeechItemBuilder from database |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 void CNssSpeechItemBuilder::ConstructL( CNssVASDatabase *aDatabase ) |
|
40 { |
|
41 // create the Srs Potal object |
|
42 iPortal = CNssSpeechItemSrsPortal::NewL(); |
|
43 iTrainer = CNssSpeechItemTrainer::NewL( aDatabase ); |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CNssSpeechItemBuilder::NewL |
|
48 // Two-phased constructor. |
|
49 // This is for new SpeechItemBuilder |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CNssSpeechItemBuilder* CNssSpeechItemBuilder::NewL( CNssVASDatabase *aDatabase ) |
|
53 { |
|
54 RUBY_DEBUG_BLOCK( "CNssSpeechItemBuilder::NewL" ); |
|
55 |
|
56 CNssSpeechItemBuilder* self = NewLC( aDatabase ); |
|
57 CleanupStack::Pop( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CNssSpeechItemBuilder::NewLC |
|
63 // Two-phased constructor. |
|
64 // This is overloaded function for SpeechItemBuilder from database |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CNssSpeechItemBuilder* CNssSpeechItemBuilder::NewLC( CNssVASDatabase *aDatabase ) |
|
68 { |
|
69 CNssSpeechItemBuilder* self = new (ELeave) CNssSpeechItemBuilder(); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL( aDatabase ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CNssSpeechItemBuilder::CreateEmptySpeechItem |
|
77 // Creates a SpeechItem given a Context and a Portal |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 CNssSpeechItem* CNssSpeechItemBuilder::CreateEmptySpeechItemL( CNssContext& aContext ) |
|
81 { |
|
82 CNssSpeechItem *speechItem = CNssSpeechItem::NewL( aContext, *iPortal, *iTrainer ); |
|
83 speechItem->SetTagId( KNssVASDbDefaultValue ); //Identify as a new item |
|
84 return speechItem; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // CNssSpeechItemBuilder::CreateSpeechItem |
|
89 // Creates a SpeechItem given all data member values. |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 CNssSpeechItem* CNssSpeechItemBuilder::CreateSpeechItemL( CNssContext& aContext, |
|
93 TUint32 aRuleID, |
|
94 const TDesC& aText, |
|
95 TInt aTagID, |
|
96 TNssVasCoreConstant::TNssTrainedType aTrainedType ) |
|
97 { |
|
98 CNssSpeechItem *speechItem = CNssSpeechItem::NewL( aContext, *iPortal, |
|
99 *iTrainer, aRuleID, aText ); |
|
100 speechItem->SetTrainedType( aTrainedType ); |
|
101 speechItem->SetTagId( aTagID ); |
|
102 return speechItem; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // CNssSpeechItemBuilder::~CNssSpeechItemBuilder |
|
108 // Delete the SpeechItemBuilder object and set the Portal's |
|
109 // state to Terminate. |
|
110 // The Builder does not delete the Portal, the Portal |
|
111 // deletes itself. |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 CNssSpeechItemBuilder::~CNssSpeechItemBuilder() |
|
115 { |
|
116 RUBY_DEBUG0( "CNssSpeechItemBuilder::~CNssSpeechItemBuilder" ); |
|
117 |
|
118 if ( iPortal ) |
|
119 { |
|
120 //set the SRS Portal's state to termination |
|
121 iPortal->SetTerminationState(); |
|
122 } |
|
123 delete iTrainer; |
|
124 } |
|
125 |
|
126 // End of file |
|