menufw/hierarchynavigator/hnutilities/src/hnmdkeyfactory.cpp
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "hnmdbasekey.h"
       
    20 #include "hnmdstring8key.h"
       
    21 #include "hnmdintegerkey.h"
       
    22 #include "hnmdinteger64key.h"
       
    23 #include "hnmduintegerkey.h"
       
    24 #include "hnmduidkey.h"
       
    25 #include "hnmdbooleankey.h"
       
    26 #include "hnmdstring16key.h"
       
    27 #include "hnmdmapkey.h"
       
    28 #include "hnmdlistkey.h"
       
    29 #include "hnmdundefkey.h"
       
    30 #include "hnglobals.h"
       
    31 #include "hnmdkeyfactory.h"
       
    32 
       
    33 
       
    34 // ======== MEMBER FUNCTIONS ========
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // 
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C CHnMdBaseKey* HnMdKeyFactory::CreateLC( TXmlEngElement aElement )
       
    41     {
       
    42     CHnMdBaseKey* self = NULL;
       
    43     
       
    44     // First we are testing if the key contains any
       
    45     // runtime alterable parameters. If so, they have to be constructed 
       
    46     // differently
       
    47 //    if ( aElement.HasAttributeL( KValueAttrName8) && 
       
    48 //            aElement.HasAttributeL( KTypeAttrName8 ) ) 
       
    49 //        {
       
    50 //        TXmlEngAttr keyValue = aElement.AttributeNodeL( KValueAttrName8 );
       
    51 //        TXmlEngAttr keyType = aElement.AttributeNodeL( KTypeAttrName8 );
       
    52 //        if ( keyValue.Value().Find( HnEvent::KEventArgNamespace) 
       
    53 //                != KErrNotFound)
       
    54 //            {
       
    55 //            self = CHnMdDynamicKey::NewL( keyType.Value() );
       
    56 //            }
       
    57 //        }
       
    58     
       
    59     if ( aElement.HasAttributeL( KTypeAttrName8 ) )
       
    60         {
       
    61         TXmlEngAttr type = aElement.AttributeNodeL( KTypeAttrName8 );
       
    62         const TPtrC8 &name = type.Value();
       
    63         self = HnMdKeyFactory::CreateL( name );
       
    64         }
       
    65     else
       
    66         {
       
    67         self = CHnMdMapKey::NewL();
       
    68         }
       
    69     
       
    70     CleanupStack::PushL( self );
       
    71     self->BaseConstructL( aElement );
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // 
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CHnMdBaseKey* HnMdKeyFactory::CreateL( TXmlEngElement aElement )
       
    80     {
       
    81     CHnMdBaseKey* self = HnMdKeyFactory::CreateLC( aElement );
       
    82     CleanupStack::Pop( self );
       
    83     return self;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // 
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C CHnMdBaseKey* HnMdKeyFactory::CreateL(
       
    91     const TDesC8& aName,
       
    92     const TDesC8& aType,
       
    93     const TDesC8& aValue )
       
    94     {
       
    95     CHnMdBaseKey* self = HnMdKeyFactory::CreateL( aType );
       
    96     CleanupStack::PushL( self );
       
    97     self->SetValueL( aValue );
       
    98     self->SetKeyNameL( aName );
       
    99     CleanupStack::Pop( self );
       
   100     return self;
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // 
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C CHnMdBaseKey* HnMdKeyFactory::CreateL(
       
   108     const TDesC8& aName,
       
   109     const TDesC8& aType,
       
   110     const TDesC& aValue )
       
   111     {
       
   112     CHnMdBaseKey* self = HnMdKeyFactory::CreateL( aType );
       
   113     CleanupStack::PushL( self );
       
   114     self->SetValueL( aValue );
       
   115     self->SetKeyNameL( aName );
       
   116     CleanupStack::Pop( self );
       
   117     return self;
       
   118     }
       
   119 // ---------------------------------------------------------------------------
       
   120 // 
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 CHnMdBaseKey* HnMdKeyFactory::CreateL( const TDesC8& aType )
       
   124     {
       
   125     CHnMdBaseKey* key = NULL;
       
   126     
       
   127     if ( !aType.Compare( KKeyTypeString ) )
       
   128         {
       
   129         key = CHnMdString16Key::NewL(); //String
       
   130         }
       
   131     else if ( !aType.Compare( KKeyTypeString8 ) )
       
   132         {
       
   133         key = CHnMdString8Key::NewL(); //String8
       
   134         }
       
   135     else if ( !aType.Compare( KKeyTypeInteger ) )
       
   136         {
       
   137         key = CHnMdIntegerKey::NewL(); //Integer
       
   138         }
       
   139     else if ( !aType.Compare( KKeyTypeInteger64 ) )
       
   140         {
       
   141         key = CHnMdInteger64Key::NewL(); //Integer64
       
   142         }
       
   143     else if ( !aType.Compare( KKeyTypeUInteger ) )
       
   144         {
       
   145         key = CHnMdUIntegerKey::NewL(); //Unsigned Integer
       
   146         }
       
   147     else if ( !aType.Compare( KKeyTypeUid ) )
       
   148         {
       
   149         key = CHnMdUidKey::NewL(); //Uid
       
   150         }
       
   151     else if ( !aType.Compare( KKeyTypeBoolean ) )
       
   152         {
       
   153         key = CHnMdBooleanKey::NewL(); //Boolean
       
   154         }
       
   155     else if ( !aType.Compare( KKeyTypeString16 ) )
       
   156         {
       
   157         key = CHnMdString16Key::NewL(); //String16
       
   158         }
       
   159     else if ( !aType.Compare( KKeyTypeMap ) )
       
   160         {
       
   161         key = CHnMdMapKey::NewL(); //Map
       
   162         }
       
   163     else if ( !aType.Compare( KKeyTypeList ) )
       
   164         {
       
   165         key = CHnMdListKey::NewL(); //List
       
   166         }
       
   167     else
       
   168         {
       
   169         key = CHnMdUndefKey::NewL(); //Undefined
       
   170         }
       
   171 
       
   172     return key;
       
   173     }
       
   174