inc/mdcserializationtype.h
changeset 0 c53acadfccc6
child 26 9f21bab39f42
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2007-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 "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:  common item type for all MdE objects
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mdscommoninternal.h"
       
    19 #include "mdcserializationbuffer.h"
       
    20 
       
    21 
       
    22 #ifndef __MDCSERIALIZATIONTYPE_H__
       
    23 #define __MDCSERIALIZATIONTYPE_H__
       
    24 
       
    25 NONSHARABLE_CLASS(TMdCSerializationType)
       
    26 	{
       
    27 	protected:
       
    28 		enum TMdCStructTypes
       
    29 			{
       
    30 			//EMdCItem,
       
    31 			EMdCObject,
       
    32 			EMdCProperty,
       
    33 			EMdCRelation,
       
    34 			EMdCEvent,
       
    35 			EMdCObjectDef,
       
    36 			EMdCPropertyDef,
       
    37 			EMdCRelationDef,
       
    38 			EMdCEventDef,
       
    39 			EMdCNamespaceDef,
       
    40 			EMdCSchema,
       
    41 			EMdCItems,
       
    42 			EMdCItemIds,
       
    43 			EMdCItemCount,
       
    44 			EMdCLogicCondition,
       
    45 			EMdCObjectCondition,
       
    46 			EMdCEventCondition,
       
    47 			EMdCRelationCondition,
       
    48 			EMdCPropertyCondition,
       
    49 			EMdCSearchCriteria,
       
    50 			EMdCOrderRule,
       
    51 			};
       
    52 	
       
    53 		typedef TInt16 TMdCStructType;
       
    54 	
       
    55 	protected:
       
    56 		TMdCSerializationType(TMdCStructTypes aType) : iType( aType )
       
    57 			{
       
    58 			}
       
    59 
       
    60 		/**
       
    61 		 * Those methods MUST be always use for serializing
       
    62 		 */
       
    63 		inline void SerializeL(CMdCSerializationBuffer& aBuffer, TUint32 aSize)
       
    64 			{
       
    65 			aBuffer.InsertL( *this, aSize );
       
    66 			}
       
    67 
       
    68 		inline void DeserializeL(CMdCSerializationBuffer& aBuffer, TUint32 aSize)
       
    69 			{
       
    70 			const TMdCStructTypes type = iType;
       
    71 			
       
    72 			aBuffer.ReceiveL( *this, aSize );
       
    73 			
       
    74 			if( type != iType )
       
    75 				{
       
    76 				_LIT( KTMdCSerializationType, "TMdCSerializationType" );
       
    77 				__ASSERT_DEBUG( EFalse, User::Panic( KTMdCSerializationType, KErrCorrupt ) );
       
    78 
       
    79 				User::Leave( KErrCorrupt );
       
    80 				}
       
    81 			}
       
    82 		
       
    83 	protected:
       
    84 		const TMdCStructTypes iType;
       
    85 	};
       
    86 
       
    87 #endif /* __MDCSERIALIZATIONTYPE_H__ */