mpviewplugins/mpsettingsviewplugin/tsrc/unittest_mpsettingsaudioeffectswidget/stub/src/mpenginefactory.cpp
changeset 45 612c4815aebe
child 47 4cc1412daed0
equal deleted inserted replaced
43:0f32e550d9d8 45:612c4815aebe
       
     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 }
       
    44 
       
    45 /*!
       
    46  Returns the singleton instance of music player engine factory.
       
    47  */
       
    48 MpEngineFactory * MpEngineFactory::instance()
       
    49 {
       
    50     static MpEngineFactory instance;
       
    51     return &instance;
       
    52 }
       
    53 
       
    54 /*!
       
    55  Returns an instance to an engine with \a hostUid, and \a mode, if the shared engine is 
       
    56  already created parameters are ignored.
       
    57  */
       
    58 MpEngine *MpEngineFactory::createSharedEngine( TUid hostUid , MpEngine::EngineMode mode )
       
    59 {
       
    60     Q_UNUSED( hostUid );
       
    61     Q_UNUSED( mode );
       
    62     if ( !instance()->mSharedEngine ) {
       
    63         instance()->mSharedEngine = new MpEngine();
       
    64     }
       
    65     return instance()->mSharedEngine;
       
    66 }
       
    67 
       
    68 /*!
       
    69  Returns an instance to the current shared engine previously created with createEngine().
       
    70  */
       
    71 MpEngine *MpEngineFactory::sharedEngine()
       
    72 {
       
    73     return instance()->mSharedEngine;
       
    74 }
       
    75 
       
    76 /*!
       
    77  Closes all engines created on this process.
       
    78  */
       
    79 void MpEngineFactory::close()
       
    80 {
       
    81     if ( instance()->mSharedEngine ) {
       
    82         delete instance()->mSharedEngine;
       
    83         instance()->mSharedEngine = 0;
       
    84         
       
    85     }
       
    86 }