mulwidgets/muldatamodel/src/mulmodelfactoryplugin.cpp
changeset 0 e83bab7cf002
equal deleted inserted replaced
-1:000000000000 0:e83bab7cf002
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Plugin factory implementation for model.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mulmodelfactoryplugin.h"
       
    19 
       
    20 #include <osn/ustring.h>
       
    21 #include "alf/alfwidget.h"
       
    22 #include <ecom/ecom.h>
       
    23 #include <libc/string.h>
       
    24 
       
    25 #include <mul/imulmodel.h>
       
    26 
       
    27 #include "mulmodelimpl.h"
       
    28 
       
    29 using namespace osncore;
       
    30 
       
    31 namespace Alf
       
    32     {
       
    33 
       
    34 const TInt KMulModelFactoryPluginUid = {0x2000D23F};
       
    35 const int KProductCount = 1;
       
    36 
       
    37 // ======== MEMBER FUNCTIONS ========
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // Two-phased Symbian constructor.
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 MulFactoryPlugin* MulFactoryPlugin::NewL()
       
    44     {
       
    45     return new (ELeave) MulFactoryPlugin;
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Destructor.
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 MulFactoryPlugin::~MulFactoryPlugin()
       
    53     {
       
    54     }
       
    55     
       
    56 // ---------------------------------------------------------------------------
       
    57 // Creates either a list widget or a list model.
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 IAlfInterfaceBase* MulFactoryPlugin::createProduct(const char* aProduct,
       
    61 													void* /*aInitData*/ )
       
    62     {
       
    63     IAlfInterfaceBase* ret(0);
       
    64    const char* KLoadNameModel("mulmodel");
       
    65    //if( !strcmp( aProduct, IMulModel::Type().iImplementationId ) )
       
    66    if( !strcmp( aProduct, KLoadNameModel ) )
       
    67         {
       
    68         // create list model
       
    69         IMulModel* model = new (EMM) MulModelImpl();
       
    70         ret = IAlfInterfaceBase::makeInterface<IMulModel>( model );    
       
    71         }
       
    72     return ret;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // From MAlfInterfaceBase.
       
    77 // Creates interface based on the given type.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 IAlfInterfaceBase* MulFactoryPlugin::makeInterface(const IfId& aType)
       
    81     {
       
    82     UString param( aType.mImplementationId );
       
    83     
       
    84     if( param == UString( IAlfFactoryPlugin::type().mImplementationId ) )
       
    85         {
       
    86         return static_cast<IAlfFactoryPlugin*>( this );            
       
    87         }
       
    88     return NULL;
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // Returns the amount of products this factory can produce.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 int MulFactoryPlugin::productCount()const
       
    96     {
       
    97     return KProductCount;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // Returns product information.
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 const char* MulFactoryPlugin::productInfo(int aIndex)const
       
   105     {
       
   106     switch( aIndex )
       
   107         {
       
   108         case 0: return mulmodel::Ident.mImplementationId;
       
   109         default: break;            
       
   110         }  
       
   111     return 0;
       
   112     }
       
   113     
       
   114     } // namespace Alf
       
   115 
       
   116 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   117 
       
   118 using namespace Alf;
       
   119 const TImplementationProxy ImplementationTable[] =
       
   120     {
       
   121 #ifdef __EABI__ 
       
   122 	IMPLEMENTATION_PROXY_ENTRY( KMulModelFactoryPluginUid, 
       
   123 								MulFactoryPlugin::NewL )
       
   124 	#else
       
   125     { {KMulModelFactoryPluginUid}, MulFactoryPlugin::NewL }
       
   126 #endif
       
   127     };
       
   128 
       
   129 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   130     {
       
   131     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
   132 
       
   133     return ImplementationTable;
       
   134     }
       
   135     
       
   136