mpviewplugins/mpmediawallviewplugin/tsrc/unittest_mpmediawallview/stub/src/mpenginefactory.cpp
changeset 47 4cc1412daed0
child 55 f3930dda3342
equal deleted inserted replaced
45:612c4815aebe 47:4cc1412daed0
       
     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: mp engine factory.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mpengine.h"
       
    19 #include "mpenginefactory.h"
       
    20 #include "mptrace.h"
       
    21 
       
    22 /*!
       
    23     \class MpEngineFactory
       
    24     \brief Music Player engine factory.
       
    25 
       
    26     MP Engine factory is responsible to create and mantain ownership of MP engines.
       
    27 */
       
    28 
       
    29 /*!
       
    30  Constructs music player engine factory.
       
    31  */
       
    32 MpEngineFactory::MpEngineFactory()
       
    33     : mSharedEngine( 0 )
       
    34 {
       
    35     TX_ENTRY_ARGS("Stub")
       
    36 }
       
    37 
       
    38 /*!
       
    39  Destructs music player engine factory.
       
    40  */
       
    41 MpEngineFactory::~MpEngineFactory()
       
    42 {
       
    43     TX_ENTRY_ARGS("Stub")
       
    44 }
       
    45 
       
    46 /*!
       
    47  Returns the singleton instance of music player engine factory.
       
    48  */
       
    49 MpEngineFactory * MpEngineFactory::instance()
       
    50 {
       
    51     TX_LOG_ARGS("MpEngineFactory::instance() Stub")
       
    52     static MpEngineFactory instance;
       
    53     return &instance;
       
    54 }
       
    55 
       
    56 /*!
       
    57  Returns an instance to an engine with \a hostUid, and \a mode, if the shared engine is 
       
    58  already created parameters are ignored.
       
    59  */
       
    60 MpEngine *MpEngineFactory::createSharedEngine( TUid /*hostUid*/ , MpEngine::EngineMode /*mode*/ )
       
    61 {
       
    62     TX_LOG_ARGS("MpEngineFactory::createSharedEngine() Stub")
       
    63     if ( !instance()->mSharedEngine ) {
       
    64         instance()->mSharedEngine = new MpEngine();
       
    65     }
       
    66     return instance()->mSharedEngine;
       
    67 }
       
    68 
       
    69 /*!
       
    70  Returns an instance to the current shared engine previously created with createEngine().
       
    71  */
       
    72 MpEngine *MpEngineFactory::sharedEngine()
       
    73 {
       
    74     return instance()->mSharedEngine;
       
    75 }
       
    76 
       
    77 /*!
       
    78  Closes all engines created on this process.
       
    79  */
       
    80 void MpEngineFactory::close()
       
    81 {
       
    82     if ( instance()->mSharedEngine ) {
       
    83         delete instance()->mSharedEngine;
       
    84         instance()->mSharedEngine = 0;        
       
    85     }
       
    86     MpEngine *ptr;
       
    87     foreach ( ptr, instance()->mEngines ) {
       
    88         delete ptr;
       
    89         ptr = 0;
       
    90     }
       
    91 }
       
    92 
       
    93 /*!
       
    94  Returns an instance to an isolated engine with \a mode.
       
    95  */
       
    96 MpEngine *MpEngineFactory::createIsolatedEngine( MpEngine::EngineMode /*mode*/ )
       
    97 {
       
    98     instance()->mEngines.append( new MpEngine() );    
       
    99     return instance()->mEngines.last();
       
   100 }