installationservices/swi/inc/swi/ipcutil.h
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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 the License "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 * Library to add s32strm support for IPC (ie. stream via multiple IPC read/writes instead of
       
    16 * copying to a buffer and streaming to/from there.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalTechnology
       
    24  @released
       
    25 */
       
    26 
       
    27 #ifndef _IPCUTIL_H_
       
    28 #define _IPCUTIL_H_
       
    29 
       
    30 #include <scs/ipcstream.h>
       
    31 #include <scs/streamingarray.h>
       
    32 
       
    33 
       
    34 template <class T>
       
    35 TInt GetObjectSizeL(const T* aObject)
       
    36     {
       
    37     TInt size(0);
       
    38    	if(aObject)
       
    39         {
       
    40         RNullWriteStream nullstream;
       
    41         CleanupClosePushL(nullstream);
       
    42         nullstream << *aObject;
       
    43         nullstream.CommitL();
       
    44         size = nullstream.BytesWritten();
       
    45         CleanupStack::PopAndDestroy(&nullstream);
       
    46         return size;
       
    47         }
       
    48    	return -1;
       
    49     }
       
    50 
       
    51 template <class T>
       
    52 void WriteObjectDataL(const RMessage2& aMessage, TInt aParam, const T* aObject)
       
    53     {
       
    54     if(!aObject)
       
    55         {
       
    56         User::Leave(KErrAbort);
       
    57         }
       
    58     RIpcWriteStream ipcstream;
       
    59     ipcstream.Open(aMessage, aParam);
       
    60     CleanupClosePushL(ipcstream);
       
    61     ipcstream << *aObject;
       
    62     CleanupStack::PopAndDestroy(&ipcstream); // Data is committed in Close method
       
    63     }
       
    64 
       
    65 #endif /* _IPCUTIL_H_ */