xdmprotocols/LocalProtocol/LocalOperations/src/LocalOperationFactory.cpp
branchRCL_3
changeset 18 fbd2e7cec7ef
parent 0 c8caa15ef882
equal deleted inserted replaced
17:2669f8761a99 18:fbd2e7cec7ef
       
     1 /*
       
     2 * Copyright (c) 2005 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: CLocalOperationFactory
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <ecom.h>
       
    21 #include <e32debug.h>
       
    22 #include <xdmlogwriter.h>
       
    23 #include <implementationproxy.h>
       
    24 #include "XdmOperation.h"
       
    25 #include "LocalRetrieval.h"
       
    26 #include "LocalAddition.h"
       
    27 #include "LocalReplacement.h"
       
    28 #include "LocalDeletion.h"
       
    29 #include "LocalProtocol.h"
       
    30 #include "LocalOperationFactory.h"
       
    31 
       
    32 // ---------------------------------------------------------
       
    33 // CLocalOperationFactory::CLocalOperationFactory
       
    34 // 
       
    35 // ---------------------------------------------------------
       
    36 //
       
    37 CLocalOperationFactory::CLocalOperationFactory()
       
    38     {   
       
    39     }
       
    40     
       
    41 // ---------------------------------------------------------
       
    42 // CLocalOperationFactory::NewL
       
    43 // 
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 CLocalOperationFactory* CLocalOperationFactory::NewL()
       
    47     {
       
    48     CLocalOperationFactory* self = new ( ELeave ) CLocalOperationFactory();
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop();
       
    52     return self;
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------
       
    56 // CLocalOperationFactory::ConstructL
       
    57 // 
       
    58 // ---------------------------------------------------------
       
    59 //
       
    60 void CLocalOperationFactory::ConstructL()
       
    61     {
       
    62     #ifdef _DEBUG
       
    63         iLogWriter = CXdmLogWriter::NewL( KLocalOpLogFile );
       
    64         WriteToLog( _L8( "CLocalOperationFactory::ConstructL()" ) );
       
    65     #endif
       
    66     }
       
    67             
       
    68 // ---------------------------------------------------------
       
    69 // CLocalOperationFactory::~CLocalOperationFactory
       
    70 // 
       
    71 // ---------------------------------------------------------
       
    72 //
       
    73 CLocalOperationFactory::~CLocalOperationFactory()
       
    74     {
       
    75     #ifdef _DEBUG
       
    76         WriteToLog( _L8( "CLocalOperationFactory::~CLocalOperationFactory()" ) );
       
    77     #endif
       
    78     delete iLogWriter;
       
    79     }
       
    80     
       
    81 // ---------------------------------------------------------
       
    82 // CLocalOperationFactory::FetchL
       
    83 // 
       
    84 // ---------------------------------------------------------
       
    85 //	
       
    86 MXdmOperation* CLocalOperationFactory::FetchL( CXdmDocument& aTargetDocument,
       
    87                                                CXdmDocumentNode* aTargetNode ) const
       
    88     {
       
    89     return CLocalRetrieval::NewL( ( CLocalDocument& )aTargetDocument,
       
    90                                   ( CLocalDocumentNode* )aTargetNode,
       
    91                                   const_cast<CLocalOperationFactory&>( *this ) );
       
    92     }       
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CLocalOperationFactory::InsertL
       
    96 // 
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 MXdmOperation* CLocalOperationFactory::InsertL( CXdmDocument& aTargetDocument,
       
   100                                                 CXdmDocumentNode* aTargetNode ) const
       
   101     {
       
   102     return CLocalAddition::NewL( ( CLocalDocument& )aTargetDocument,
       
   103                                  ( CLocalDocumentNode* )aTargetNode,
       
   104                                  const_cast<CLocalOperationFactory&>( *this ) );
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------
       
   108 // CLocalOperationFactory::ReplaceL
       
   109 // 
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 MXdmOperation* CLocalOperationFactory::ReplaceL( CXdmDocument& aOldDocument, 
       
   113                                                  CXdmDocumentNode* aNewNode,
       
   114                                                  CXdmDocumentNode* aOldNode  ) const
       
   115     {
       
   116     return CLocalReplacement::NewL( ( CLocalDocument& )aOldDocument,
       
   117                                     ( CLocalDocumentNode* )aNewNode,
       
   118                                     ( CLocalDocumentNode* )aOldNode,
       
   119                                     const_cast<CLocalOperationFactory&>( *this ) );
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // CLocalOperationFactory::AppendL
       
   124 // 
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 MXdmOperation* CLocalOperationFactory::AppendL( CXdmDocument& aTargetDocument,
       
   128                                                 CXdmDocumentNode* aTargetNode ) const
       
   129     { 
       
   130     return CLocalAddition::NewL( ( CLocalDocument& )aTargetDocument,
       
   131                                  ( CLocalDocumentNode* )aTargetNode,
       
   132                                  const_cast<CLocalOperationFactory&>( *this ) );
       
   133     }              
       
   134 
       
   135 // ---------------------------------------------------------
       
   136 // CLocalOperationFactory::PartialDeletionL
       
   137 // 
       
   138 // ---------------------------------------------------------
       
   139 //
       
   140 MXdmOperation* CLocalOperationFactory::DeletionL( CXdmDocument& aTargetDocument,
       
   141                                                   CXdmDocumentNode* aTargetNode ) const
       
   142     {
       
   143     return CLocalDeletion::NewL( ( CLocalDocument& )aTargetDocument,
       
   144                                  ( CLocalDocumentNode* )aTargetNode,
       
   145                                  const_cast<CLocalOperationFactory&>( *this ) );
       
   146     }              
       
   147 
       
   148 // ----------------------------------------------------------
       
   149 // CLocalOperationFactory::WriteToLog
       
   150 // 
       
   151 // ----------------------------------------------------------
       
   152 //
       
   153 void CLocalOperationFactory::WriteToLog( TRefByValue<const TDesC8> aFmt,... )                                 
       
   154     {
       
   155     VA_LIST list;
       
   156     VA_START( list, aFmt );
       
   157     TBuf8<KLogBufferMaxSize> buf;
       
   158     buf.FormatList( aFmt, list );
       
   159     iLogWriter->WriteToLog( buf );
       
   160     }
       
   161         
       
   162 // ---------------------------------------------------------
       
   163 // Map the interface UIDs to implementation factory functions
       
   164 // 
       
   165 // ---------------------------------------------------------
       
   166 //
       
   167 const TImplementationProxy ImplementationTable[] = 
       
   168 	{
       
   169 #ifdef __EABI__
       
   170     IMPLEMENTATION_PROXY_ENTRY( KLocalOperationFactory,	CLocalOperationFactory::NewL )
       
   171 #else
       
   172     { { KLocalOperationFactory }, CLocalOperationFactory::NewL }
       
   173 #endif
       
   174     };
       
   175 
       
   176 // ---------------------------------------------------------
       
   177 // Return the implementation table & number of implementations
       
   178 // 
       
   179 // ---------------------------------------------------------
       
   180 //
       
   181 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   182     {
       
   183     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
   184     return ImplementationTable;
       
   185     }
       
   186