omaprovisioning/provisioning/ProvisioningEngine/Src/WPElementFactory.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Factory for adapters.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 #include "WPElementFactory.h"
       
    21 #include "CWPCharacteristic.h"
       
    22 #include "CWPParameter.h"
       
    23 #include "CWPEngine.pan"
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // WPElementFactory::CreateCharacteristicL
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 EXPORT_C CWPCharacteristic* WPElementFactory::CreateCharacteristicL(
       
    32     TInt aType )
       
    33     {
       
    34     __ASSERT_DEBUG( aType > KWPParameter && aType <= KWPResource, 
       
    35         Panic( EWPIllegalCharacteristic ) );
       
    36     return CWPCharacteristic::NewL( aType );
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // WPElementFactory::CreateCharacteristicLC
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CWPCharacteristic* WPElementFactory::CreateCharacteristicLC( 
       
    44     TInt aType )
       
    45     {
       
    46     __ASSERT_DEBUG( aType > 0 && aType <= KWPResource,
       
    47         Panic( EWPIllegalCharacteristic ) );
       
    48     return CWPCharacteristic::NewLC( aType );
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // WPElementFactory::CreateCharacteristicL
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CWPCharacteristic* WPElementFactory::CreateCharacteristicL(
       
    56     const TDesC& aName )
       
    57     {
       
    58     CWPCharacteristic* result = 
       
    59         WPElementFactory::CreateCharacteristicLC( aName );
       
    60     CleanupStack::Pop(); // result
       
    61     return result;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // WPElementFactory::CreateCharacteristicLC
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CWPCharacteristic* WPElementFactory::CreateCharacteristicLC( 
       
    69     const TDesC& aName )
       
    70     {
       
    71     CWPCharacteristic* result = 
       
    72         CWPCharacteristic::NewLC( KWPNamedCharacteristic );
       
    73     result->SetNameL( aName );
       
    74     return result;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // WPElementFactory::CreateParameterL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C CWPParameter* WPElementFactory::CreateParameterL( TInt aID, 
       
    82                                                           const TDesC& aValue )
       
    83     {
       
    84     CWPParameter* param = CreateParameterLC( aID, aValue );
       
    85     CleanupStack::Pop( param );
       
    86     return param;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // WPElementFactory::CreateParameterLC
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 EXPORT_C CWPParameter* WPElementFactory::CreateParameterLC( TInt aID, 
       
    94                                                            const TDesC& aValue )
       
    95     {
       
    96     CWPParameter* param = CWPParameter::NewLC();
       
    97     param->SetID( aID );
       
    98     param->SetValueL( aValue );
       
    99 
       
   100     return param;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // WPElementFactory::CreateParameterL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C CWPParameter* WPElementFactory::CreateParameterL( const TDesC& aName, 
       
   108                                                           const TDesC& aValue )
       
   109     {
       
   110     CWPParameter* param = CreateParameterLC( aName, aValue );
       
   111     CleanupStack::Pop( param );
       
   112     return param;
       
   113     }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // WPElementFactory::CreateParameterLC
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 EXPORT_C CWPParameter* WPElementFactory::CreateParameterLC( const TDesC& aName, 
       
   120                                                           const TDesC& aValue )
       
   121     {
       
   122     CWPParameter* param = CWPParameter::NewLC();
       
   123     param->SetNameL( aName );
       
   124     param->SetValueL( aValue );
       
   125 
       
   126     return param;
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // WPElementFactory::CreateL
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C MWPElement* WPElementFactory::CreateL( TInt aType )
       
   134     {
       
   135     MWPElement* element = CreateLC( aType );
       
   136     CleanupStack::Pop( element );
       
   137     return element;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // WPElementFactory::CreateLC
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C MWPElement* WPElementFactory::CreateLC( TInt aType )
       
   145     {
       
   146     __ASSERT_DEBUG( aType >= KWPParameter 
       
   147         && aType <= KWPResource, Panic( EWPIllegalElement ) );
       
   148 
       
   149     MWPElement* element = NULL;
       
   150 
       
   151     if( aType == KWPParameter )
       
   152         {
       
   153         element = CWPParameter::NewLC();
       
   154         }
       
   155     else
       
   156         {
       
   157         element = CreateCharacteristicLC( aType );
       
   158         }
       
   159 
       
   160     return element;
       
   161     }
       
   162 
       
   163 //  End of File