ncdengine/provider/server/src/ncdchildentity.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Implements CNcdChildEntity class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32cmn.h>
       
    20 #include <s32strm.h>
       
    21 #include <s32mem.h>
       
    22 
       
    23 #include "ncdchildentity.h"
       
    24 #include "ncdnodeidentifier.h"
       
    25 #include "catalogsutils.h"
       
    26 #include "catalogsconstants.h"
       
    27 
       
    28 
       
    29 CNcdChildEntity* CNcdChildEntity::NewL( 
       
    30     TInt aIndex,
       
    31     const CNcdNodeIdentifier& aNodeIdentifier,
       
    32     TBool aTransparent,
       
    33     CNcdNodeFactory::TNcdNodeType aNodeType )
       
    34     {
       
    35     CNcdChildEntity* self = 
       
    36         CNcdChildEntity::NewLC( aIndex, aNodeIdentifier, aTransparent, aNodeType );
       
    37     CleanupStack::Pop( self );
       
    38     return self;        
       
    39     }
       
    40     
       
    41 CNcdChildEntity* CNcdChildEntity::NewLC( 
       
    42     TInt aIndex,
       
    43     const CNcdNodeIdentifier& aNodeIdentifier,
       
    44     TBool aTransparent,
       
    45     CNcdNodeFactory::TNcdNodeType aNodeType )
       
    46     {
       
    47     CNcdChildEntity* self = 
       
    48         new( ELeave ) CNcdChildEntity( aIndex, aTransparent, aNodeType );
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL( aNodeIdentifier );
       
    51     return self;
       
    52     }
       
    53 
       
    54 CNcdChildEntity* CNcdChildEntity::NewLC( RReadStream& aReadStream )
       
    55     {
       
    56     CNcdChildEntity* self = 
       
    57         new( ELeave ) CNcdChildEntity();
       
    58     CleanupStack::PushL( self );
       
    59     self->InternalizeL( aReadStream );
       
    60     return self;        
       
    61     }
       
    62 
       
    63 CNcdChildEntity* CNcdChildEntity::NewL( RReadStream& aReadStream )
       
    64     {
       
    65     CNcdChildEntity* self = NewLC( aReadStream );
       
    66     CleanupStack::Pop( self );
       
    67     return self;        
       
    68     }
       
    69 
       
    70 CNcdChildEntity* CNcdChildEntity::NewL( const CNcdChildEntity& aChildEntity )
       
    71     {
       
    72     CNcdChildEntity* self = 
       
    73         CNcdChildEntity::NewLC( aChildEntity );
       
    74     CleanupStack::Pop( self );
       
    75     return self;        
       
    76     }
       
    77 
       
    78 CNcdChildEntity* CNcdChildEntity::NewLC( const CNcdChildEntity& aChildEntity )
       
    79     {
       
    80     CNcdChildEntity* self = 
       
    81         new( ELeave ) CNcdChildEntity( aChildEntity.Index(),
       
    82             aChildEntity.IsTransparent(), aChildEntity.NodeType() );
       
    83     CleanupStack::PushL( self );
       
    84     self->ConstructL( aChildEntity.Identifier() );
       
    85     return self;
       
    86     }
       
    87 
       
    88 const CNcdNodeIdentifier& CNcdChildEntity::Identifier() const
       
    89     {
       
    90     return *iIdentifier;
       
    91     }
       
    92     
       
    93 void CNcdChildEntity::SetIdentifierL( const CNcdNodeIdentifier& aIdentifier )
       
    94     {
       
    95     CNcdNodeIdentifier* temp = CNcdNodeIdentifier::NewL( aIdentifier );
       
    96     delete iIdentifier;
       
    97     iIdentifier = temp;
       
    98     }
       
    99     
       
   100 TInt CNcdChildEntity::Index() const
       
   101     {
       
   102     return iIndex;
       
   103     }
       
   104 
       
   105 void CNcdChildEntity::InternalizeL( RReadStream& aReadStream )
       
   106     {
       
   107     iIndex = aReadStream.ReadInt32L();
       
   108     delete iIdentifier;
       
   109     iIdentifier = NULL;
       
   110     iIdentifier = CNcdNodeIdentifier::NewL( aReadStream );
       
   111     iTransparent = aReadStream.ReadInt8L();
       
   112     iNodeType =
       
   113         static_cast<CNcdNodeFactory::TNcdNodeType>( aReadStream.ReadInt8L() );
       
   114     }
       
   115 
       
   116 void CNcdChildEntity::ExternalizeL( RWriteStream& aWriteStream ) const
       
   117     {
       
   118     aWriteStream.WriteInt32L( iIndex );
       
   119     iIdentifier->ExternalizeL( aWriteStream );
       
   120     aWriteStream.WriteInt8L( iTransparent );
       
   121     aWriteStream.WriteInt8L( iNodeType );
       
   122     }
       
   123         
       
   124 
       
   125 TBool CNcdChildEntity::Equals( const CNcdChildEntity& aObject ) const
       
   126     {
       
   127     // iTransparent is ignored in equality checks
       
   128     return iIdentifier->Equals( aObject.Identifier() ) &&
       
   129         iIndex == aObject.Index();
       
   130     }
       
   131     
       
   132 TBool CNcdChildEntity::IsTransparent() const
       
   133     {
       
   134     return iTransparent;
       
   135     }
       
   136     
       
   137 void CNcdChildEntity::SetTransparent( TBool aTransparent )
       
   138     {
       
   139     iTransparent = aTransparent;
       
   140     }
       
   141     
       
   142 CNcdNodeFactory::TNcdNodeType CNcdChildEntity::NodeType() const
       
   143     {
       
   144     return iNodeType;
       
   145     }
       
   146     
       
   147 void CNcdChildEntity::SetNodeType( CNcdNodeFactory::TNcdNodeType aNodeType )
       
   148     {
       
   149     iNodeType = aNodeType;
       
   150     }
       
   151 
       
   152 CNcdChildEntity::CNcdChildEntity( 
       
   153     TInt aIndex,
       
   154     TBool aTransparent,
       
   155     CNcdNodeFactory::TNcdNodeType aNodeType ) 
       
   156     : iIndex( aIndex ),
       
   157       iTransparent( aTransparent ),
       
   158       iNodeType( aNodeType )
       
   159     {
       
   160     }
       
   161     
       
   162 CNcdChildEntity::CNcdChildEntity()
       
   163     {
       
   164     }
       
   165 
       
   166 void CNcdChildEntity::ConstructL( const CNcdNodeIdentifier& aIdentifier )
       
   167     {
       
   168     iIdentifier = CNcdNodeIdentifier::NewL( aIdentifier );
       
   169     }
       
   170 
       
   171 CNcdChildEntity::~CNcdChildEntity()
       
   172     {
       
   173     delete iIdentifier;
       
   174     }