taskswitcher/server/src/tsservicesprovider.cpp
changeset 116 305818acdca4
child 125 26079c1bb561
equal deleted inserted replaced
112:dbfb5e38438b 116:305818acdca4
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "tsservicesprovider.h"
       
    19 #include "tsservice.h"
       
    20 // -----------------------------------------------------------------------------
       
    21 /**
       
    22  * Symbian two phase constructor. Create and initialize services provider instance
       
    23  * @param aConfig - services provider configurator
       
    24  * @return address to initialized services provider instance 
       
    25  */
       
    26 CTsServiceProvider* CTsServiceProvider::NewL( 
       
    27                                        const CTsServiceProviderConfig& aConfig )
       
    28     {
       
    29     CTsServiceProvider* self = new (ELeave)CTsServiceProvider();
       
    30     self->Construct( aConfig );
       
    31     return self;
       
    32     }
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 /**
       
    36  * Constructor
       
    37  */
       
    38 CTsServiceProvider::CTsServiceProvider()
       
    39     {
       
    40     //No implementation required
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 /**
       
    45  * Function initialzie services provider. Using configurator load serivces
       
    46  * @param aConfig - serivces provider configurator
       
    47  * 
       
    48  */
       
    49 void CTsServiceProvider::Construct( const CTsServiceProviderConfig& aConfig )
       
    50     {
       
    51     CTsService* srvPtr(0);
       
    52     for( TInt iter(0); iter < aConfig.Count(); ++iter ) 
       
    53         {
       
    54         TRAP_IGNORE( srvPtr = CTsService::NewLC( aConfig.LoadL( iter ) );
       
    55                      iServices.AppendL( srvPtr );
       
    56                      CleanupStack::Pop( srvPtr ); )
       
    57         }
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 /**
       
    62  * Destructor. Release allocated resouces
       
    63  */
       
    64 CTsServiceProvider::~CTsServiceProvider()
       
    65     {
       
    66     iServices.ResetAndDestroy();
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 /**
       
    71  * Operator enable access to initialized service
       
    72  * @param aOffset - index of requested service
       
    73  * @return reference to MTsModel interface
       
    74  */
       
    75 MTsModel& CTsServiceProvider::operator[](TInt aOffset) const
       
    76     {
       
    77     return *( iServices[ aOffset ] );
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 /**
       
    82  * @return number of available services
       
    83  */
       
    84 TInt CTsServiceProvider::Count() const
       
    85     {
       
    86     return iServices.Count();
       
    87     }