presencecache/inc/cacheobjecthelpers.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 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:  Templated algorithms to simplify object handling
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef PRESENCECACHEOBJECTHELPERS_H
       
    19 #define PRESENCECACHEOBJECTHELPERS_H
       
    20 
       
    21 #include <s32mem.h>
       
    22 
       
    23 
       
    24 const TInt KObjectBufGranurality = 100;
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 /**
       
    30  * Templated object packer.
       
    31  *
       
    32  * Object type must support: NewLC(),
       
    33  * ExternalizeL() and InternalizeL().
       
    34  *
       
    35  * @since S60 v3.2
       
    36  */
       
    37 template< class T >
       
    38 class TCacheObjectPacker
       
    39     {
       
    40  public:
       
    41 
       
    42     /**
       
    43      * Templated method to pack object.
       
    44      *
       
    45      * Packs given object data to flat buffer and
       
    46      * returns buffer to caller.
       
    47      *
       
    48      * @param aObj Templated object to pack.
       
    49      *             Object type must support ExternalizeL() method.
       
    50      *
       
    51      * @return Buffer containing externalized object data.
       
    52      *         Buffer ownership is returned to caller.
       
    53      */
       
    54     static inline HBufC8* PackL( const T& aObj );
       
    55 
       
    56 
       
    57 
       
    58     /**
       
    59      * Templated method to unpack object.
       
    60      *
       
    61      * Extracts object data from given flat buffer and
       
    62      * returns objects ownership to caller.
       
    63      *
       
    64      * @param aObj Object which data to internalize from package.
       
    65      *             Concrete object type must support InternalizeL() method.
       
    66      *
       
    67      * @Param aPack Buffer containing object data.
       
    68      */
       
    69     static void UnPackL( T& aObj,
       
    70                          const TDesC8& aPack );
       
    71 
       
    72 private:   //Prohibited constructor
       
    73     TCacheObjectPacker();
       
    74 
       
    75     };
       
    76 
       
    77 
       
    78 #include "cacheobjecthelpers.inl"
       
    79 
       
    80 
       
    81 #endif // PRESENCECACHEOBJECTHELPERS_H