srsf/nssvasapi/nssvascore/src/nssvasccontextbuilder.cpp
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:  CNssContextBuilder is the builder for context objects. It is owned 
       
    15 *               by the context manager. A client builds contexts by requesting the
       
    16 *               context manager which in turn forwards the request to context builder.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "nssvasccontextbuilder.h"
       
    23 #include "rubydebug.h"
       
    24 
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 // ---------------------------------------------------------
       
    29 // CNssContextBuilder::CNssContextBuilder
       
    30 // C++ constructor can NOT contain any code that
       
    31 // might leave.
       
    32 // ---------------------------------------------------------
       
    33 // 
       
    34 CNssContextBuilder::CNssContextBuilder()
       
    35     {
       
    36     // Nothing
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------
       
    40 // CNssContextBuilder::NewL
       
    41 // Two-phased constructor.
       
    42 // ---------------------------------------------------------
       
    43 // 
       
    44 CNssContextBuilder* CNssContextBuilder::NewL()
       
    45     {
       
    46     // Takes ages in strain test
       
    47     // RUBY_DEBUG0( "CNssContextBuilder::NewL" );
       
    48 
       
    49     CNssContextBuilder* self = NewLC();
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------
       
    55 // CNssContextBuilder::NewLC
       
    56 // Two-phased constructor.
       
    57 // ---------------------------------------------------------
       
    58 // 
       
    59 CNssContextBuilder* CNssContextBuilder::NewLC()
       
    60     {
       
    61     CNssContextBuilder* self = new (ELeave) CNssContextBuilder;
       
    62     
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     return self;
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------
       
    69 // CNssContextBuilder::~CNssContextBuilder
       
    70 // Destructor
       
    71 // ---------------------------------------------------------
       
    72 //    
       
    73 CNssContextBuilder::~CNssContextBuilder()
       
    74     {
       
    75     RUBY_DEBUG0( "CNssContextBuilder::~CNssContextBuilder" );
       
    76 
       
    77 	// do not delete the portal if ContextCount() > 0 
       
    78 	if ( iContextSrsPortal )
       
    79 	    {
       
    80     	iContextSrsPortal->SetTerminationState( CNssContextSrsPortal::EVASTERMINATION_PENDING );
       
    81     	if ( iContextSrsPortal->ContextCount() == 0 )
       
    82 	    	{
       
    83 			delete iContextSrsPortal;
       
    84 		    }    	
       
    85 	    }
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------
       
    89 // CNssContextBuilder::ConstructL
       
    90 // creates a context srs portal
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 void CNssContextBuilder::ConstructL()
       
    94     {
       
    95     iContextSrsPortal = new (ELeave) CNssContextSrsPortal();
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // CNssContextBuilder::CreateContextL
       
   100 // creates a context given all data member values.
       
   101 // ---------------------------------------------------------
       
   102 //
       
   103 CNssContext* CNssContextBuilder::CreateContextL( const TDesC& aName, 
       
   104                                                  TInt aContextId, 
       
   105                                                  TBool aGlobal, 
       
   106                                                  TUint32 aGrammarId, 
       
   107                                                  TUint32 aLexiconId, 
       
   108                                                  TUint32 aModelBankId, 
       
   109                                                  TUint32 /*iTrainType*/, 
       
   110                                                  const TDesC8& aClientData )
       
   111     {
       
   112     // Takes ages in strain test
       
   113     // RUBY_DEBUG_BLOCK( "CNssContextBuilder::CreateContextL" );
       
   114 
       
   115 	CNssContext *context = new (ELeave) CNssContext( iContextSrsPortal );
       
   116 	CleanupStack::PushL(context);
       
   117 	context->SetNameL( aName );
       
   118 	context->SetContextId( aContextId );
       
   119 	context->SetGlobal( aGlobal );
       
   120 	context->SetGrammarId( aGrammarId );
       
   121 	context->SetLexiconId( aLexiconId );
       
   122 	context->SetModelBankId( aModelBankId );
       
   123     context->SetClientData( aClientData );
       
   124 	CleanupStack::Pop(context);
       
   125 	return context;
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // CNssContextBuilder::CreateContextL
       
   130 // creates a context given lexicon id and model bank id
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 CNssContext* CNssContextBuilder::CreateContextL( TUint32 aLexiconId, 
       
   134                                                  TUint32 aModelBankId )
       
   135     {
       
   136     RUBY_DEBUG_BLOCK( "CNssContextBuilder::CreateContextL() - w/ lex id & model bank id" );
       
   137 
       
   138 	CNssContext *context = new (ELeave) CNssContext( iContextSrsPortal );
       
   139 	context->SetLexiconId( aLexiconId );
       
   140 	context->SetModelBankId( aModelBankId );
       
   141 	return context;
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 // CNssContextBuilder::CreateContextL
       
   146 // creates an empty context object
       
   147 // ---------------------------------------------------------
       
   148 //
       
   149 CNssContext* CNssContextBuilder::CreateContextL()
       
   150     {
       
   151     RUBY_DEBUG_BLOCK( "CNssContextBuilder::CreateContextL() - empty" );
       
   152 
       
   153     CNssContext *context = new (ELeave) CNssContext( iContextSrsPortal );
       
   154 	return context;
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------
       
   158 // CNssContextBuilder::GetContextPortal
       
   159 // returns the context SRS portal
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 CNssContextSrsPortal* CNssContextBuilder::GetContextPortal()
       
   163     {
       
   164 	return iContextSrsPortal;
       
   165     }
       
   166 
       
   167 //  End of File